diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libcrypto/bn/bn_mod_exp_zero.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_mod_exp_zero.c b/src/regress/lib/libcrypto/bn/bn_mod_exp_zero.c index 0e1e21d141..292983e86b 100644 --- a/src/regress/lib/libcrypto/bn/bn_mod_exp_zero.c +++ b/src/regress/lib/libcrypto/bn/bn_mod_exp_zero.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_mod_exp_zero.c,v 1.1 2022/12/02 17:33:38 tb Exp $ */ | 1 | /* $OpenBSD: bn_mod_exp_zero.c,v 1.2 2023/03/15 00:41:04 tb Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> |
| @@ -49,12 +49,12 @@ static const struct mod_exp_zero_test { | |||
| 49 | (sizeof(mod_exp_zero_test_data) / sizeof(mod_exp_zero_test_data[0])) | 49 | (sizeof(mod_exp_zero_test_data) / sizeof(mod_exp_zero_test_data[0])) |
| 50 | 50 | ||
| 51 | static void | 51 | static void |
| 52 | print_failure(const BIGNUM *result, const BIGNUM *a, const char *name) | 52 | print_failure(const BIGNUM *got, const BIGNUM *a, const char *name) |
| 53 | { | 53 | { |
| 54 | fprintf(stderr, "%s test failed for a = ", name); | 54 | fprintf(stderr, "%s test failed for a = ", name); |
| 55 | BN_print_fp(stderr, a); | 55 | BN_print_fp(stderr, a); |
| 56 | fprintf(stderr, "\nwant 0, got "); | 56 | fprintf(stderr, "\nwant 0, got "); |
| 57 | BN_print_fp(stderr, result); | 57 | BN_print_fp(stderr, got); |
| 58 | fprintf(stderr, "\n"); | 58 | fprintf(stderr, "\n"); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| @@ -63,7 +63,7 @@ bn_mod_exp_zero_test(const struct mod_exp_zero_test *test, BN_CTX *ctx, | |||
| 63 | int use_random) | 63 | int use_random) |
| 64 | { | 64 | { |
| 65 | const BIGNUM *one; | 65 | const BIGNUM *one; |
| 66 | BIGNUM *a, *p, *result; | 66 | BIGNUM *a, *p, *got; |
| 67 | int failed = 1; | 67 | int failed = 1; |
| 68 | 68 | ||
| 69 | BN_CTX_start(ctx); | 69 | BN_CTX_start(ctx); |
| @@ -72,7 +72,7 @@ bn_mod_exp_zero_test(const struct mod_exp_zero_test *test, BN_CTX *ctx, | |||
| 72 | errx(1, "BN_CTX_get"); | 72 | errx(1, "BN_CTX_get"); |
| 73 | if ((p = BN_CTX_get(ctx)) == NULL) | 73 | if ((p = BN_CTX_get(ctx)) == NULL) |
| 74 | errx(1, "BN_CTX_get"); | 74 | errx(1, "BN_CTX_get"); |
| 75 | if ((result = BN_CTX_get(ctx)) == NULL) | 75 | if ((got = BN_CTX_get(ctx)) == NULL) |
| 76 | errx(1, "BN_CTX_get"); | 76 | errx(1, "BN_CTX_get"); |
| 77 | 77 | ||
| 78 | one = BN_value_one(); | 78 | one = BN_value_one(); |
| @@ -85,21 +85,21 @@ bn_mod_exp_zero_test(const struct mod_exp_zero_test *test, BN_CTX *ctx, | |||
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | if (test->mod_exp_fn != NULL) { | 87 | if (test->mod_exp_fn != NULL) { |
| 88 | if (!test->mod_exp_fn(result, a, p, one, ctx)) { | 88 | if (!test->mod_exp_fn(got, a, p, one, ctx)) { |
| 89 | fprintf(stderr, "%s failed\n", test->name); | 89 | fprintf(stderr, "%s failed\n", test->name); |
| 90 | ERR_print_errors_fp(stderr); | 90 | ERR_print_errors_fp(stderr); |
| 91 | goto err; | 91 | goto err; |
| 92 | } | 92 | } |
| 93 | } else { | 93 | } else { |
| 94 | if (!test->mod_exp_mont_fn(result, a, p, one, ctx, NULL)) { | 94 | if (!test->mod_exp_mont_fn(got, a, p, one, ctx, NULL)) { |
| 95 | fprintf(stderr, "%s failed\n", test->name); | 95 | fprintf(stderr, "%s failed\n", test->name); |
| 96 | ERR_print_errors_fp(stderr); | 96 | ERR_print_errors_fp(stderr); |
| 97 | goto err; | 97 | goto err; |
| 98 | } | 98 | } |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | if (!BN_is_zero(result)) { | 101 | if (!BN_is_zero(got)) { |
| 102 | print_failure(result, a, test->name); | 102 | print_failure(got, a, test->name); |
| 103 | goto err; | 103 | goto err; |
| 104 | } | 104 | } |
| 105 | 105 | ||
| @@ -116,27 +116,27 @@ bn_mod_exp_zero_word_test(BN_CTX *ctx) | |||
| 116 | { | 116 | { |
| 117 | const char *name = "BN_mod_exp_mont_word"; | 117 | const char *name = "BN_mod_exp_mont_word"; |
| 118 | const BIGNUM *one; | 118 | const BIGNUM *one; |
| 119 | BIGNUM *p, *result; | 119 | BIGNUM *p, *got; |
| 120 | int failed = 1; | 120 | int failed = 1; |
| 121 | 121 | ||
| 122 | BN_CTX_start(ctx); | 122 | BN_CTX_start(ctx); |
| 123 | 123 | ||
| 124 | if ((p = BN_CTX_get(ctx)) == NULL) | 124 | if ((p = BN_CTX_get(ctx)) == NULL) |
| 125 | errx(1, "BN_CTX_get"); | 125 | errx(1, "BN_CTX_get"); |
| 126 | if ((result = BN_CTX_get(ctx)) == NULL) | 126 | if ((got = BN_CTX_get(ctx)) == NULL) |
| 127 | errx(1, "BN_CTX_get"); | 127 | errx(1, "BN_CTX_get"); |
| 128 | 128 | ||
| 129 | one = BN_value_one(); | 129 | one = BN_value_one(); |
| 130 | BN_zero(p); | 130 | BN_zero(p); |
| 131 | 131 | ||
| 132 | if (!BN_mod_exp_mont_word(result, 1, p, one, ctx, NULL)) { | 132 | if (!BN_mod_exp_mont_word(got, 1, p, one, ctx, NULL)) { |
| 133 | fprintf(stderr, "%s failed\n", name); | 133 | fprintf(stderr, "%s failed\n", name); |
| 134 | ERR_print_errors_fp(stderr); | 134 | ERR_print_errors_fp(stderr); |
| 135 | goto err; | 135 | goto err; |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | if (!BN_is_zero(result)) { | 138 | if (!BN_is_zero(got)) { |
| 139 | print_failure(result, one, name); | 139 | print_failure(got, one, name); |
| 140 | goto err; | 140 | goto err; |
| 141 | } | 141 | } |
| 142 | 142 | ||
