From 72a8a1069a6a1f94fb77c8ae4a05cd09b45ac339 Mon Sep 17 00:00:00 2001 From: David Garske Date: Tue, 2 Feb 2021 14:16:21 -0800 Subject: [PATCH] Fix to only set missing RNG if needed. Resolves unit test, which already sets the RNG on the private key and the incoming context is not provided (use local). --- wolfcrypt/src/ecc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 01f1edfab..1da358639 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -10576,9 +10576,8 @@ int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg, return BUFFER_E; #ifdef ECC_TIMING_RESISTANT - ret = wc_ecc_set_rng(privKey, ctx->rng); - if (ret != 0) - return ret; + if (ctx->rng != NULL && privKey->rng == NULL) + privKey->rng = ctx->rng; #endif #ifdef WOLFSSL_SMALL_STACK @@ -10775,9 +10774,8 @@ int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg, return BUFFER_E; #ifdef ECC_TIMING_RESISTANT - ret = wc_ecc_set_rng(privKey, ctx->rng); - if (ret != 0) - return ret; + if (ctx->rng != NULL && privKey->rng == NULL) + privKey->rng = ctx->rng; #endif #ifdef WOLFSSL_SMALL_STACK