diff options
Diffstat (limited to '')
| -rw-r--r-- | src/regress/lib/libcrypto/bn/bn_mod_exp.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_mod_exp.c b/src/regress/lib/libcrypto/bn/bn_mod_exp.c index 7009a6096a..68e44cf9e7 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.16 2023/03/26 14:50:23 tb Exp $ */ | 1 | /* $OpenBSD: bn_mod_exp.c,v 1.17 2023/03/26 18:46:23 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> |
| @@ -27,6 +27,24 @@ | |||
| 27 | #define INIT_MOD_EXP_FN(f) { .name = #f, .mod_exp_fn = (f), } | 27 | #define INIT_MOD_EXP_FN(f) { .name = #f, .mod_exp_fn = (f), } |
| 28 | #define INIT_MOD_EXP_MONT_FN(f) { .name = #f, .mod_exp_mont_fn = (f), } | 28 | #define INIT_MOD_EXP_MONT_FN(f) { .name = #f, .mod_exp_mont_fn = (f), } |
| 29 | 29 | ||
| 30 | static int | ||
| 31 | bn_mod_exp2_mont_first(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | ||
| 32 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *mctx) | ||
| 33 | { | ||
| 34 | const BIGNUM *one = BN_value_one(); | ||
| 35 | |||
| 36 | return BN_mod_exp2_mont(r, a, p, one, one, m, ctx, mctx); | ||
| 37 | } | ||
| 38 | |||
| 39 | static int | ||
| 40 | bn_mod_exp2_mont_second(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | ||
| 41 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *mctx) | ||
| 42 | { | ||
| 43 | const BIGNUM *one = BN_value_one(); | ||
| 44 | |||
| 45 | return BN_mod_exp2_mont(r, one, one, a, p, m, ctx, mctx); | ||
| 46 | } | ||
| 47 | |||
| 30 | static const struct mod_exp_zero_test { | 48 | static const struct mod_exp_zero_test { |
| 31 | const char *name; | 49 | const char *name; |
| 32 | int (*mod_exp_fn)(BIGNUM *, const BIGNUM *, const BIGNUM *, | 50 | int (*mod_exp_fn)(BIGNUM *, const BIGNUM *, const BIGNUM *, |
| @@ -43,6 +61,8 @@ static const struct mod_exp_zero_test { | |||
| 43 | INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_ct), | 61 | INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_ct), |
| 44 | INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_consttime), | 62 | INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_consttime), |
| 45 | INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_nonct), | 63 | INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_nonct), |
| 64 | INIT_MOD_EXP_MONT_FN(bn_mod_exp2_mont_first), | ||
| 65 | INIT_MOD_EXP_MONT_FN(bn_mod_exp2_mont_second), | ||
| 46 | }; | 66 | }; |
| 47 | 67 | ||
| 48 | #define N_MOD_EXP_ZERO_TESTS \ | 68 | #define N_MOD_EXP_ZERO_TESTS \ |
| @@ -193,6 +213,8 @@ static const struct mod_exp_test { | |||
| 193 | INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_ct), | 213 | INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_ct), |
| 194 | INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_consttime), | 214 | INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_consttime), |
| 195 | INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_nonct), | 215 | INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_nonct), |
| 216 | INIT_MOD_EXP_MONT_FN(bn_mod_exp2_mont_first), | ||
| 217 | INIT_MOD_EXP_MONT_FN(bn_mod_exp2_mont_second), | ||
| 196 | }; | 218 | }; |
| 197 | 219 | ||
| 198 | #define N_MOD_EXP_FN (sizeof(mod_exp_fn) / sizeof(mod_exp_fn[0])) | 220 | #define N_MOD_EXP_FN (sizeof(mod_exp_fn) / sizeof(mod_exp_fn[0])) |
