Eliminate harmless non-constant time operations on secret data.
There were several places where the code was non-constant time for invalid secret inputs. These are harmless under sane use but get in the way of automatic const-time validation. (Nonce overflow in signing is not addressed, nor is s==0 in signing)
This commit is contained in:
@@ -1822,7 +1822,7 @@ void run_field_misc(void) {
|
||||
q = x;
|
||||
secp256k1_fe_cmov(&x, &z, 0);
|
||||
#ifdef VERIFY
|
||||
CHECK(!x.normalized && x.magnitude == z.magnitude);
|
||||
CHECK(x.normalized && x.magnitude == 1);
|
||||
#endif
|
||||
secp256k1_fe_cmov(&x, &x, 1);
|
||||
CHECK(fe_memcmp(&x, &z) != 0);
|
||||
@@ -1845,7 +1845,7 @@ void run_field_misc(void) {
|
||||
secp256k1_fe_normalize_var(&q);
|
||||
secp256k1_fe_cmov(&q, &z, (j&1));
|
||||
#ifdef VERIFY
|
||||
CHECK(!q.normalized && q.magnitude == (j+2));
|
||||
CHECK((q.normalized != (j&1)) && q.magnitude == ((j&1) ? z.magnitude : 1));
|
||||
#endif
|
||||
}
|
||||
secp256k1_fe_normalize_var(&z);
|
||||
|
||||
Reference in New Issue
Block a user