]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
constate: added _gnutls_epoch_dup
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Fri, 15 Sep 2017 06:30:52 +0000 (08:30 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Mon, 19 Feb 2018 14:29:34 +0000 (15:29 +0100)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
lib/constate.c
lib/constate.h

index b5dd46be29f240cac640c2aed534134e5aa8a244..8582fed879df629e039a2b6f7d3669faa3dbb791 100644 (file)
@@ -366,6 +366,35 @@ _gnutls_set_cipher_suite2(gnutls_session_t session,
        return 0;
 }
 
+/* Sets the next epoch to be a clone of the current one.
+ */
+int _gnutls_epoch_dup(gnutls_session_t session)
+{
+       record_parameters_st *prev;
+       record_parameters_st *next;
+       int ret;
+
+       ret = _gnutls_epoch_get(session, EPOCH_READ_CURRENT, &prev);
+       if (ret < 0)
+               return gnutls_assert_val(ret);
+
+       ret = _gnutls_epoch_get(session, EPOCH_NEXT, &next);
+       if (ret < 0) {
+               ret = _gnutls_epoch_new(session, 0, &next);
+               if (ret < 0)
+                       return gnutls_assert_val(ret);
+       }
+
+       if (next->initialized
+           || next->cipher != NULL || next->mac != NULL)
+               return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
+
+       next->cipher = prev->cipher;
+       next->mac = prev->mac;
+
+       return 0;
+}
+
 int _gnutls_epoch_set_keys(gnutls_session_t session, uint16_t epoch)
 {
        int hash_size;
@@ -515,8 +544,6 @@ int _gnutls_read_connection_state_init(gnutls_session_t session)
        return 0;
 }
 
-
-
 /* Initializes the write connection session
  * (write encrypted data)
  */
index e7cf0a0a23f197a9e9c2e754614c5ed43f38d109..18c8cfe1a4057440f960fa1254284eca25c69241 100644 (file)
@@ -35,6 +35,8 @@ int _gnutls_write_connection_state_init(gnutls_session_t session);
 #define _gnutls_epoch_bump(session) \
        (session)->security_parameters.epoch_next++
 
+int _gnutls_epoch_dup(gnutls_session_t session);
+
 int _gnutls_epoch_get(gnutls_session_t session, unsigned int epoch_rel,
                      record_parameters_st ** params_out);
 int _gnutls_epoch_new(gnutls_session_t session, unsigned null_epoch, record_parameters_st **newp);