From: Nikos Mavrogiannopoulos Date: Fri, 15 Sep 2017 06:30:52 +0000 (+0200) Subject: constate: added _gnutls_epoch_dup X-Git-Tag: gnutls_3_6_3~388 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=36bab3d3c0e45110ba338eee81d51e4a88aa470f;p=thirdparty%2Fgnutls.git constate: added _gnutls_epoch_dup Signed-off-by: Nikos Mavrogiannopoulos --- diff --git a/lib/constate.c b/lib/constate.c index b5dd46be29..8582fed879 100644 --- a/lib/constate.c +++ b/lib/constate.c @@ -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) */ diff --git a/lib/constate.h b/lib/constate.h index e7cf0a0a23..18c8cfe1a4 100644 --- a/lib/constate.h +++ b/lib/constate.h @@ -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);