From 9783d64f7e67218d835f4e83f9ba6993113ecc82 Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Tue, 6 Jul 2021 02:13:42 +0200 Subject: [PATCH 1/2] Add missing return value check in mp_invmod_slow --- wolfcrypt/src/integer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index d2c33ba36..5c7e50adb 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -1197,7 +1197,9 @@ int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c) goto LBL_ERR; } if (mp_isone(&x)) { - mp_set(c, 1); + if ((res = mp_set(c, 1)) != MP_OKAY) { + goto LBL_ERR; + } res = MP_OKAY; goto LBL_ERR; } From e0f268e5222f2a9309c755cd35c0d6a799a8421c Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Tue, 6 Jul 2021 02:29:31 +0200 Subject: [PATCH 2/2] Simplify mp_invmod_slow fix --- wolfcrypt/src/integer.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index 5c7e50adb..604698afd 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -1197,10 +1197,7 @@ int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c) goto LBL_ERR; } if (mp_isone(&x)) { - if ((res = mp_set(c, 1)) != MP_OKAY) { - goto LBL_ERR; - } - res = MP_OKAY; + res = mp_set(c, 1); goto LBL_ERR; } if ((res = mp_copy (b, &y)) != MP_OKAY) {