diff options
author | Billy Brumley <bbrumley@gmail.com> | 2022-06-10 00:03:23 +0300 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-11-21 10:49:52 +0100 |
commit | d8813ae09a2a29bcd9a9cf2f4ed9485f8801e0e2 (patch) | |
tree | 5c100f90c75c114521312b788be02aa726705d4e /test | |
parent | 03b825f74f429ede35f86f196553460810922746 (diff) |
[crypto/bn] BN_consttime_swap: remove superfluous early exit
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18518)
(cherry picked from commit a644cb7c1c19c78e2ca393c8ca36989e7ca61715)
Diffstat (limited to 'test')
-rw-r--r-- | test/bntest.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/bntest.c b/test/bntest.c index c5894c157b..00b9b8cfd8 100644 --- a/test/bntest.c +++ b/test/bntest.c @@ -168,6 +168,11 @@ static int test_swap(void) || !equalBN("swap", b, c)) goto err; + /* regular swap: same pointer */ + BN_swap(a, a); + if (!equalBN("swap with same pointer", a, d)) + goto err; + /* conditional swap: true */ cond = 1; BN_consttime_swap(cond, a, b, top); @@ -175,6 +180,11 @@ static int test_swap(void) || !equalBN("cswap true", b, d)) goto err; + /* conditional swap: true, same pointer */ + BN_consttime_swap(cond, a, a, top); + if (!equalBN("cswap true", a, c)) + goto err; + /* conditional swap: false */ cond = 0; BN_consttime_swap(cond, a, b, top); @@ -182,6 +192,11 @@ static int test_swap(void) || !equalBN("cswap false", b, d)) goto err; + /* conditional swap: false, same pointer */ + BN_consttime_swap(cond, a, a, top); + if (!equalBN("cswap false", a, c)) + goto err; + /* same tests but checking flag swap */ BN_set_flags(a, BN_FLG_CONSTTIME); |