From: Nikos Mavrogiannopoulos Date: Thu, 18 Apr 2002 18:41:30 +0000 (+0000) Subject: Added function to report if a session is a resumed one. See gnutls_session_resumed(). X-Git-Tag: gnutls_0_4_2~46 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=673ea698ecd37c1b8b0482875dda0ce276b0c052;p=thirdparty%2Fgnutls.git Added function to report if a session is a resumed one. See gnutls_session_resumed(). --- diff --git a/doc/TODO b/doc/TODO index 09c9ce29af..08f326830d 100644 --- a/doc/TODO +++ b/doc/TODO @@ -5,8 +5,8 @@ in order to avoid having people working on the same thing. Current list: + Audit the code * Add function(s) to get the DHE/A parameters -* Add function to quickly report if a session is a resumed one * Add function(s) to extract the certificate key's parameters +* Optimize functions which now return malloc'd data * Minimize footprint. - Add Kerberos support diff --git a/lib/gnutls.h.in.in b/lib/gnutls.h.in.in index ff9eb1cabc..282afec7fb 100644 --- a/lib/gnutls.h.in.in +++ b/lib/gnutls.h.in.in @@ -160,12 +160,17 @@ GNUTLS_Version gnutls_protocol_get_version(GNUTLS_STATE state); const char *gnutls_protocol_get_name(GNUTLS_Version version); -/* get/set session */ +/* get/set session + */ int gnutls_session_set_data( GNUTLS_STATE state, void* session, int session_size); int gnutls_session_get_data( GNUTLS_STATE state, void* session, int *session_size); /* returns the session ID */ int gnutls_session_get_id( GNUTLS_STATE state, void* session, int *session_size); +/* checks if this session is a resumed one + */ +int gnutls_session_resumed(GNUTLS_STATE state); + typedef int (*GNUTLS_DB_STORE_FUNC)(void*, gnutls_datum key, gnutls_datum data); typedef int (*GNUTLS_DB_REMOVE_FUNC)(void*, gnutls_datum key); typedef gnutls_datum (*GNUTLS_DB_RETR_FUNC)(void*, gnutls_datum key); diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h index cbe5221f5c..18d923b83f 100644 --- a/lib/gnutls_int.h +++ b/lib/gnutls_int.h @@ -428,7 +428,7 @@ typedef struct { CertType_Priority cert_type_priority; /* resumed session */ - ResumableSession resumed; /* TRUE or FALSE - if we are resuming a session */ + ResumableSession resumed; /* RESUME_TRUE or FALSE - if we are resuming a session */ SecurityParameters resumed_security_parameters; /* sockets internals */ diff --git a/lib/gnutls_privkey.c b/lib/gnutls_privkey.c index e1b0aaa65c..2a115a59b7 100644 --- a/lib/gnutls_privkey.c +++ b/lib/gnutls_privkey.c @@ -30,6 +30,7 @@ #include #include +void _gcry_mpi_invm( MPI x, MPI a, MPI n ); /* Converts an RSA PKCS#1 key to * an internal structure (gnutls_private_key) diff --git a/lib/gnutls_state.c b/lib/gnutls_state.c index fa5136888b..b71a637f7a 100644 --- a/lib/gnutls_state.c +++ b/lib/gnutls_state.c @@ -128,7 +128,6 @@ void _gnutls_handshake_internal_state_clear( GNUTLS_STATE state) { state->gnutls_internals.adv_version_minor = 0; state->gnutls_internals.adv_version_minor = 0; - state->gnutls_internals.resumed = RESUME_FALSE; state->gnutls_internals.resumable = RESUME_TRUE; } @@ -597,3 +596,26 @@ int _gnutls_PRF( opaque * secret, int secret_size, uint8 * label, int label_size return 0; /* ok */ } + +/** + * gnutls_session_resumed - Used to check whether this session is a resumed one + * @state: is a &GNUTLS_STATE structure. + * + * This function will return 0 if this session is a resumed one, + * or a negative number if this is a new session. + * + **/ +int gnutls_session_resumed(GNUTLS_STATE state) +{ + if (state->security_parameters.entity==GNUTLS_CLIENT) { + if (memcmp( state->security_parameters.session_id, + state->gnutls_internals.resumed_security_parameters.session_id, + state->security_parameters.session_id_size)==0) + return 0; + } else { + if (state->gnutls_internals.resumed==RESUME_TRUE) + return 0; + } + + return GNUTLS_E_UNKNOWN_ERROR; +} diff --git a/src/cli.c b/src/cli.c index 7c2dd4aa01..325a7c3035 100644 --- a/src/cli.c +++ b/src/cli.c @@ -306,6 +306,8 @@ int main(int argc, char **argv) return 1; } else { printf("- Handshake was completed\n"); + if (gnutls_session_resumed( state)==0) + printf("*** This is a resumed session\n"); } if (i == 1) { /* resume */ diff --git a/src/serv.c b/src/serv.c index 62358bc92c..a2fb799bde 100644 --- a/src/serv.c +++ b/src/serv.c @@ -451,6 +451,8 @@ int main(int argc, char **argv) continue; } printf("- Handshake was completed\n"); + if ( gnutls_session_resumed( state)==0) + printf("*** This is a resumed session\n"); print_info(state);