diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2020-08-22 14:55:41 +1000 |
---|---|---|
committer | Shane Lontis <shane.lontis@oracle.com> | 2020-08-22 14:55:41 +1000 |
commit | c0f39ded68ba0929698a8773e63e9806ec9e5c74 (patch) | |
tree | dce39d009fceac112a1d320b5e072d94e22ca27d /include | |
parent | a02c715c183382aa3038fc4d7d463b17e62a24ff (diff) |
Add Explicit EC parameter support to providers.
This was added for backward compatability.
Added EC_GROUP_new_from_params() that supports explicit curve parameters.
This fixes the 15-test_genec.t TODO.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12604)
Diffstat (limited to 'include')
-rw-r--r-- | include/crypto/ec.h | 6 | ||||
-rw-r--r-- | include/openssl/core.h | 6 | ||||
-rw-r--r-- | include/openssl/core_names.h | 22 | ||||
-rw-r--r-- | include/openssl/ec.h | 14 | ||||
-rw-r--r-- | include/openssl/ecerr.h | 7 |
5 files changed, 51 insertions, 4 deletions
diff --git a/include/crypto/ec.h b/include/crypto/ec.h index 9901141bb2..587f7a39fc 100644 --- a/include/crypto/ec.h +++ b/include/crypto/ec.h @@ -59,10 +59,14 @@ const char *ec_curve_nid2name(int nid); int ec_curve_name2nid(const char *name); /* Backend support */ +int ec_group_todata(const EC_GROUP *group, OSSL_PARAM_BLD *tmpl, + OSSL_PARAM params[], OPENSSL_CTX *libctx, const char *propq, + BN_CTX *bnctx, unsigned char **genbuf); +int ec_group_fromdata(EC_KEY *ec, const OSSL_PARAM params[]); int ec_key_fromdata(EC_KEY *ecx, const OSSL_PARAM params[], int include_private); -int ec_key_domparams_fromdata(EC_KEY *ecx, const OSSL_PARAM params[]); int ec_key_otherparams_fromdata(EC_KEY *ec, const OSSL_PARAM params[]); int ec_set_ecdh_cofactor_mode(EC_KEY *ec, int mode); +int ec_encoding_name2id(const char *name); # endif /* OPENSSL_NO_EC */ #endif diff --git a/include/openssl/core.h b/include/openssl/core.h index e77c2ba22f..80ba32d9bf 100644 --- a/include/openssl/core.h +++ b/include/openssl/core.h @@ -107,18 +107,18 @@ struct ossl_param_st { # define OSSL_PARAM_REAL 3 /*- * OSSL_PARAM_UTF8_STRING - * is a printable string. Is expteced to be printed as it is. + * is a printable string. It is expected to be printed as it is. */ # define OSSL_PARAM_UTF8_STRING 4 /*- * OSSL_PARAM_OCTET_STRING - * is a string of bytes with no further specification. Is expected to be + * is a string of bytes with no further specification. It is expected to be * printed as a hexdump. */ # define OSSL_PARAM_OCTET_STRING 5 /*- * OSSL_PARAM_UTF8_PTR - * is a pointer to a printable string. Is expteced to be printed as it is. + * is a pointer to a printable string. It is expected to be printed as it is. * * The difference between this and OSSL_PARAM_UTF8_STRING is that only pointers * are manipulated for this type. diff --git a/include/openssl/core_names.h b/include/openssl/core_names.h index 7538d9ce93..bf6dd2e96f 100644 --- a/include/openssl/core_names.h +++ b/include/openssl/core_names.h @@ -269,6 +269,22 @@ extern "C" { #define OSSL_PKEY_PARAM_EC_PUB_X "qx" #define OSSL_PKEY_PARAM_EC_PUB_Y "qy" +/* Elliptic Curve Explicit Domain Parameters */ +#define OSSL_PKEY_PARAM_EC_FIELD_TYPE "field-type" +#define OSSL_PKEY_PARAM_EC_P "p" +#define OSSL_PKEY_PARAM_EC_A "a" +#define OSSL_PKEY_PARAM_EC_B "b" +#define OSSL_PKEY_PARAM_EC_GENERATOR "generator" +#define OSSL_PKEY_PARAM_EC_ORDER "order" +#define OSSL_PKEY_PARAM_EC_COFACTOR "cofactor" +#define OSSL_PKEY_PARAM_EC_SEED "seed" +#define OSSL_PKEY_PARAM_EC_CHAR2_M "m" +#define OSSL_PKEY_PARAM_EC_CHAR2_TYPE "basis-type" +#define OSSL_PKEY_PARAM_EC_CHAR2_TP_BASIS "tp" +#define OSSL_PKEY_PARAM_EC_CHAR2_PP_K1 "k1" +#define OSSL_PKEY_PARAM_EC_CHAR2_PP_K2 "k2" +#define OSSL_PKEY_PARAM_EC_CHAR2_PP_K3 "k3" + /* Elliptic Curve Key Parameters */ #define OSSL_PKEY_PARAM_USE_COFACTOR_FLAG "use-cofactor-flag" #define OSSL_PKEY_PARAM_USE_COFACTOR_ECDH \ @@ -352,6 +368,12 @@ extern "C" { #define OSSL_PKEY_PARAM_FFC_DIGEST OSSL_PKEY_PARAM_DIGEST #define OSSL_PKEY_PARAM_FFC_DIGEST_PROPS OSSL_PKEY_PARAM_PROPERTIES +#define OSSL_PKEY_PARAM_EC_ENCODING "encoding" /* utf8_string */ + +/* OSSL_PKEY_PARAM_EC_ENCODING values */ +#define OSSL_PKEY_EC_ENCODING_EXPLICIT "explicit" +#define OSSL_PKEY_EC_ENCODING_GROUP "named_curve" + /* Key Exchange parameters */ #define OSSL_EXCHANGE_PARAM_PAD "pad" /* uint */ #define OSSL_EXCHANGE_PARAM_EC_ECDH_COFACTOR_MODE "ecdh-cofactor-mode" /* int */ diff --git a/include/openssl/ec.h b/include/openssl/ec.h index 822e3e9b28..9db898cfed 100644 --- a/include/openssl/ec.h +++ b/include/openssl/ec.h @@ -47,6 +47,7 @@ typedef enum { POINT_CONVERSION_HYBRID = 6 } point_conversion_form_t; +# include <openssl/params.h> # ifndef OPENSSL_NO_DEPRECATED_3_0 typedef struct ec_method_st EC_METHOD; # endif @@ -380,6 +381,19 @@ EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, # endif /** + * Creates a EC_GROUP object with a curve specified by parameters. + * The parameters may be explicit or a named curve, + * \param params A list of parameters describing the group. + * \param libctx The associated library context or NULL for the default + * context + * \param propq A property query string + * \return newly created EC_GROUP object with specified parameters or NULL + * if an error occurred + */ +EC_GROUP *EC_GROUP_new_from_params(const OSSL_PARAM params[], + OPENSSL_CTX *libctx, const char *propq); + +/** * Creates a EC_GROUP object with a curve specified by a NID * \param libctx The associated library context or NULL for the default * context diff --git a/include/openssl/ecerr.h b/include/openssl/ecerr.h index b12e222510..bbed2b4b7c 100644 --- a/include/openssl/ecerr.h +++ b/include/openssl/ecerr.h @@ -243,7 +243,10 @@ int ERR_load_EC_strings(void); # define EC_R_GROUP2PKPARAMETERS_FAILURE 120 # define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 # define EC_R_INCOMPATIBLE_OBJECTS 101 +# define EC_R_INVALID_A 168 # define EC_R_INVALID_ARGUMENT 112 +# define EC_R_INVALID_B 169 +# define EC_R_INVALID_COFACTOR 171 # define EC_R_INVALID_COMPRESSED_POINT 110 # define EC_R_INVALID_COMPRESSION_BIT 109 # define EC_R_INVALID_CURVE 141 @@ -252,12 +255,16 @@ int ERR_load_EC_strings(void); # define EC_R_INVALID_ENCODING 102 # define EC_R_INVALID_FIELD 103 # define EC_R_INVALID_FORM 104 +# define EC_R_INVALID_GENERATOR 173 # define EC_R_INVALID_GROUP_ORDER 122 # define EC_R_INVALID_KEY 116 +# define EC_R_INVALID_NAMED_GROUP_CONVERSION 174 # define EC_R_INVALID_OUTPUT_LENGTH 161 +# define EC_R_INVALID_P 172 # define EC_R_INVALID_PEER_KEY 133 # define EC_R_INVALID_PENTANOMIAL_BASIS 132 # define EC_R_INVALID_PRIVATE_KEY 123 +# define EC_R_INVALID_SEED 175 # define EC_R_INVALID_TRINOMIAL_BASIS 137 # define EC_R_KDF_PARAMETER_ERROR 148 # define EC_R_KEYS_NOT_SET 140 |