summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_pmeth.c
diff options
context:
space:
mode:
authortb <>2025-01-05 16:07:08 +0000
committertb <>2025-01-05 16:07:08 +0000
commit26c9248a10bd0d95f47397e21bc2f056e53e19c8 (patch)
tree01052cd554006bd8d0b366164df08e22b7dd6d57 /src/lib/libcrypto/ec/ec_pmeth.c
parent7d80fee84377d3dd9365558712de411fc7f8356b (diff)
downloadopenbsd-26c9248a10bd0d95f47397e21bc2f056e53e19c8.tar.gz
openbsd-26c9248a10bd0d95f47397e21bc2f056e53e19c8.tar.bz2
openbsd-26c9248a10bd0d95f47397e21bc2f056e53e19c8.zip
Move BIGNUMs in EC_GROUP and EC_POINT to the heap
The only way to get an EC_GROUP or an EC_POINT is by calling the relevant _new() function and to get rid of it, something must call _free(). Thus we can establish the invariant that every group has Weierstrass coefficients p, a, b as well as order and cofactor hanging off it. Similarly, Every point has allocated BIGNUMs for its Jacobian projective coordinates. Unfortunately, a group has the generator as an optional component in addition to seed and montgomery context/one (where optionality makes more sense). This is a mostly mechanical diff and only drops a few silly comments and a couple of unnecessary NULL checks since in our part of the wrold the word invariant has a meaning. This should also appease Coverity who likes to throw fits at calling BN_free() for BIGNUM on the stack (yes, this is actually a thing). ok jsing
Diffstat (limited to 'src/lib/libcrypto/ec/ec_pmeth.c')
-rw-r--r--src/lib/libcrypto/ec/ec_pmeth.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/ec/ec_pmeth.c b/src/lib/libcrypto/ec/ec_pmeth.c
index 424d1896b2..6d74a7f8a4 100644
--- a/src/lib/libcrypto/ec/ec_pmeth.c
+++ b/src/lib/libcrypto/ec/ec_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_pmeth.c,v 1.23 2024/10/19 14:41:03 tb Exp $ */ 1/* $OpenBSD: ec_pmeth.c,v 1.24 2025/01/05 16:07:08 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -323,7 +323,7 @@ pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
323 if (!ec_key->group) 323 if (!ec_key->group)
324 return -2; 324 return -2;
325 /* If cofactor is 1 cofactor mode does nothing */ 325 /* If cofactor is 1 cofactor mode does nothing */
326 if (BN_is_one(&ec_key->group->cofactor)) 326 if (BN_is_one(ec_key->group->cofactor))
327 return 1; 327 return 1;
328 if (!dctx->co_key) { 328 if (!dctx->co_key) {
329 dctx->co_key = EC_KEY_dup(ec_key); 329 dctx->co_key = EC_KEY_dup(ec_key);