From: Wenkai Lin linwenkai6@hisilicon.com
When key bytes is 0, it should not clean session key, CPU usage is occupied by wd_memset_zero now, which will causing performance deterioration.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com --- wd_aead.c | 4 ++-- wd_cipher.c | 2 +- wd_digest.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/wd_aead.c b/wd_aead.c index ed7b987..e5e1b19 100644 --- a/wd_aead.c +++ b/wd_aead.c @@ -342,8 +342,8 @@ void wd_aead_free_sess(handle_t h_sess) return; }
- wd_memset_zero(sess->ckey, MAX_CIPHER_KEY_SIZE); - wd_memset_zero(sess->akey, MAX_HMAC_KEY_SIZE); + wd_memset_zero(sess->ckey, sess->ckey_bytes); + wd_memset_zero(sess->akey, sess->akey_bytes);
if (sess->sched_key) free(sess->sched_key); diff --git a/wd_cipher.c b/wd_cipher.c index 6f57e17..2eaa77b 100644 --- a/wd_cipher.c +++ b/wd_cipher.c @@ -284,7 +284,7 @@ void wd_cipher_free_sess(handle_t h_sess) return; }
- wd_memset_zero(sess->key, MAX_CIPHER_KEY_SIZE); + wd_memset_zero(sess->key, sess->key_bytes);
if (sess->sched_key) free(sess->sched_key); diff --git a/wd_digest.c b/wd_digest.c index c8ccc8d..0847fe3 100644 --- a/wd_digest.c +++ b/wd_digest.c @@ -211,7 +211,7 @@ void wd_digest_free_sess(handle_t h_sess) return; }
- wd_memset_zero(sess->key, MAX_HMAC_KEY_SIZE); + wd_memset_zero(sess->key, sess->key_bytes); if (sess->sched_key) free(sess->sched_key); free(sess);