diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index fa13dfda5..12f4d7c1f 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -562,10 +562,10 @@ void mp_rshb (mp_int *c, int x) mp_digit r, rr; mp_digit D = x; - /* shifting by a negative number not supported */ - if (x < 0) return; - /* shifting by zero changes nothing */ - if (x == 0) return; + /* shifting by a negative number not supported, and shifting by + * zero changes nothing. + */ + if (x <= 0) return; /* shift digits first if needed */ if (x >= DIGIT_BIT) { diff --git a/wolfcrypt/src/tfm.c b/wolfcrypt/src/tfm.c index 56fb5993e..9eedd30d7 100644 --- a/wolfcrypt/src/tfm.c +++ b/wolfcrypt/src/tfm.c @@ -3903,10 +3903,10 @@ void fp_rshb(fp_int *c, int x) fp_digit r, rr; fp_digit D = x; - /* shifting by a negative number not supported */ - if (x < 0) return; - /* shifting by zero changes nothing */ - if (x == 0) return; + /* shifting by a negative number not supported, and shifting by + * zero changes nothing. + */ + if (x <= 0) return; /* shift digits first if needed */ if (x >= DIGIT_BIT) {