commit b5c2468c4d2b4b9ee2364e6331cbf968c060023d
parent 22bae681926eabc13c88db558e10355345f5a2aa
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 29 Oct 2023 16:47:04 +0100
init ossl
Diffstat:
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/openssl/openssl-test.c b/openssl/openssl-test.c
@@ -2914,7 +2914,9 @@ BN_add_word (BIGNUM *a, BN_ULONG w)
int
-BN_MONT_CTX_set (BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
+BN_MONT_CTX_set (BN_MONT_CTX *mont,
+ const BIGNUM *mod,
+ BN_CTX *ctx)
{
int i, ret = 0;
BIGNUM *Ri, *R;
@@ -3073,8 +3075,12 @@ err:
int
-BN_mod_exp_mont (BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
- const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
+BN_mod_exp_mont (BIGNUM *rr,
+ const BIGNUM *a,
+ const BIGNUM *p,
+ const BIGNUM *m,
+ BN_CTX *ctx,
+ BN_MONT_CTX *in_mont)
{
int i, j, bits, ret = 0, wstart, wend, window;
int start = 1;
@@ -3426,12 +3432,16 @@ err:
// BN_mod_exp_mont(r, a, p, m, ctx, NULL);
+// mm = modulus (n), aa = e, pp = d
void
test (char *aa, char *pp, char *mm)
{
OSSL_LIB_CTX ossl; // should be initialised
+ memset (&ossl,
+ 0,
+ sizeof (ossl));
BN_CTX ctx = *BN_CTX_new_ex (&ossl);
BIGNUM *a = BN_new ();
@@ -3446,5 +3456,6 @@ test (char *aa, char *pp, char *mm)
if (0 == BN_hex2bn (&m, mm))
abort ();
+ // NOTE: r==0, why?
BN_mod_exp_mont (r, a, p, m, &ctx, NULL);
}