diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2019-03-21 20:09:02 +1000 |
---|---|---|
committer | Nicola Tuveri <nic.tuv@gmail.com> | 2019-04-11 12:05:38 +0300 |
commit | 8402cd5f75f8c2f60d8bd39775b24b03dd8b3b38 (patch) | |
tree | dd33391c6df2811326b1787ab8fef274d86d8e93 /crypto/ec/ec_check.c | |
parent | 4660bdea07e185b96c3b91be3e3b0a38959626ac (diff) |
added code to validate EC named curve parameters
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8555)
Diffstat (limited to 'crypto/ec/ec_check.c')
-rw-r--r-- | crypto/ec/ec_check.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/crypto/ec/ec_check.c b/crypto/ec/ec_check.c index 322d0fe551..09e3deb048 100644 --- a/crypto/ec/ec_check.c +++ b/crypto/ec/ec_check.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-2019 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 @@ -10,6 +10,16 @@ #include "ec_lcl.h" #include <openssl/err.h> +int EC_GROUP_check_named_curve(const EC_GROUP *group, int nist_only) +{ + int nid; + + nid = ec_curve_nid_from_params(group); + if (nid > 0 && nist_only && EC_curve_nid2nist(nid) == NULL) + nid = 0; + return nid; +} + int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx) { int ret = 0; @@ -17,6 +27,11 @@ int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx) BN_CTX *new_ctx = NULL; EC_POINT *point = NULL; + if (group == NULL || group->meth == NULL) { + ECerr(EC_F_EC_GROUP_CHECK, ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + /* Custom curves assumed to be correct */ if ((group->meth->flags & EC_FLAGS_CUSTOM_CURVE) != 0) return 1; |