]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Added gnutls_db_check_entry_time().
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 31 Jan 2013 22:28:36 +0000 (23:28 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 31 Jan 2013 22:28:36 +0000 (23:28 +0100)
lib/gnutls_db.c
lib/gnutls_session_pack.c
lib/includes/gnutls/gnutls.h.in
lib/libgnutls.map

index 3881800561d96678013c6fc9dbf61b4e33989ca5..27f8a700a20fa4a94538a65d6df4cc9a4e1149b7 100644 (file)
@@ -148,6 +148,27 @@ gnutls_db_check_entry (gnutls_session_t session, gnutls_datum_t session_entry)
   return 0;
 }
 
+/**
+ * gnutls_db_check_entry_time:
+ * @entry: is a pointer to a #gnutls_datum_t structure.
+ * @t: is the time of the session handshake
+ *
+ * This function returns the time that this entry was active.
+ * It can be used for database entry expiration.
+ *
+ **/
+time_t
+gnutls_db_check_entry_time (gnutls_datum_t *entry)
+{
+uint32_t t;
+
+  if (entry->size < 4)
+    return gnutls_assert_val(0);
+  
+  memcpy(&t, entry->data, 4);
+  return t;
+}
+
 /* Checks if both db_store and db_retrieve functions have
  * been set up.
  */
index 2b73c0bbcddb75611960cd231b36293a088ef63d..4780802394af347b984dcac580cf759192daa6c7 100644 (file)
@@ -93,6 +93,9 @@ _gnutls_session_pack (gnutls_session_t session,
 
   _gnutls_buffer_init (&sb);
 
+  /* first is the timestamp */
+  BUFFER_APPEND_NUM(&sb, session->security_parameters.timestamp);
+
   id = gnutls_auth_get_type (session);
   BUFFER_APPEND (&sb, &id, 1);
 
@@ -193,6 +196,9 @@ _gnutls_session_unpack (gnutls_session_t session,
       return ret;
     }
 
+  /* the timestamp is first */
+  BUFFER_POP_NUM (&sb, session->security_parameters.timestamp);
+
   if (_gnutls_get_auth_info (session) != NULL)
     {
       _gnutls_free_auth_info (session);
@@ -725,7 +731,6 @@ error:
  *      1 byte the session ID size
  *      x bytes the session ID (32 bytes max)
  *
- *      4 bytes a timestamp
  *      4 bytes the new record padding flag
  *      4 bytes the ECC curve
  *            -------------------
@@ -783,7 +788,6 @@ pack_security_parameters (gnutls_session_t session, gnutls_buffer_st * ps)
 
   BUFFER_APPEND_NUM (ps, session->security_parameters.max_record_send_size);
   BUFFER_APPEND_NUM (ps, session->security_parameters.max_record_recv_size);
-  BUFFER_APPEND_NUM (ps, session->security_parameters.timestamp);
   BUFFER_APPEND_NUM (ps, session->security_parameters.new_record_padding);
   BUFFER_APPEND_NUM (ps, session->security_parameters.ecc_curve);
 
@@ -840,8 +844,6 @@ unpack_security_parameters (gnutls_session_t session, gnutls_buffer_st * ps)
   BUFFER_POP_NUM (ps,
                   session->internals.
                   resumed_security_parameters.max_record_recv_size);
-  BUFFER_POP_NUM (ps,
-                  session->internals.resumed_security_parameters.timestamp);
 
   BUFFER_POP_NUM (ps,
                   session->internals.resumed_security_parameters.new_record_padding);
index e9670401d6edd2963769a2baa97dad3d4b01c38d..710d77ce251be2ec173c20bf05be79b28eb57b2d 100644 (file)
@@ -1131,6 +1131,7 @@ gnutls_ecc_curve_t gnutls_ecc_curve_get(gnutls_session_t session);
   void *gnutls_db_get_ptr (gnutls_session_t session);
   int gnutls_db_check_entry (gnutls_session_t session,
                              gnutls_datum_t session_entry);
+  time_t gnutls_db_check_entry_time (gnutls_datum_t *entry);
 
   typedef int (*gnutls_handshake_post_client_hello_func) (gnutls_session_t);
   void
index 783fbbe9d9a4cda2ef299b06ed5bdce25176eeea..bbc3ecaa945618b869f342cee7aa907a3d03f6c4 100644 (file)
@@ -885,6 +885,7 @@ GNUTLS_3_1_0 {
        gnutls_record_set_max_empty_records;
        gnutls_range_split;
        gnutls_record_send_range;
+       gnutls_db_check_entry_time;
        xssl_deinit;
        xssl_flush;
        xssl_read;