Compare commits

...

3 Commits

Author SHA1 Message Date
Nicola Tuveri b9659fb76f
Merge b35a39f53d into ac87f6b3a3 2025-07-16 06:41:35 +01:00
Nicola Tuveri b35a39f53d fixup! Revert "Revert BN_copy() flag copy semantics change"
[extended tests]
2019-02-21 22:25:48 +02:00
Nicola Tuveri 5bf33e9cd7 Revert "Revert BN_copy() flag copy semantics change"
PR#5080 reverted the `BN_FLG_CONSTTIME` inheritance on `BN_copy()` due
to "unintended consequences". These were most likely due to leakage of
the flag on `BN_CTX_get()` depending on reusage patterns of frames in
`BN_CTX`.

This leakage is now fixed, so `BN_copy()` can now do the "proper thing"
and propagate the `BN_FLG_CONSTTIME` flag.

This reverts commit 7d461736f7.
2019-02-21 22:25:48 +02:00
2 changed files with 1 additions and 3 deletions

View File

@ -349,7 +349,7 @@ BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
a->neg = b->neg;
a->top = b->top;
a->flags |= b->flags & BN_FLG_FIXED_TOP;
a->flags |= b->flags & (BN_FLG_FIXED_TOP | BN_FLG_CONSTTIME);
bn_check_top(a);
return a;
}

View File

@ -272,8 +272,6 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
R = &(mont->RR); /* grab RR as a temp */
if (!BN_copy(&(mont->N), mod))
goto err; /* Set N */
if (BN_get_flags(mod, BN_FLG_CONSTTIME) != 0)
BN_set_flags(&(mont->N), BN_FLG_CONSTTIME);
mont->N.neg = 0;
#ifdef MONT_WORD