diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-04-18 18:41:30 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2002-04-18 18:41:30 +0000 |
commit | 673ea698ecd37c1b8b0482875dda0ce276b0c052 (patch) | |
tree | 16e4dc5423bc5e7bf324d1e8507f61317a975146 | |
parent | 2e80888dba17d19b4f10e7dca64c4470a70e1618 (diff) | |
download | gnutls-673ea698ecd37c1b8b0482875dda0ce276b0c052.tar.gz |
Added function to report if a session is a resumed one. See gnutls_session_resumed().
-rw-r--r-- | doc/TODO | 2 | ||||
-rw-r--r-- | lib/gnutls.h.in.in | 7 | ||||
-rw-r--r-- | lib/gnutls_int.h | 2 | ||||
-rw-r--r-- | lib/gnutls_privkey.c | 1 | ||||
-rw-r--r-- | lib/gnutls_state.c | 24 | ||||
-rw-r--r-- | src/cli.c | 2 | ||||
-rw-r--r-- | src/serv.c | 2 |
7 files changed, 36 insertions, 4 deletions
@@ -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 <gnutls_gcry.h> #include <gnutls_global.h> +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; +} @@ -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); |