diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2017-11-07 16:52:21 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2018-02-19 15:29:36 +0100 |
commit | 62ea232f180b980a0d4b6462c468706db6cc4700 (patch) | |
tree | e2b8d1851061c6b5726c399edb43c5a717d891ef /lib/state.c | |
parent | e8d4118bcc76586c5fe86382189305f1291269eb (diff) | |
download | gnutls-62ea232f180b980a0d4b6462c468706db6cc4700.tar.gz |
record state: avoid memory allocations for stored keys
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'lib/state.c')
-rw-r--r-- | lib/state.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/state.c b/lib/state.c index 2b2fcb3b14..b4e539e45b 100644 --- a/lib/state.c +++ b/lib/state.c @@ -1204,12 +1204,21 @@ gnutls_record_get_state(gnutls_session_t session, else record_state = &record_params->write; - if (mac_key) - memcpy(mac_key, &record_state->mac_secret, sizeof(gnutls_datum_t)); - if (IV) - memcpy(IV, &record_state->IV, sizeof(gnutls_datum_t)); - if (cipher_key) - memcpy(cipher_key, &record_state->key, sizeof(gnutls_datum_t)); + if (mac_key) { + mac_key->data = record_state->mac_key; + mac_key->size = record_state->mac_key_size; + } + + if (IV) { + IV->data = record_state->iv; + IV->size = record_state->iv_size; + } + + if (cipher_key) { + cipher_key->data = record_state->key; + cipher_key->size = record_state->key_size; + } + if (seq_number) memcpy(seq_number, UINT64DATA(record_state->sequence_number), 8); return 0; |