]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Added function to report if a session is a resumed one. See gnutls_session_resumed().
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 18 Apr 2002 18:41:30 +0000 (18:41 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 18 Apr 2002 18:41:30 +0000 (18:41 +0000)
doc/TODO
lib/gnutls.h.in.in
lib/gnutls_int.h
lib/gnutls_privkey.c
lib/gnutls_state.c
src/cli.c
src/serv.c

index 09c9ce29af568bee4b9345558900c1a347d6b443..08f326830d79bbde4b111f8f6de3e0844cb807d5 100644 (file)
--- 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
 
index ff9eb1cabc0e32d21f9f172cd455dbe90ff42fc8..282afec7fb4e57c4107994f6759401922ae0ee14 100644 (file)
@@ -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);
index cbe5221f5c9120f297fbe5b9f4e0cb5aef42a4f3..18d923b83fbea5d4eae801ef8291927b8dab7fd9 100644 (file)
@@ -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 */
index e1b0aaa65cd42b3228f139e79db4c48b6c17b4b9..2a115a59b7bd756fec20e907d8f76b32bfbd24df 100644 (file)
@@ -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)
index fa5136888bf324ffdc84f92f817306ed7c7c7aea..b71a637f7adf1f1e10a6214fb2f316b89e86d05d 100644 (file)
@@ -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;
+}
index 7c2dd4aa01549ea452154f4ed7cd51a5f4694d0c..325a7c3035eae83782163fa01e889ac691ce3f70 100644 (file)
--- 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 */
index 62358bc92ce5776d5e260fbafe86cb02fc3ca717..a2fb799bde2f2294a016d22c0a00b8965d89b724 100644 (file)
@@ -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);