bugfix in final fips loop

This commit is contained in:
czurnieden 2019-03-23 18:36:47 +01:00 committed by Steffen Jaeckel
parent b587c954a5
commit 9771308d11

View File

@ -335,7 +335,11 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
* smaller than or equal to "a"
*/
len = mp_count_bits(&b);
if (len > size_a) {
if (len >= size_a) {
/* Witness and test subject must not be equal */
if( (len == size_a) && (mp_cmp(a, &b) == MP_EQ) ) {
len++;
}
len = len - size_a;
if ((err = mp_div_2d(&b, len, &b, NULL)) != MP_OKAY) {
goto LBL_B;