summaryrefslogtreecommitdiffstats
path: root/crypto/ec/ec_asn1.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2016-02-01 18:15:57 +0000
committerDr. Stephen Henson <steve@openssl.org>2016-02-28 22:54:53 +0000
commit6903e2e7e9a47bb350920ae640287cf9f43a22ce (patch)
tree7cbbc665d681b79500d0c60aefdb3d745518896a /crypto/ec/ec_asn1.c
parent474d84ec81d6926698d27a2cbbbbe2961ecf6541 (diff)
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_asn1.c')
-rw-r--r--crypto/ec/ec_asn1.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c
index d56e6cdc2e..f033613993 100644
--- a/crypto/ec/ec_asn1.c
+++ b/crypto/ec/ec_asn1.c
@@ -342,7 +342,7 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field)
ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_ASN1_LIB);
goto err;
}
- } else /* nid == NID_X9_62_characteristic_two_field */
+ } else if (nid == NID_X9_62_characteristic_two_field)
#ifdef OPENSSL_NO_EC2M
{
ECerr(EC_F_EC_ASN1_GROUP2FIELDID, EC_R_GF2M_NOT_SUPPORTED);
@@ -417,6 +417,10 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field)
}
}
#endif
+ else {
+ ECerr(EC_F_EC_ASN1_GROUP2FIELDID, EC_R_UNSUPPORTED_FIELD);
+ goto err;
+ }
ok = 1;
@@ -1050,9 +1054,11 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len)
goto err;
}
} else {
- if (!EC_POINT_mul
- (ret->group, ret->pub_key, ret->priv_key, NULL, NULL, NULL)) {
- ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB);
+ if (ret->group->meth->keygenpub != NULL) {
+ if (ret->group->meth->keygenpub(ret) == 0)
+ goto err;
+ } else if (!EC_POINT_mul(ret->group, ret->pub_key, ret->priv_key, NULL,
+ NULL, NULL)) {
goto err;
}
/* Remember the original private-key-only encoding. */