1 |
wellsi |
1.1 |
diff -up openssl-fips-0.9.8e/fips/dh/fips_dh_key.c.dh-check openssl-fips-0.9.8e/fips/dh/fips_dh_key.c |
2 |
|
|
--- openssl-fips-0.9.8e/fips/dh/fips_dh_key.c.dh-check 2007-08-21 16:44:13.000000000 +0200 |
3 |
|
|
+++ openssl-fips-0.9.8e/fips/dh/fips_dh_key.c 2011-05-04 12:30:34.000000000 +0200 |
4 |
|
|
@@ -189,6 +189,7 @@ static int compute_key(unsigned char *ke |
5 |
|
|
BN_MONT_CTX *mont=NULL; |
6 |
|
|
BIGNUM *tmp; |
7 |
|
|
int ret= -1; |
8 |
|
|
+ int check_result; |
9 |
|
|
|
10 |
|
|
ctx = BN_CTX_new(); |
11 |
|
|
if (ctx == NULL) goto err; |
12 |
|
|
@@ -227,6 +228,12 @@ static int compute_key(unsigned char *ke |
13 |
|
|
goto err; |
14 |
|
|
} |
15 |
|
|
|
16 |
|
|
+ if (!DH_check_pub_key(dh, pub_key, &check_result) || check_result) |
17 |
|
|
+ { |
18 |
|
|
+ DHerr(DH_F_COMPUTE_KEY,DH_R_INVALID_PUBKEY); |
19 |
|
|
+ goto err; |
20 |
|
|
+ } |
21 |
|
|
+ |
22 |
|
|
if (!dh->meth->bn_mod_exp(dh, tmp, pub_key, dh->priv_key,dh->p,ctx,mont)) |
23 |
|
|
{ |
24 |
|
|
DHerr(DH_F_COMPUTE_KEY,ERR_R_BN_LIB); |
25 |
|
|
@@ -235,8 +242,11 @@ static int compute_key(unsigned char *ke |
26 |
|
|
|
27 |
|
|
ret=BN_bn2bin(tmp,key); |
28 |
|
|
err: |
29 |
|
|
- BN_CTX_end(ctx); |
30 |
|
|
- BN_CTX_free(ctx); |
31 |
|
|
+ if (ctx != NULL) |
32 |
|
|
+ { |
33 |
|
|
+ BN_CTX_end(ctx); |
34 |
|
|
+ BN_CTX_free(ctx); |
35 |
|
|
+ } |
36 |
|
|
return(ret); |
37 |
|
|
} |
38 |
|
|
|