From: Nikos Mavrogiannopoulos Date: Mon, 5 Nov 2001 20:14:57 +0000 (+0000) Subject: changed semantics of the GNUTLS_E_REHANDSHAKE error code. X-Git-Tag: gnutls_0_2_11~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d490dcdc70bc21da7d49abd3c33236b2236db1cf;p=thirdparty%2Fgnutls.git changed semantics of the GNUTLS_E_REHANDSHAKE error code. --- diff --git a/NEWS b/NEWS index 18ea7b03dc..90432a4fab 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +Version 0.2.11 +- Changed the meaning of GNUTLS_E_REHANDSHAKE value. If this value + is returned, then the caller should perform a handshake or send + an alert to the peer. + Version 0.2.10 (5/11/2001) - Corrected bugs and improved non blocking IO - Added hooks to use external database to store sessions diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c index c8eac441d8..2b367bc67f 100644 --- a/lib/gnutls_handshake.c +++ b/lib/gnutls_handshake.c @@ -1807,7 +1807,7 @@ int _gnutls_recv_hello_request(SOCKET cd, GNUTLS_STATE state, void *data, } return 0; -#else /* this does not seem to work - yet */ +#else /* this does seem to work - now */ uint8 type; if (state->security_parameters.entity == GNUTLS_SERVER) { @@ -1820,7 +1820,7 @@ int _gnutls_recv_hello_request(SOCKET cd, GNUTLS_STATE state, void *data, } type = ((uint8 *) data)[0]; if (type == GNUTLS_HELLO_REQUEST) - return gnutls_handshake(cd, state); + return GNUTLS_E_REHANDSHAKE; else { gnutls_assert(); return GNUTLS_E_UNEXPECTED_PACKET; diff --git a/lib/gnutls_record.c b/lib/gnutls_record.c index b17fec6b1f..2ede69d253 100644 --- a/lib/gnutls_record.c +++ b/lib/gnutls_record.c @@ -899,10 +899,6 @@ ssize_t gnutls_recv_int(SOCKET cd, GNUTLS_STATE state, ContentType type, Handsha if (recv_type == GNUTLS_HANDSHAKE) { /* we may get a hello request */ ret = _gnutls_recv_hello_request( cd, state, tmpdata, tmplen); - if (ret < 0) { - gnutls_assert(); - } else /* inform the caller */ - ret = GNUTLS_E_REHANDSHAKE; } else { gnutls_assert(); ret = GNUTLS_E_UNEXPECTED_PACKET; @@ -1078,6 +1074,11 @@ ssize_t gnutls_write(SOCKET cd, GNUTLS_STATE state, const void *data, size_t siz * difference is that is accepts a GNUTLS state. * Returns the number of bytes received, zero on EOF, or * a negative error code. + * + * If this function returns GNUTLS_E_REHANDSHAKE, then you must + * either send an alert containing NO_RENEGOTIATION, or perform a + * handshake. (only a client may receive this message) + * **/ ssize_t gnutls_read(SOCKET cd, GNUTLS_STATE state, void *data, size_t sizeofdata) { return gnutls_recv_int( cd, state, GNUTLS_APPLICATION_DATA, -1, data, sizeofdata); diff --git a/src/cli.c b/src/cli.c index 0b06a45181..1e94b599a1 100644 --- a/src/cli.c +++ b/src/cli.c @@ -348,9 +348,15 @@ int main(int argc, char** argv) } else { if (ret==GNUTLS_E_WARNING_ALERT_RECEIVED || ret==GNUTLS_E_FATAL_ALERT_RECEIVED) printf("* Received alert [%d]\n", gnutls_get_last_alert(state)); - if (ret==GNUTLS_E_REHANDSHAKE) - printf("* Rehandshake was performed\n"); - + if (ret==GNUTLS_E_REHANDSHAKE) { + do { + ret = gnutls_handshake( sd, state); + } while( ret==GNUTLS_E_AGAIN || ret==GNUTLS_E_INTERRUPTED); + if (ret==0) printf("* Rehandshake was performed\n"); + else { + printf("* Rehandshake Failed [%d]\n", ret); + } + } if (ret > 0) { printf("- Received[%d]: ", ret); for (ii=0;ii