aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2012-07-09 15:04:00 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2012-07-11 17:09:04 +0200
commitdfe82160e4f70f52d75e2b6b70e89caf6256cf69 (patch)
tree35cae7e03c848a00789175b30c5d7bd49276ea21
parent87efdef35b2a88ae239abe05b91f34c79fa6c959 (diff)
downloadstrongswan-dfe82160e4f70f52d75e2b6b70e89caf6256cf69.tar.bz2
strongswan-dfe82160e4f70f52d75e2b6b70e89caf6256cf69.tar.xz
some tls_eap optimizations
-rw-r--r--src/libtls/tls_eap.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/libtls/tls_eap.c b/src/libtls/tls_eap.c
index 1354fa144..613431822 100644
--- a/src/libtls/tls_eap.c
+++ b/src/libtls/tls_eap.c
@@ -150,10 +150,12 @@ METHOD(tls_eap_t, initiate, status_t,
*/
static status_t process_pkt(private_tls_eap_t *this, eap_tls_packet_t *pkt)
{
- u_int32_t msg_len;
u_int16_t pkt_len;
+ u_int32_t msg_len;
+ size_t msg_len_offset = 0;
pkt_len = untoh16(&pkt->length);
+
if (pkt->flags & EAP_TLS_LENGTH)
{
if (pkt_len < sizeof(eap_tls_packet_t) + sizeof(msg_len))
@@ -169,11 +171,11 @@ static status_t process_pkt(private_tls_eap_t *this, eap_tls_packet_t *pkt)
this->type, msg_len);
return FAILED;
}
- return this->tls->process(this->tls, (char*)(pkt + 1) + sizeof(msg_len),
- pkt_len - sizeof(eap_tls_packet_t) - sizeof(msg_len));
+ msg_len_offset = sizeof(msg_len);
}
- return this->tls->process(this->tls, (char*)(pkt + 1),
- pkt_len - sizeof(eap_tls_packet_t));
+
+ return this->tls->process(this->tls, (char*)(pkt + 1) + msg_len_offset,
+ pkt_len - sizeof(eap_tls_packet_t) - msg_len_offset);
}
/**
@@ -183,7 +185,7 @@ static status_t build_pkt(private_tls_eap_t *this, chunk_t *out)
{
char buf[this->frag_size];
eap_tls_packet_t *pkt;
- size_t len, reclen;
+ size_t len, reclen, msg_len_offset;
status_t status;
char *kind;
@@ -215,15 +217,16 @@ static status_t build_pkt(private_tls_eap_t *this, chunk_t *out)
if (this->first_fragment)
{
len = sizeof(buf) - sizeof(eap_tls_packet_t) - sizeof(u_int32_t);
- status = this->tls->build(this->tls, buf + sizeof(eap_tls_packet_t) +
- sizeof(u_int32_t), &len, &reclen);
+ msg_len_offset = sizeof(u_int32_t);
}
else
{
len = sizeof(buf) - sizeof(eap_tls_packet_t);
- status = this->tls->build(this->tls, buf + sizeof(eap_tls_packet_t),
- &len, &reclen);
+ msg_len_offset = 0;
}
+ status = this->tls->build(this->tls, buf + sizeof(eap_tls_packet_t) +
+ msg_len_offset, &len, &reclen);
+
switch (status)
{
case NEED_MORE: