diff options
Diffstat (limited to 'src/lib/libcrypto/ec/ec_lib.c')
-rw-r--r-- | src/lib/libcrypto/ec/ec_lib.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c index b1aad34017..8bae5940c2 100644 --- a/src/lib/libcrypto/ec/ec_lib.c +++ b/src/lib/libcrypto/ec/ec_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_lib.c,v 1.97 2025/01/06 12:35:14 jsing Exp $ */ | 1 | /* $OpenBSD: ec_lib.c,v 1.98 2025/01/06 14:22:55 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Originally written by Bodo Moeller for the OpenSSL project. | 3 | * Originally written by Bodo Moeller for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -150,10 +150,6 @@ LCRYPTO_ALIAS(EC_GROUP_clear_free); | |||
150 | int | 150 | int |
151 | EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) | 151 | EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) |
152 | { | 152 | { |
153 | if (dest->meth->group_copy == NULL) { | ||
154 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | ||
155 | return 0; | ||
156 | } | ||
157 | if (dest->meth != src->meth) { | 153 | if (dest->meth != src->meth) { |
158 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 154 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); |
159 | return 0; | 155 | return 0; |
@@ -161,8 +157,23 @@ EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) | |||
161 | if (dest == src) | 157 | if (dest == src) |
162 | return 1; | 158 | return 1; |
163 | 159 | ||
164 | if (!dest->meth->group_copy(dest, src)) | 160 | if (!bn_copy(dest->p, src->p)) |
165 | return 0; | 161 | return 0; |
162 | if (!bn_copy(dest->a, src->a)) | ||
163 | return 0; | ||
164 | if (!bn_copy(dest->b, src->b)) | ||
165 | return 0; | ||
166 | |||
167 | dest->a_is_minus3 = src->a_is_minus3; | ||
168 | |||
169 | BN_MONT_CTX_free(dest->mont_ctx); | ||
170 | dest->mont_ctx = NULL; | ||
171 | if (src->mont_ctx != NULL) { | ||
172 | if ((dest->mont_ctx = BN_MONT_CTX_new()) == NULL) | ||
173 | return 0; | ||
174 | if (!BN_MONT_CTX_copy(dest->mont_ctx, src->mont_ctx)) | ||
175 | return 0; | ||
176 | } | ||
166 | 177 | ||
167 | EC_POINT_free(dest->generator); | 178 | EC_POINT_free(dest->generator); |
168 | dest->generator = NULL; | 179 | dest->generator = NULL; |
@@ -185,7 +196,7 @@ EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) | |||
185 | if (!EC_GROUP_set_seed(dest, src->seed, src->seed_len)) | 196 | if (!EC_GROUP_set_seed(dest, src->seed, src->seed_len)) |
186 | return 0; | 197 | return 0; |
187 | 198 | ||
188 | return dest->meth->group_copy(dest, src); | 199 | return 1; |
189 | } | 200 | } |
190 | LCRYPTO_ALIAS(EC_GROUP_copy); | 201 | LCRYPTO_ALIAS(EC_GROUP_copy); |
191 | 202 | ||