From ce0136e9682b81582f412647faa13ba00ad5bcf6 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Wed, 20 Nov 2019 13:55:57 -0800 Subject: [PATCH] Maintenance: Integers In TFM and Integer, rshb() shouldn't try to shift a value that is 0. This leads to using a negative offset to a pointer, but isn't used. --- wolfcrypt/src/integer.c | 2 ++ wolfcrypt/src/tfm.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index e94c36e11..7c1536eda 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -572,6 +572,8 @@ void mp_rshb (mp_int *c, int x) mp_digit r, rr; mp_digit D = x; + if (mp_iszero(c)) return; + /* mask */ mask = (((mp_digit)1) << D) - 1; diff --git a/wolfcrypt/src/tfm.c b/wolfcrypt/src/tfm.c index f0fb014ac..e6713f9ca 100644 --- a/wolfcrypt/src/tfm.c +++ b/wolfcrypt/src/tfm.c @@ -3174,6 +3174,8 @@ void fp_rshb(fp_int *c, int x) fp_digit r, rr; fp_digit D = x; + if (fp_iszero(c)) return; + /* mask */ mask = (((fp_digit)1) << D) - 1;