diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-09-15 08:30:52 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-11-14 15:00:32 +0100 |
commit | 08ca6e11df6104579ffce2d9325d4bc720ce7b75 (patch) | |
tree | c54aee8fa420acbe441a73d3b46162d9c37a7acf | |
parent | a83d0d54017c6eec1ece1c3b5164e59b346ef2e9 (diff) | |
download | gnutls-08ca6e11df6104579ffce2d9325d4bc720ce7b75.tar.gz |
constate: added _gnutls_epoch_dup
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r-- | lib/constate.c | 31 | ||||
-rw-r--r-- | lib/constate.h | 2 |
2 files changed, 31 insertions, 2 deletions
diff --git a/lib/constate.c b/lib/constate.c index abfff7718e..63c44fa229 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; @@ -514,8 +543,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); |