diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/ecdh/ecdh.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/src/lib/libcrypto/ecdh/ecdh.c b/src/lib/libcrypto/ecdh/ecdh.c index 0781c30e09..ecb849c135 100644 --- a/src/lib/libcrypto/ecdh/ecdh.c +++ b/src/lib/libcrypto/ecdh/ecdh.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ecdh.c,v 1.4 2023/07/07 13:54:45 beck Exp $ */ | 1 | /* $OpenBSD: ecdh.c,v 1.5 2023/07/12 08:54:18 tb Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
| 4 | * | 4 | * |
| @@ -151,7 +151,7 @@ ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh | |||
| 151 | void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)) | 151 | void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)) |
| 152 | { | 152 | { |
| 153 | BN_CTX *ctx; | 153 | BN_CTX *ctx; |
| 154 | BIGNUM *cofactor, *x; | 154 | BIGNUM *x; |
| 155 | const BIGNUM *priv_key; | 155 | const BIGNUM *priv_key; |
| 156 | const EC_GROUP *group; | 156 | const EC_GROUP *group; |
| 157 | EC_POINT *point = NULL; | 157 | EC_POINT *point = NULL; |
| @@ -172,8 +172,6 @@ ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh | |||
| 172 | 172 | ||
| 173 | if ((x = BN_CTX_get(ctx)) == NULL) | 173 | if ((x = BN_CTX_get(ctx)) == NULL) |
| 174 | goto err; | 174 | goto err; |
| 175 | if ((cofactor = BN_CTX_get(ctx)) == NULL) | ||
| 176 | goto err; | ||
| 177 | 175 | ||
| 178 | if ((group = EC_KEY_get0_group(ecdh)) == NULL) | 176 | if ((group = EC_KEY_get0_group(ecdh)) == NULL) |
| 179 | goto err; | 177 | goto err; |
| @@ -191,18 +189,6 @@ ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh | |||
| 191 | goto err; | 189 | goto err; |
| 192 | } | 190 | } |
| 193 | 191 | ||
| 194 | if ((EC_KEY_get_flags(ecdh) & EC_FLAG_COFACTOR_ECDH) != 0) { | ||
| 195 | if (!EC_GROUP_get_cofactor(group, cofactor, NULL)) { | ||
| 196 | ECerror(ERR_R_EC_LIB); | ||
| 197 | goto err; | ||
| 198 | } | ||
| 199 | if (!BN_mul(cofactor, cofactor, priv_key, ctx)) { | ||
| 200 | ECerror(ERR_R_BN_LIB); | ||
| 201 | goto err; | ||
| 202 | } | ||
| 203 | priv_key = cofactor; | ||
| 204 | } | ||
| 205 | |||
| 206 | if (!EC_POINT_mul(group, point, NULL, pub_key, priv_key, ctx)) { | 192 | if (!EC_POINT_mul(group, point, NULL, pub_key, priv_key, ctx)) { |
| 207 | ECerror(EC_R_POINT_ARITHMETIC_FAILURE); | 193 | ECerror(EC_R_POINT_ARITHMETIC_FAILURE); |
| 208 | goto err; | 194 | goto err; |
