diff options
author | Ulf Möller <ulf@openssl.org> | 2000-02-05 14:17:32 +0000 |
---|---|---|
committer | Ulf Möller <ulf@openssl.org> | 2000-02-05 14:17:32 +0000 |
commit | 9b141126d4b6f0636bc047e81b846c193ae26611 (patch) | |
tree | c8786c99bfccc8b9899cad5c3aa30f29ada5e1b9 /crypto/dh | |
parent | 7e708ebee066d0308a335579b546326220dc8317 (diff) |
New functions BN_CTX_start(), BN_CTX_get(), BN_CTX_end() to access
temporary BIGNUMs. BN_CTX still uses a fixed number of BIGNUMs, but
the BN_CTX implementation could now easily be changed.
Diffstat (limited to 'crypto/dh')
-rw-r--r-- | crypto/dh/dh_gen.c | 13 | ||||
-rw-r--r-- | crypto/dh/dh_key.c | 4 |
2 files changed, 12 insertions, 5 deletions
diff --git a/crypto/dh/dh_gen.c b/crypto/dh/dh_gen.c index f0ee43ed87..7a6a38fbb4 100644 --- a/crypto/dh/dh_gen.c +++ b/crypto/dh/dh_gen.c @@ -95,9 +95,10 @@ DH *DH_generate_parameters(int prime_len, int generator, if (ret == NULL) goto err; ctx=BN_CTX_new(); if (ctx == NULL) goto err; - t1= &(ctx->bn[0]); - t2= &(ctx->bn[1]); - ctx->tos=2; + BN_CTX_start(ctx); + t1 = BN_CTX_get(ctx); + t2 = BN_CTX_get(ctx); + if (t1 == NULL || t2 == NULL) goto err; if (generator == DH_GENERATOR_2) { @@ -138,7 +139,11 @@ err: ok=0; } - if (ctx != NULL) BN_CTX_free(ctx); + if (ctx != NULL) + { + BN_CTX_end(ctx); + BN_CTX_free(ctx); + } if (!ok && (ret != NULL)) { DH_free(ret); diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c index 4e6a0fc0ef..0c7eeaf260 100644 --- a/crypto/dh/dh_key.c +++ b/crypto/dh/dh_key.c @@ -161,7 +161,8 @@ static int compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh) int ret= -1; BN_CTX_init(&ctx); - tmp= &(ctx.bn[ctx.tos++]); + BN_CTX_start(&ctx); + tmp = BN_CTX_get(&ctx); if (dh->priv_key == NULL) { @@ -184,6 +185,7 @@ static int compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh) ret=BN_bn2bin(tmp,key); err: + BN_CTX_end(&ctx); BN_CTX_free(&ctx); return(ret); } |