diff options
author | Martin Willi <martin@revosec.ch> | 2010-08-31 08:57:26 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2010-08-31 15:54:37 +0200 |
commit | ecd98efa9d5cb1c6f3e14ee5c8a97d405d3a1ef9 (patch) | |
tree | 87aae03ce2a255489bfeda6ce463608efa9e847b /src/libtls/tls_socket.c | |
parent | f13a03add0553d6d7c9d989d0de4ee68fa35acb4 (diff) | |
download | strongswan-ecd98efa9d5cb1c6f3e14ee5c8a97d405d3a1ef9.tar.bz2 strongswan-ecd98efa9d5cb1c6f3e14ee5c8a97d405d3a1ef9.tar.xz |
Support output fragmentation of TLS records
Diffstat (limited to 'src/libtls/tls_socket.c')
-rw-r--r-- | src/libtls/tls_socket.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/libtls/tls_socket.c b/src/libtls/tls_socket.c index 6aa776879..e0c440a4c 100644 --- a/src/libtls/tls_socket.c +++ b/src/libtls/tls_socket.c @@ -96,25 +96,31 @@ METHOD(tls_application_t, build, status_t, */ static bool exchange(private_tls_socket_t *this, bool wr) { - chunk_t data; - char buf[2048]; + char buf[1024]; ssize_t len; int round = 0; for (round = 0; TRUE; round++) { - if (this->tls->build(this->tls, &data) != NEED_MORE) - { - return FALSE; - } - if (data.len) + while (TRUE) { - len = write(this->fd, data.ptr, data.len); - free(data.ptr); - if (len != data.len) + len = sizeof(buf); + switch (this->tls->build(this->tls, buf, &len, NULL)) { - return FALSE; + case NEED_MORE: + case ALREADY_DONE: + len = write(this->fd, buf, len); + if (len == -1) + { + return FALSE; + } + continue; + case INVALID_STATE: + break; + default: + return FALSE; } + break; } if (wr) { @@ -139,7 +145,7 @@ static bool exchange(private_tls_socket_t *this, bool wr) { return FALSE; } - if (this->tls->process(this->tls, chunk_create(buf, len)) != NEED_MORE) + if (this->tls->process(this->tls, buf, len) != NEED_MORE) { return FALSE; } |