summaryrefslogtreecommitdiffstats
path: root/crypto/ec
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2020-04-15 10:06:20 +1000
committerPauli <paul.dale@oracle.com>2020-04-17 19:51:37 +1000
commitd8171446a274ab57e7d55d8d9f6ca8a0a7144d13 (patch)
tree438785e97e48f7ef76c49331e07d84a9f69dc58b /crypto/ec
parentc1e48c5171affd99111fd08e7a0a7e1a76121138 (diff)
ecx: check for errors creating public keys from private ones.
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11371)
Diffstat (limited to 'crypto/ec')
-rw-r--r--crypto/ec/ec_err.c4
-rw-r--r--crypto/ec/ecx_meth.c14
2 files changed, 11 insertions, 7 deletions
diff --git a/crypto/ec/ec_err.c b/crypto/ec/ec_err.c
index 66d9c4b16e..d775ced93a 100644
--- a/crypto/ec/ec_err.c
+++ b/crypto/ec/ec_err.c
@@ -1,6 +1,6 @@
/*
* Generated by util/mkerr.pl DO NOT EDIT
- * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -34,6 +34,8 @@ static const ERR_STRING_DATA EC_str_reasons[] = {
"discriminant is zero"},
{ERR_PACK(ERR_LIB_EC, 0, EC_R_EC_GROUP_NEW_BY_NAME_FAILURE),
"ec group new by name failure"},
+ {ERR_PACK(ERR_LIB_EC, 0, EC_R_FAILED_MAKING_PUBLIC_KEY),
+ "failed making public key"},
{ERR_PACK(ERR_LIB_EC, 0, EC_R_FIELD_TOO_LARGE), "field too large"},
{ERR_PACK(ERR_LIB_EC, 0, EC_R_GF2M_NOT_SUPPORTED), "gf2m not supported"},
{ERR_PACK(ERR_LIB_EC, 0, EC_R_GROUP2PKPARAMETERS_FAILURE),
diff --git a/crypto/ec/ecx_meth.c b/crypto/ec/ecx_meth.c
index 3944f483ed..ba037ffb8b 100644
--- a/crypto/ec/ecx_meth.c
+++ b/crypto/ec/ecx_meth.c
@@ -93,17 +93,19 @@ static int ecx_key_op(EVP_PKEY *pkey, int id, const X509_ALGOR *palg,
X25519_public_from_private(pubkey, privkey);
break;
case EVP_PKEY_ED25519:
- /*
- * TODO(3.0): We set the library context to NULL for now. This will
- * need to change.
- */
- ED25519_public_from_private(NULL, pubkey, privkey);
+ if (!ED25519_public_from_private(libctx, pubkey, privkey)) {
+ ECerr(EC_F_ECX_KEY_OP, EC_R_FAILED_MAKING_PUBLIC_KEY);
+ return 0;
+ }
break;
case EVP_PKEY_X448:
X448_public_from_private(pubkey, privkey);
break;
case EVP_PKEY_ED448:
- ED448_public_from_private(libctx, pubkey, privkey);
+ if (!ED448_public_from_private(libctx, pubkey, privkey)) {
+ ECerr(EC_F_ECX_KEY_OP, EC_R_FAILED_MAKING_PUBLIC_KEY);
+ return 0;
+ }
break;
}
}