diff options
author | tb <> | 2023-03-27 08:52:57 +0000 |
---|---|---|
committer | tb <> | 2023-03-27 08:52:57 +0000 |
commit | ee9510ce8537555ad5dbe5fd9f5bfd77e70b451a (patch) | |
tree | de5b5682ee656798f6e24ff220ceb0fb061050eb /src | |
parent | be90622cbcd6520254b911da4ffbca102d59abb6 (diff) | |
download | openbsd-ee9510ce8537555ad5dbe5fd9f5bfd77e70b451a.tar.gz openbsd-ee9510ce8537555ad5dbe5fd9f5bfd77e70b451a.tar.bz2 openbsd-ee9510ce8537555ad5dbe5fd9f5bfd77e70b451a.zip |
Switch regress to using bn_copy()
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/bn/bn_mod_exp.c | 6 | ||||
-rw-r--r-- | src/regress/lib/libcrypto/bn/bn_test.c | 20 |
2 files changed, 13 insertions, 13 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_mod_exp.c b/src/regress/lib/libcrypto/bn/bn_mod_exp.c index 10647ad3dd..c880e78dd3 100644 --- a/src/regress/lib/libcrypto/bn/bn_mod_exp.c +++ b/src/regress/lib/libcrypto/bn/bn_mod_exp.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_mod_exp.c,v 1.25 2023/03/26 22:09:08 tb Exp $ */ | 1 | /* $OpenBSD: bn_mod_exp.c,v 1.26 2023/03/27 08:52:57 tb Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2022,2023 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2022,2023 Theo Buehler <tb@openbsd.org> |
@@ -261,7 +261,7 @@ generate_test_triple(int reduce, BIGNUM *a, BIGNUM *p, BIGNUM *m, BN_CTX *ctx) | |||
261 | if ((mmodified = BN_CTX_get(ctx)) == NULL) | 261 | if ((mmodified = BN_CTX_get(ctx)) == NULL) |
262 | goto err; | 262 | goto err; |
263 | 263 | ||
264 | if (BN_copy(mmodified, m) == NULL) | 264 | if (!bn_copy(mmodified, m)) |
265 | goto err; | 265 | goto err; |
266 | 266 | ||
267 | multiple = arc4random_uniform(1023) + 2; | 267 | multiple = arc4random_uniform(1023) + 2; |
@@ -319,7 +319,7 @@ generate_test_quintuple(int reduce, BIGNUM *a1, BIGNUM *p1, | |||
319 | if ((mmodified = BN_CTX_get(ctx)) == NULL) | 319 | if ((mmodified = BN_CTX_get(ctx)) == NULL) |
320 | goto err; | 320 | goto err; |
321 | 321 | ||
322 | if (BN_copy(mmodified, m) == NULL) | 322 | if (!bn_copy(mmodified, m)) |
323 | goto err; | 323 | goto err; |
324 | 324 | ||
325 | multiple = arc4random_uniform(16) + 2; | 325 | multiple = arc4random_uniform(16) + 2; |
diff --git a/src/regress/lib/libcrypto/bn/bn_test.c b/src/regress/lib/libcrypto/bn/bn_test.c index ed61f86f2e..33050862ce 100644 --- a/src/regress/lib/libcrypto/bn/bn_test.c +++ b/src/regress/lib/libcrypto/bn/bn_test.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_test.c,v 1.2 2022/12/06 18:23:29 tb Exp $ */ | 1 | /* $OpenBSD: bn_test.c,v 1.3 2023/03/27 08:52:57 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -425,7 +425,7 @@ test_sub(BIO *bp) | |||
425 | for (i = 0; i < num0 + num1; i++) { | 425 | for (i = 0; i < num0 + num1; i++) { |
426 | if (i < num1) { | 426 | if (i < num1) { |
427 | CHECK_GOTO(BN_bntest_rand(a, 512, 0, 0)); | 427 | CHECK_GOTO(BN_bntest_rand(a, 512, 0, 0)); |
428 | CHECK_GOTO(BN_copy(b, a)); | 428 | CHECK_GOTO(bn_copy(b, a)); |
429 | if (BN_set_bit(a, i) == 0) { | 429 | if (BN_set_bit(a, i) == 0) { |
430 | rc = 0; | 430 | rc = 0; |
431 | break; | 431 | break; |
@@ -491,7 +491,7 @@ test_div(BIO *bp, BN_CTX *ctx) | |||
491 | for (i = 0; i < num0 + num1; i++) { | 491 | for (i = 0; i < num0 + num1; i++) { |
492 | if (i < num1) { | 492 | if (i < num1) { |
493 | CHECK_GOTO(BN_bntest_rand(a, 400, 0, 0)); | 493 | CHECK_GOTO(BN_bntest_rand(a, 400, 0, 0)); |
494 | CHECK_GOTO(BN_copy(b, a)); | 494 | CHECK_GOTO(bn_copy(b, a)); |
495 | CHECK_GOTO(BN_lshift(a, a, i)); | 495 | CHECK_GOTO(BN_lshift(a, a, i)); |
496 | CHECK_GOTO(BN_add_word(a, i)); | 496 | CHECK_GOTO(BN_add_word(a, i)); |
497 | } else | 497 | } else |
@@ -576,7 +576,7 @@ test_div_word(BIO *bp) | |||
576 | s = BN_get_word(b); | 576 | s = BN_get_word(b); |
577 | } while (!s); | 577 | } while (!s); |
578 | 578 | ||
579 | if (!BN_copy(b, a)) { | 579 | if (!bn_copy(b, a)) { |
580 | rc = 0; | 580 | rc = 0; |
581 | break; | 581 | break; |
582 | } | 582 | } |
@@ -655,7 +655,7 @@ test_div_recp(BIO *bp, BN_CTX *ctx) | |||
655 | for (i = 0; i < num0 + num1; i++) { | 655 | for (i = 0; i < num0 + num1; i++) { |
656 | if (i < num1) { | 656 | if (i < num1) { |
657 | CHECK_GOTO(BN_bntest_rand(a, 400, 0, 0)); | 657 | CHECK_GOTO(BN_bntest_rand(a, 400, 0, 0)); |
658 | CHECK_GOTO(BN_copy(b, a)); | 658 | CHECK_GOTO(bn_copy(b, a)); |
659 | CHECK_GOTO(BN_lshift(a, a, i)); | 659 | CHECK_GOTO(BN_lshift(a, a, i)); |
660 | CHECK_GOTO(BN_add_word(a, i)); | 660 | CHECK_GOTO(BN_add_word(a, i)); |
661 | } else | 661 | } else |
@@ -1561,7 +1561,7 @@ test_gf2m_add(BIO *bp) | |||
1561 | 1561 | ||
1562 | for (i = 0; i < num0; i++) { | 1562 | for (i = 0; i < num0; i++) { |
1563 | CHECK_GOTO(BN_rand(a, 512, 0, 0)); | 1563 | CHECK_GOTO(BN_rand(a, 512, 0, 0)); |
1564 | CHECK_GOTO(BN_copy(b, BN_value_one())); | 1564 | CHECK_GOTO(bn_copy(b, BN_value_one())); |
1565 | BN_set_negative(a, rand_neg()); | 1565 | BN_set_negative(a, rand_neg()); |
1566 | BN_set_negative(b, rand_neg()); | 1566 | BN_set_negative(b, rand_neg()); |
1567 | CHECK_GOTO(BN_GF2m_add(c, a, b)); | 1567 | CHECK_GOTO(BN_GF2m_add(c, a, b)); |
@@ -1763,7 +1763,7 @@ test_gf2m_mod_sqr(BIO *bp, BN_CTX *ctx) | |||
1763 | CHECK_GOTO(BN_bntest_rand(a, 1024, 0, 0)); | 1763 | CHECK_GOTO(BN_bntest_rand(a, 1024, 0, 0)); |
1764 | for (j = 0; j < 2; j++) { | 1764 | for (j = 0; j < 2; j++) { |
1765 | CHECK_GOTO(BN_GF2m_mod_sqr(c, a, b[j], ctx)); | 1765 | CHECK_GOTO(BN_GF2m_mod_sqr(c, a, b[j], ctx)); |
1766 | CHECK_GOTO(BN_copy(d, a)); | 1766 | CHECK_GOTO(bn_copy(d, a)); |
1767 | CHECK_GOTO(BN_GF2m_mod_mul(d, a, d, b[j], ctx)); | 1767 | CHECK_GOTO(BN_GF2m_mod_mul(d, a, d, b[j], ctx)); |
1768 | #if 0 /* make test uses ouput in bc but bc can't handle GF(2^m) arithmetic */ | 1768 | #if 0 /* make test uses ouput in bc but bc can't handle GF(2^m) arithmetic */ |
1769 | if (bp != NULL) { | 1769 | if (bp != NULL) { |
@@ -2199,7 +2199,7 @@ test_kron(BIO *bp, BN_CTX *ctx) | |||
2199 | BN_set_negative(a, rand_neg()); | 2199 | BN_set_negative(a, rand_neg()); |
2200 | 2200 | ||
2201 | /* t := (|b|-1)/2 (note that b is odd) */ | 2201 | /* t := (|b|-1)/2 (note that b is odd) */ |
2202 | if (!BN_copy(t, b)) | 2202 | if (!bn_copy(t, b)) |
2203 | goto err; | 2203 | goto err; |
2204 | BN_set_negative(t, 0); | 2204 | BN_set_negative(t, 0); |
2205 | if (!BN_sub_word(t, 1)) | 2205 | if (!BN_sub_word(t, 1)) |
@@ -2449,7 +2449,7 @@ test_lshift1(BIO *bp) | |||
2449 | break; | 2449 | break; |
2450 | } | 2450 | } |
2451 | 2451 | ||
2452 | CHECK_GOTO(BN_copy(a, b)); | 2452 | CHECK_GOTO(bn_copy(a, b)); |
2453 | } | 2453 | } |
2454 | err: | 2454 | err: |
2455 | BN_free(a); | 2455 | BN_free(a); |
@@ -2543,7 +2543,7 @@ test_rshift1(BIO *bp) | |||
2543 | rc = 0; | 2543 | rc = 0; |
2544 | break; | 2544 | break; |
2545 | } | 2545 | } |
2546 | CHECK_GOTO(BN_copy(a, b)); | 2546 | CHECK_GOTO(bn_copy(a, b)); |
2547 | } | 2547 | } |
2548 | err: | 2548 | err: |
2549 | BN_free(a); | 2549 | BN_free(a); |