diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2016-02-01 18:15:57 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2016-02-28 22:54:53 +0000 |
commit | 6903e2e7e9a47bb350920ae640287cf9f43a22ce (patch) | |
tree | 7cbbc665d681b79500d0c60aefdb3d745518896a /crypto/ec/ec_lib.c | |
parent | 474d84ec81d6926698d27a2cbbbbe2961ecf6541 (diff) | |
download | openssl-6903e2e7e9a47bb350920ae640287cf9f43a22ce.zip openssl-6903e2e7e9a47bb350920ae640287cf9f43a22ce.tar.gz openssl-6903e2e7e9a47bb350920ae640287cf9f43a22ce.tar.bz2 |
Extended EC_METHOD customisation support.
Add support for optional overrides of various private key operations
in EC_METHOD.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
Diffstat (limited to 'crypto/ec/ec_lib.c')
-rw-r--r-- | crypto/ec/ec_lib.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c index a34113c..b7bbc41 100644 --- a/crypto/ec/ec_lib.c +++ b/crypto/ec/ec_lib.c @@ -89,12 +89,14 @@ EC_GROUP *EC_GROUP_new(const EC_METHOD *meth) } ret->meth = meth; - ret->order = BN_new(); - if (ret->order == NULL) - goto err; - ret->cofactor = BN_new(); - if (ret->cofactor == NULL) - goto err; + if ((ret->meth->flags & EC_FLAGS_CUSTOM_CURVE) == 0) { + ret->order = BN_new(); + if (ret->order == NULL) + goto err; + ret->cofactor = BN_new(); + if (ret->cofactor == NULL) + goto err; + } ret->asn1_flag = OPENSSL_EC_NAMED_CURVE; ret->asn1_form = POINT_CONVERSION_UNCOMPRESSED; if (!meth->group_init(ret)) @@ -240,10 +242,12 @@ int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) dest->generator = NULL; } - if (!BN_copy(dest->order, src->order)) - return 0; - if (!BN_copy(dest->cofactor, src->cofactor)) - return 0; + if ((src->meth->flags & EC_FLAGS_CUSTOM_CURVE) == 0) { + if (!BN_copy(dest->order, src->order)) + return 0; + if (!BN_copy(dest->cofactor, src->cofactor)) + return 0; + } dest->curve_name = src->curve_name; dest->asn1_flag = src->asn1_flag; @@ -527,6 +531,8 @@ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx) if (EC_GROUP_get_curve_name(a) && EC_GROUP_get_curve_name(b) && EC_GROUP_get_curve_name(a) != EC_GROUP_get_curve_name(b)) return 1; + if (a->meth->flags & EC_FLAGS_CUSTOM_CURVE) + return 0; if (ctx == NULL) ctx_new = ctx = BN_CTX_new(); |