From: Nikos Mavrogiannopoulos Date: Fri, 4 Jan 2002 11:19:52 +0000 (+0000) Subject: Cleanups X-Git-Tag: gnutls_0_3_2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78fcf46acfef31b49960d2a7fee7c172a1116bf0;p=thirdparty%2Fgnutls.git Cleanups --- diff --git a/configure.in b/configure.in index c96e7bbd05..704402e4f8 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ AC_DEFINE_UNQUOTED(T_OS, "$target_os") GNUTLS_MAJOR_VERSION=0 GNUTLS_MINOR_VERSION=3 -GNUTLS_MICRO_VERSION=1 +GNUTLS_MICRO_VERSION=2 GNUTLS_VERSION=$GNUTLS_MAJOR_VERSION.$GNUTLS_MINOR_VERSION.$GNUTLS_MICRO_VERSION AC_DEFINE_UNQUOTED(GNUTLS_VERSION, "$GNUTLS_VERSION") diff --git a/lib/auth_rsa.c b/lib/auth_rsa.c index 27cd1ce63a..d155a48d70 100644 --- a/lib/auth_rsa.c +++ b/lib/auth_rsa.c @@ -160,10 +160,6 @@ int gen_rsa_client_kx(GNUTLS_STATE state, opaque ** data) RANDOMIZE_KEY(state->gnutls_key->key, gnutls_secure_malloc); ver = _gnutls_get_adv_version( state); - /* Some implementations do not interoperate if we send the - * latest version (the one send in the client hello). They'd - * rather use the one in the client hello record header. - */ state->gnutls_key->key.data[0] = _gnutls_version_get_major(ver); state->gnutls_key->key.data[1] = _gnutls_version_get_minor(ver); diff --git a/lib/gnutls_auth.c b/lib/gnutls_auth.c index e2be2b9b4e..7522504867 100644 --- a/lib/gnutls_auth.c +++ b/lib/gnutls_auth.c @@ -24,6 +24,7 @@ #include "gnutls_auth_int.h" #include "gnutls_algorithms.h" #include "auth_x509.h" +#include #include "auth_anon.h" /* The functions here are used in order for authentication algorithms diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c index 2e4774de2f..6d8bb7dde5 100644 --- a/lib/gnutls_handshake.c +++ b/lib/gnutls_handshake.c @@ -1369,9 +1369,18 @@ static int _gnutls_send_client_hello(GNUTLS_STATE state, int again) /* Set the version we advertized as maximum * (RSA uses it). */ - _gnutls_set_current_version(state, hver); _gnutls_set_adv_version( state, hver); + /* Some implementations do not interoperate if we send a + * different version in the record layer. + * It seems they prefer to read the record's version + * as the one we actually requested. + * The proper behaviour is to use the one in the client hello + * handshake packet and ignore the one in the packet's record + * header. + */ + _gnutls_set_current_version(state, hver); + /* In order to know when this session was initiated. */ state->security_parameters.timestamp = time(NULL); diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h index 41b6dc3f93..e68f6799c5 100644 --- a/lib/gnutls_int.h +++ b/lib/gnutls_int.h @@ -491,7 +491,6 @@ typedef struct GNUTLS_STATE_INT *GNUTLS_STATE; /* functions */ -int gnutls_send_alert( GNUTLS_STATE state, AlertLevel level, AlertDescription desc); int gnutls_PRF( opaque * secret, int secret_size, uint8 * label, int label_size, opaque * seed, int seed_size, int total_bytes, void* ret); diff --git a/lib/gnutls_kx.c b/lib/gnutls_kx.c index b4e57b0935..4dc8031e0e 100644 --- a/lib/gnutls_kx.c +++ b/lib/gnutls_kx.c @@ -28,6 +28,7 @@ #include "gnutls_gcry.h" #include #include +#include /* This file contains important thing for the TLS handshake procedure. */ diff --git a/lib/gnutls_priority.c b/lib/gnutls_priority.c index f3183728f5..9412e3bdd7 100644 --- a/lib/gnutls_priority.c +++ b/lib/gnutls_priority.c @@ -182,7 +182,6 @@ int num=0, i; int gnutls_protocol_set_priority( GNUTLS_STATE state, GNUTLS_LIST list) { GNUTLS_LIST _list = list; int num=0, i; -GNUTLS_Version ver; while( *_list != 0) { num++; @@ -205,13 +204,11 @@ GNUTLS_Version ver; state->gnutls_internals.ProtocolPriority.algorithm_priority[i] = list[i]; } - /* set the current version to the latest supported + /* set the current version to the first in the chain. + * This will be overriden later. */ - ver = _gnutls_version_max( state); - if (ver < 0) { - gnutls_assert(); - return GNUTLS_E_UNKNOWN_ERROR; - } - _gnutls_set_current_version( state, ver); + if (num > 0) + _gnutls_set_current_version( state, state->gnutls_internals.ProtocolPriority.algorithm_priority[0]); + return 0; } diff --git a/lib/gnutls_record.c b/lib/gnutls_record.c index b34b9cb805..3f846f2a08 100644 --- a/lib/gnutls_record.c +++ b/lib/gnutls_record.c @@ -387,94 +387,6 @@ int gnutls_PRF( opaque * secret, int secret_size, uint8 * label, int label_size, } -/** - * gnutls_alert_send - This function sends an alert message to the peer - * @state: is a &GNUTLS_STATE structure. - * @level: is the level of the alert - * @desc: is the alert description - * - * This function will send an alert to the peer in order to inform - * him of something important (eg. his Certificate could not be verified). - * If the alert level is Fatal then the peer is expected to close the - * connection, otherwise he may ignore the alert and continue. - * Returns 0 on success. - * - **/ -int gnutls_alert_send( GNUTLS_STATE state, AlertLevel level, AlertDescription desc) -{ - uint8 data[2]; - int ret; - - data[0] = (uint8) level; - data[1] = (uint8) desc; - -#ifdef RECORD_DEBUG - _gnutls_log( "Record: Sending Alert[%d|%d] - %s\n", data[0], data[1], _gnutls_alert2str((int)data[1])); -#endif - - if ( (ret = gnutls_send_int( state, GNUTLS_ALERT, -1, data, 2)) >= 0) - return 0; - else - return ret; -} - -/* Sends the appropriate alert, depending - * on the error message. - */ -/** - * gnutls_alert_send_appropriate - This function sends an alert to the peer depending on the error code - * @state: is a &GNUTLS_STATE structure. - * @err: is an integer - * - * Sends an alert to the peer depending on the error code returned by a gnutls - * function. All alerts sent by this function are fatal, so connection should - * be considered terminated after calling this function. The only exception - * is when err == GNUTLS_E_REHANDSHAKE, then a warning alert is sent to - * the peer indicating the no renegotiation will be performed. - * - * This function may also return GNUTLS_E_AGAIN, or GNUTLS_E_INTERRUPTED. - * - * If the return value is GNUTLS_E_UNIMPLEMENTED_FEATURE, then no alert has - * been sent to the peer. - * - **/ -int gnutls_alert_send_appropriate( GNUTLS_STATE state, int err) { -int ret = GNUTLS_E_UNIMPLEMENTED_FEATURE; - switch (err) { /* send appropriate alert */ - case GNUTLS_E_MAC_FAILED: - ret = gnutls_alert_send( state, GNUTLS_AL_FATAL, GNUTLS_A_BAD_RECORD_MAC); - break; - case GNUTLS_E_DECRYPTION_FAILED: - ret = gnutls_alert_send( state, GNUTLS_AL_FATAL, GNUTLS_A_DECRYPTION_FAILED); - break; - case GNUTLS_E_DECOMPRESSION_FAILED: - ret = gnutls_alert_send( state, GNUTLS_AL_FATAL, GNUTLS_A_DECOMPRESSION_FAILURE); - break; - case GNUTLS_E_ILLEGAL_PARAMETER: - ret = gnutls_alert_send( state, GNUTLS_AL_FATAL, GNUTLS_A_ILLEGAL_PARAMETER); - break; - case GNUTLS_E_ASN1_PARSING_ERROR: - case GNUTLS_E_NO_CERTIFICATE_FOUND: - ret = gnutls_alert_send( state, GNUTLS_AL_FATAL, GNUTLS_A_BAD_CERTIFICATE); - break; - case GNUTLS_E_UNKNOWN_CIPHER_SUITE: - ret = gnutls_alert_send( state, GNUTLS_AL_FATAL, GNUTLS_A_HANDSHAKE_FAILURE); - break; - case GNUTLS_E_UNEXPECTED_PACKET: - ret = gnutls_alert_send( state, GNUTLS_AL_FATAL, GNUTLS_A_UNEXPECTED_MESSAGE); - break; - case GNUTLS_E_REHANDSHAKE: - ret = gnutls_alert_send( state, GNUTLS_AL_WARNING, GNUTLS_A_NO_RENEGOTIATION); - break; - case GNUTLS_E_UNSUPPORTED_VERSION_PACKET: - ret = gnutls_alert_send( state, GNUTLS_AL_WARNING, GNUTLS_A_PROTOCOL_VERSION); - break; - case GNUTLS_E_UNEXPECTED_PACKET_LENGTH: - ret = gnutls_alert_send( state, GNUTLS_AL_FATAL, GNUTLS_A_RECORD_OVERFLOW); - break; - } - return ret; -} /** * gnutls_bye - This function terminates the current TLS/SSL connection. @@ -1116,19 +1028,6 @@ gnutls_check_version( const char *req_version ) return NULL; } -/** - * gnutls_alert_get_last - Returns the last alert number received. - * @state: is a &GNUTLS_STATE structure. - * - * Returns the last alert number received. This function - * should be called if GNUTLS_E_WARNING_ALERT_RECEIVED or - * GNUTLS_E_FATAL_ALERT_RECEIVED has been returned by a gnutls function. - * The peer may send alerts if he thinks some things were not - * right. Check gnutls.h for the available alert descriptions. - **/ -AlertDescription gnutls_alert_get_last( GNUTLS_STATE state) { - return state->gnutls_internals.last_alert; -} /** * gnutls_write - sends to the peer the specified data diff --git a/lib/gnutls_record.h b/lib/gnutls_record.h index 0bbfd20da2..d602267ebe 100644 --- a/lib/gnutls_record.h +++ b/lib/gnutls_record.h @@ -1,4 +1,3 @@ -AlertDescription gnutls_alert_get_last( GNUTLS_STATE state); KXAlgorithm gnutls_kx_get_algo( GNUTLS_STATE state); ssize_t gnutls_send_int( GNUTLS_STATE state, ContentType type, HandshakeType htype, const void* data, size_t sizeofdata); ssize_t gnutls_recv_int( GNUTLS_STATE state, ContentType type, HandshakeType, char* data, size_t sizeofdata);