From 5286cb1a467bb489d00819060c045ca6216472cb Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Thu, 26 Nov 2020 00:27:50 -0600 Subject: [PATCH] optimize domain check in wolfcrypt/src/integer.c and wolfcrypt/src/tfm.c. --- wolfcrypt/src/integer.c | 8 ++++---- wolfcrypt/src/tfm.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) 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) {