diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/dh/dh_check.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/lib/libcrypto/dh/dh_check.c b/src/lib/libcrypto/dh/dh_check.c index 7b9fcbdf5a..a3d2c98c34 100644 --- a/src/lib/libcrypto/dh/dh_check.c +++ b/src/lib/libcrypto/dh/dh_check.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dh_check.c,v 1.21 2021/11/29 20:02:14 tb Exp $ */ | 1 | /* $OpenBSD: dh_check.c,v 1.22 2021/12/05 13:45:26 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -68,18 +68,11 @@ | |||
68 | int | 68 | int |
69 | DH_check_params(const DH *dh, int *flags) | 69 | DH_check_params(const DH *dh, int *flags) |
70 | { | 70 | { |
71 | BN_CTX *ctx = NULL; | 71 | BIGNUM *max_g = NULL; |
72 | BIGNUM *max_g; | ||
73 | int ok = 0; | 72 | int ok = 0; |
74 | 73 | ||
75 | *flags = 0; | 74 | *flags = 0; |
76 | 75 | ||
77 | if ((ctx = BN_CTX_new()) == NULL) | ||
78 | goto err; | ||
79 | BN_CTX_start(ctx); | ||
80 | if ((max_g = BN_CTX_get(ctx)) == NULL) | ||
81 | goto err; | ||
82 | |||
83 | if (!BN_is_odd(dh->p)) | 76 | if (!BN_is_odd(dh->p)) |
84 | *flags |= DH_CHECK_P_NOT_PRIME; | 77 | *flags |= DH_CHECK_P_NOT_PRIME; |
85 | 78 | ||
@@ -90,7 +83,7 @@ DH_check_params(const DH *dh, int *flags) | |||
90 | if (BN_cmp(dh->g, BN_value_one()) <= 0) | 83 | if (BN_cmp(dh->g, BN_value_one()) <= 0) |
91 | *flags |= DH_NOT_SUITABLE_GENERATOR; | 84 | *flags |= DH_NOT_SUITABLE_GENERATOR; |
92 | /* max_g = p - 1 */ | 85 | /* max_g = p - 1 */ |
93 | if (BN_copy(max_g, dh->p) == NULL) | 86 | if ((max_g = BN_dup(dh->p)) == NULL) |
94 | goto err; | 87 | goto err; |
95 | if (!BN_sub_word(max_g, 1)) | 88 | if (!BN_sub_word(max_g, 1)) |
96 | goto err; | 89 | goto err; |
@@ -101,8 +94,7 @@ DH_check_params(const DH *dh, int *flags) | |||
101 | ok = 1; | 94 | ok = 1; |
102 | 95 | ||
103 | err: | 96 | err: |
104 | BN_CTX_end(ctx); | 97 | BN_free(max_g); |
105 | BN_CTX_free(ctx); | ||
106 | 98 | ||
107 | return ok; | 99 | return ok; |
108 | } | 100 | } |