summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-03-20 13:49:08 +0100
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-05-11 12:46:42 +0200
commitf925315203f77d0241183ccabfc784d259b0a152 (patch)
tree2d92c75d7e19d48de1ed8da32b724b3603f5a3c6 /include
parent6dbb277627de86578577185084378135605d2df1 (diff)
Add convenience functions and macros for asymmetric key generation
Add EVP_PKEY_gen(), EVP_PKEY_Q_gen(), EVP_RSA_gen(), and EVP_EC_gen(). Also export auxiliary function OSSL_EC_curve_nid2name() and improve deprecation info on RSA and EC key generation/management functions. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/14695)
Diffstat (limited to 'include')
-rw-r--r--include/crypto/ec.h1
-rw-r--r--include/openssl/ec.h6
-rw-r--r--include/openssl/evp.h4
-rw-r--r--include/openssl/rsa.h3
4 files changed, 11 insertions, 3 deletions
diff --git a/include/crypto/ec.h b/include/crypto/ec.h
index 9743dcc3a7..acb14effc9 100644
--- a/include/crypto/ec.h
+++ b/include/crypto/ec.h
@@ -16,7 +16,6 @@
# include <openssl/opensslconf.h>
# include <openssl/evp.h>
-const char *ossl_ec_curve_nid2name(int nid);
int ossl_ec_curve_name2nid(const char *name);
const char *ossl_ec_curve_nid2nist_int(int nid);
int ossl_ec_curve_nist2nid_int(const char *name);
diff --git a/include/openssl/ec.h b/include/openssl/ec.h
index 970570c1ed..ad40b9045c 100644
--- a/include/openssl/ec.h
+++ b/include/openssl/ec.h
@@ -84,6 +84,8 @@ typedef enum {
POINT_CONVERSION_HYBRID = 6
} point_conversion_form_t;
+const char *OSSL_EC_curve_nid2name(int nid);
+
# ifndef OPENSSL_NO_EC
# include <openssl/asn1.h>
# include <openssl/symhacks.h>
@@ -1072,7 +1074,7 @@ OSSL_DEPRECATEDIN_3_0 void EC_KEY_set_conv_form(EC_KEY *eckey,
point_conversion_form_t cform);
# endif /*OPENSSL_NO_DEPRECATED_3_0 */
-# define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \
+# define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \
CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef)
# ifndef OPENSSL_NO_DEPRECATED_3_0
@@ -1544,6 +1546,8 @@ OSSL_DEPRECATEDIN_3_0 void EC_KEY_METHOD_get_verify
EC_KEY *eckey));
# endif /* OPENSSL_NO_DEPRECATED_3_0 */
+# define EVP_EC_gen(curve) \
+ EVP_PKEY_Q_keygen(NULL, NULL, "EC", (char *)(strstr(curve, "")))
# define ECParameters_dup(x) ASN1_dup_of(EC_KEY, i2d_ECParameters, \
d2i_ECParameters, x)
diff --git a/include/openssl/evp.h b/include/openssl/evp.h
index c380f2e539..34eced8d92 100644
--- a/include/openssl/evp.h
+++ b/include/openssl/evp.h
@@ -1933,11 +1933,13 @@ int EVP_PKEY_set_octet_string_param(EVP_PKEY *pkey, const char *key_name,
int EVP_PKEY_get_ec_point_conv_form(const EVP_PKEY *pkey);
int EVP_PKEY_get_field_type(const EVP_PKEY *pkey);
+EVP_PKEY *EVP_PKEY_Q_keygen(OSSL_LIB_CTX *libctx, const char *propq,
+ const char *type, ...);
int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);
int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);
int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
-int EVP_PKEY_gen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
+int EVP_PKEY_generate(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
int EVP_PKEY_check(EVP_PKEY_CTX *ctx);
int EVP_PKEY_public_check(EVP_PKEY_CTX *ctx);
int EVP_PKEY_public_check_quick(EVP_PKEY_CTX *ctx);
diff --git a/include/openssl/rsa.h b/include/openssl/rsa.h
index 573ba003cc..a55c9727c6 100644
--- a/include/openssl/rsa.h
+++ b/include/openssl/rsa.h
@@ -245,6 +245,9 @@ OSSL_DEPRECATEDIN_3_0 int RSA_get_version(RSA *r);
OSSL_DEPRECATEDIN_3_0 ENGINE *RSA_get0_engine(const RSA *r);
# endif /* !OPENSSL_NO_DEPRECATED_3_0 */
+# define EVP_RSA_gen(bits) \
+ EVP_PKEY_Q_keygen(NULL, NULL, "RSA", (size_t)(0 + (bits)))
+
/* Deprecated version */
# ifndef OPENSSL_NO_DEPRECATED_0_9_8
OSSL_DEPRECATEDIN_0_9_8 RSA *RSA_generate_key(int bits, unsigned long e, void