diff options
author | Matt Caswell <matt@openssl.org> | 2020-01-24 17:13:40 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2020-02-11 22:32:56 +0000 |
commit | 6f7d213533d9c7c2d810499cfedaa6d2424482c9 (patch) | |
tree | 4677e309cbc687b77a956255cbc8cc06fab1214e /crypto | |
parent | 90d3cb57c6caafbe031e32a99051386b8c5a90c0 (diff) | |
download | openssl-6f7d213533d9c7c2d810499cfedaa6d2424482c9.tar.gz |
Add X25519/X448 Key Exchange to the default provider
Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10964)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/ec/ecx_meth.c | 48 | ||||
-rw-r--r-- | crypto/err/openssl.txt | 3 |
2 files changed, 50 insertions, 1 deletions
diff --git a/crypto/ec/ecx_meth.c b/crypto/ec/ecx_meth.c index 15b902ec1d..88787e0db6 100644 --- a/crypto/ec/ecx_meth.c +++ b/crypto/ec/ecx_meth.c @@ -18,6 +18,8 @@ #include <openssl/x509.h> #include <openssl/ec.h> #include <openssl/rand.h> +#include <openssl/core_names.h> +#include "internal/param_build.h" #include "crypto/asn1.h" #include "crypto/evp.h" #include "crypto/ecx.h" @@ -401,6 +403,48 @@ static int ecx_get_pub_key(const EVP_PKEY *pkey, unsigned char *pub, return 1; } +static size_t ecx_pkey_dirty_cnt(const EVP_PKEY *pkey) +{ + /* + * We provide no mechanism to "update" an ECX key once it has been set, + * therefore we do not have to maintain a dirty count. + */ + return 1; +} + +static int ecx_pkey_export_to(const EVP_PKEY *from, void *to_keydata, + EVP_KEYMGMT *to_keymgmt) +{ + const ECX_KEY *key = from->pkey.ecx; + OSSL_PARAM_BLD tmpl; + OSSL_PARAM *params = NULL; + int rv = 0; + + ossl_param_bld_init(&tmpl); + + /* A key must at least have a public part */ + if (!ossl_param_bld_push_octet_string(&tmpl, OSSL_PKEY_PARAM_PUB_KEY, + key->pubkey, key->keylen)) + goto err; + + if (key->privkey != NULL) { + if (!ossl_param_bld_push_octet_string(&tmpl, + OSSL_PKEY_PARAM_PRIV_KEY, + key->privkey, key->keylen)) + goto err; + } + + params = ossl_param_bld_to_param(&tmpl); + + /* We export, the provider imports */ + rv = evp_keymgmt_import(to_keymgmt, to_keydata, OSSL_KEYMGMT_SELECT_ALL, + params); + + err: + ossl_param_bld_free(params); + return rv; +} + const EVP_PKEY_ASN1_METHOD ecx25519_asn1_meth = { EVP_PKEY_X25519, EVP_PKEY_X25519, @@ -442,6 +486,8 @@ const EVP_PKEY_ASN1_METHOD ecx25519_asn1_meth = { ecx_set_pub_key, ecx_get_priv_key, ecx_get_pub_key, + ecx_pkey_dirty_cnt, + ecx_pkey_export_to }; const EVP_PKEY_ASN1_METHOD ecx448_asn1_meth = { @@ -485,6 +531,8 @@ const EVP_PKEY_ASN1_METHOD ecx448_asn1_meth = { ecx_set_pub_key, ecx_get_priv_key, ecx_get_pub_key, + ecx_pkey_dirty_cnt, + ecx_pkey_export_to }; static int ecd_size25519(const EVP_PKEY *pkey) diff --git a/crypto/err/openssl.txt b/crypto/err/openssl.txt index a663bd2858..8920a77390 100644 --- a/crypto/err/openssl.txt +++ b/crypto/err/openssl.txt @@ -1822,13 +1822,13 @@ X509V3_F_X509_PURPOSE_SET:141:X509_PURPOSE_set X509_F_ADD_CERT_DIR:100:add_cert_dir X509_F_BUILD_CHAIN:106:build_chain X509_F_BY_FILE_CTRL:101:by_file_ctrl +X509_F_CACHE_OBJECTS:163:cache_objects X509_F_CHECK_NAME_CONSTRAINTS:149:check_name_constraints X509_F_CHECK_POLICY:145:check_policy X509_F_COMMON_VERIFY_SM2:165:common_verify_sm2 X509_F_DANE_I2D:107:dane_i2d X509_F_DIR_CTRL:102:dir_ctrl X509_F_GET_CERT_BY_SUBJECT:103:get_cert_by_subject -X509_F_CACHE_OBJECTS:163:cache_objects X509_F_I2D_X509_AUX:151:i2d_X509_AUX X509_F_LOOKUP_CERTS_SK:152:lookup_certs_sk X509_F_NETSCAPE_SPKI_B64_DECODE:129:NETSCAPE_SPKI_b64_decode @@ -2741,6 +2741,7 @@ PROV_R_BAD_TLS_CLIENT_VERSION:161:bad tls client version PROV_R_BN_ERROR:160:bn error PROV_R_BOTH_MODE_AND_MODE_INT:127:both mode and mode int PROV_R_CIPHER_OPERATION_FAILED:102:cipher operation failed +PROV_R_FAILED_DURING_DERIVATION:164:failed during derivation PROV_R_FAILED_TO_DECRYPT:162:failed to decrypt PROV_R_FAILED_TO_GENERATE_KEY:121:failed to generate key PROV_R_FAILED_TO_GET_PARAMETER:103:failed to get parameter |