mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
rshb: handle cases of shift amount being multiple of DIGIT_BIT
tfm.c and integer.c fixed
This commit is contained in:
@ -564,12 +564,16 @@ void mp_rshb (mp_int *c, int x)
|
||||
|
||||
/* shifting by a negative number not supported */
|
||||
if (x < 0) return;
|
||||
/* shifting by zero changes nothing */
|
||||
if (x == 0) return;
|
||||
|
||||
/* shift digits first if needed */
|
||||
if (x >= DIGIT_BIT) {
|
||||
mp_rshd(c, x / DIGIT_BIT);
|
||||
/* recalculate number of bits to shift */
|
||||
D = x % DIGIT_BIT;
|
||||
/* check if any more shifting needed */
|
||||
if (D == 0) return;
|
||||
}
|
||||
|
||||
/* zero shifted is always zero */
|
||||
|
@ -3871,12 +3871,17 @@ void fp_rshb(fp_int *c, int x)
|
||||
|
||||
/* shifting by a negative number not supported */
|
||||
if (x < 0) return;
|
||||
/* shifting by zero changes nothing */
|
||||
if (x == 0) return;
|
||||
|
||||
/* shift digits first if needed */
|
||||
if (x >= DIGIT_BIT) {
|
||||
fp_rshd(c, x / DIGIT_BIT);
|
||||
/* recalculate number of bits to shift */
|
||||
D = x % DIGIT_BIT;
|
||||
/* check if any more shifting needed */
|
||||
if (D == 0) return;
|
||||
|
||||
}
|
||||
|
||||
/* zero shifted is always zero */
|
||||
|
Reference in New Issue
Block a user