From d8171446a274ab57e7d55d8d9f6ca8a0a7144d13 Mon Sep 17 00:00:00 2001 From: Pauli Date: Wed, 15 Apr 2020 10:06:20 +1000 Subject: ecx: check for errors creating public keys from private ones. Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/11371) --- crypto/ec/ec_err.c | 4 +++- crypto/ec/ecx_meth.c | 14 ++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'crypto/ec') 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; } } -- cgit v1.2.3