From 5eca844e01fed3ee0cc5778bf11549543c718ce2 Mon Sep 17 00:00:00 2001 From: David Garske Date: Mon, 4 Jun 2018 11:05:14 -0700 Subject: [PATCH] Fix for possible leak with normal math and verify fail for R and S in ECC verify. --- wolfcrypt/src/ecc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 7ecaaeff6..ee271da8f 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -4353,6 +4353,13 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash, key->state = ECC_STATE_VERIFY_DO; err = wc_ecc_verify_hash_ex(r, s, hash, hashlen, res, key); + + #ifndef WOLFSSL_ASYNC_CRYPT + /* done with R/S */ + mp_clear(r); + mp_clear(s); + #endif + if (err < 0) { break; } @@ -4361,10 +4368,6 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash, case ECC_STATE_VERIFY_RES: key->state = ECC_STATE_VERIFY_RES; err = 0; - - /* done with R/S */ - mp_clear(r); - mp_clear(s); break; default: