diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2022-12-02 18:24:02 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2022-12-02 18:24:02 +0000 |
commit | 594ddd5ca4e2875e65d584d94b2772e0dd5f93c2 (patch) | |
tree | f812bbecb24b17183d52b396d21a49b154501ae3 /regress | |
parent | 1ade12882bea5cb8bbac9e174c60829cfc47d1cc (diff) |
bn_mod_exp: we have a BN_CTX available...
Use BN_CTX_get() instead of BN_new()/BN_free().
Diffstat (limited to 'regress')
-rw-r--r-- | regress/lib/libcrypto/bn/bn_mod_exp.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/regress/lib/libcrypto/bn/bn_mod_exp.c b/regress/lib/libcrypto/bn/bn_mod_exp.c index d12d9f1e051..591d6031823 100644 --- a/regress/lib/libcrypto/bn/bn_mod_exp.c +++ b/regress/lib/libcrypto/bn/bn_mod_exp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mod_exp.c,v 1.3 2022/12/02 17:42:45 tb Exp $ */ +/* $OpenBSD: bn_mod_exp.c,v 1.4 2022/12/02 18:24:01 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -82,23 +82,26 @@ main(int argc, char *argv[]) if ((ctx = BN_CTX_new()) == NULL) goto err; - if ((r_mont = BN_new()) == NULL) + + BN_CTX_start(ctx); + + if ((r_mont = BN_CTX_get(ctx)) == NULL) goto err; - if ((r_mont_const = BN_new()) == NULL) + if ((r_mont_const = BN_CTX_get(ctx)) == NULL) goto err; - if ((r_mont_ct = BN_new()) == NULL) + if ((r_mont_ct = BN_CTX_get(ctx)) == NULL) goto err; - if ((r_mont_nonct = BN_new()) == NULL) + if ((r_mont_nonct = BN_CTX_get(ctx)) == NULL) goto err; - if ((r_recp = BN_new()) == NULL) + if ((r_recp = BN_CTX_get(ctx)) == NULL) goto err; - if ((r_simple = BN_new()) == NULL) + if ((r_simple = BN_CTX_get(ctx)) == NULL) goto err; - if ((a = BN_new()) == NULL) + if ((a = BN_CTX_get(ctx)) == NULL) goto err; - if ((b = BN_new()) == NULL) + if ((b = BN_CTX_get(ctx)) == NULL) goto err; - if ((m = BN_new()) == NULL) + if ((m = BN_CTX_get(ctx)) == NULL) goto err; if ((out = BIO_new(BIO_s_file())) == NULL) @@ -194,15 +197,8 @@ main(int argc, char *argv[]) exit(1); } } - BN_free(r_mont); - BN_free(r_mont_const); - BN_free(r_mont_ct); - BN_free(r_mont_nonct); - BN_free(r_recp); - BN_free(r_simple); - BN_free(a); - BN_free(b); - BN_free(m); + + BN_CTX_end(ctx); BN_CTX_free(ctx); ERR_remove_thread_state(NULL); CRYPTO_mem_leaks(out); |