aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/dh/dh_key.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2001-03-08 15:56:15 +0000
committerBodo Möller <bodo@openssl.org>2001-03-08 15:56:15 +0000
commitc62b26fdc6bb176541ec56498090ff6f2ad4a885 (patch)
tree8c29e8e873252b41f54761a71c2e75e15e154ac8 /crypto/dh/dh_key.c
parente0a9ba9c3c4ea7bf27ceff33633cd48b542de860 (diff)
downloadopenssl-c62b26fdc6bb176541ec56498090ff6f2ad4a885.tar.gz
Hide BN_CTX structure details.
Incease the number of BIGNUMs in a BN_CTX.
Diffstat (limited to 'crypto/dh/dh_key.c')
-rw-r--r--crypto/dh/dh_key.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c
index ad86048a36..91af882e43 100644
--- a/crypto/dh/dh_key.c
+++ b/crypto/dh/dh_key.c
@@ -101,11 +101,12 @@ const DH_METHOD *DH_OpenSSL(void)
static int generate_key(DH *dh)
{
int ok=0;
- BN_CTX ctx;
+ BN_CTX *ctx;
BN_MONT_CTX *mont;
BIGNUM *pub_key=NULL,*priv_key=NULL;
- BN_CTX_init(&ctx);
+ ctx = BN_CTX_new();
+ if (ctx == NULL) goto err;
if (dh->priv_key == NULL)
{
@@ -130,12 +131,12 @@ static int generate_key(DH *dh)
{
if ((dh->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)
if (!BN_MONT_CTX_set((BN_MONT_CTX *)dh->method_mont_p,
- dh->p,&ctx)) goto err;
+ dh->p,ctx)) goto err;
}
mont=(BN_MONT_CTX *)dh->method_mont_p;
if (!ENGINE_get_DH(dh->engine)->bn_mod_exp(dh, pub_key, dh->g,
- priv_key,dh->p,&ctx,mont))
+ priv_key,dh->p,ctx,mont))
goto err;
dh->pub_key=pub_key;
@@ -147,20 +148,21 @@ err:
if ((pub_key != NULL) && (dh->pub_key == NULL)) BN_free(pub_key);
if ((priv_key != NULL) && (dh->priv_key == NULL)) BN_free(priv_key);
- BN_CTX_free(&ctx);
+ BN_CTX_free(ctx);
return(ok);
}
static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
{
- BN_CTX ctx;
+ BN_CTX *ctx;
BN_MONT_CTX *mont;
BIGNUM *tmp;
int ret= -1;
- BN_CTX_init(&ctx);
- BN_CTX_start(&ctx);
- tmp = BN_CTX_get(&ctx);
+ ctx = BN_CTX_new();
+ if (ctx == NULL) goto err;
+ BN_CTX_start(ctx);
+ tmp = BN_CTX_get(ctx);
if (dh->priv_key == NULL)
{
@@ -171,12 +173,12 @@ static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
{
if ((dh->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)
if (!BN_MONT_CTX_set((BN_MONT_CTX *)dh->method_mont_p,
- dh->p,&ctx)) goto err;
+ dh->p,ctx)) goto err;
}
mont=(BN_MONT_CTX *)dh->method_mont_p;
if (!ENGINE_get_DH(dh->engine)->bn_mod_exp(dh, tmp, pub_key,
- dh->priv_key,dh->p,&ctx,mont))
+ dh->priv_key,dh->p,ctx,mont))
{
DHerr(DH_F_DH_COMPUTE_KEY,ERR_R_BN_LIB);
goto err;
@@ -184,8 +186,8 @@ static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
ret=BN_bn2bin(tmp,key);
err:
- BN_CTX_end(&ctx);
- BN_CTX_free(&ctx);
+ BN_CTX_end(ctx);
+ BN_CTX_free(ctx);
return(ret);
}