[openssl] master update
Richard Levitte
levitte at openssl.org
Mon Jul 26 10:14:45 UTC 2021
The branch master has been updated
via 317ed1b41790db7187bc6585b3d57c6a983c793a (commit)
via ad0a2c011020268a242737820bc50549e76cd6b8 (commit)
from 4d4de19e9c77f36cc5ab71df77a6eb1253031d4c (commit)
- Log -----------------------------------------------------------------
commit 317ed1b41790db7187bc6585b3d57c6a983c793a
Author: Richard Levitte <levitte at openssl.org>
Date: Tue Jul 13 11:15:29 2021 +0200
DOCS: Move the description of EVP_PKEY_get0_description()
It appears to have been misplaced
Reviewed-by: Tomas Mraz <tomas at openssl.org>
Reviewed-by: Paul Dale <pauli at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16063)
commit ad0a2c011020268a242737820bc50549e76cd6b8
Author: Richard Levitte <levitte at openssl.org>
Date: Tue Jul 13 10:40:45 2021 +0200
EVP: Add EVP_PKEY_get0_provider() and EVP_PKEY_CTX_get0_provider()
Fixes #16058
Reviewed-by: Tomas Mraz <tomas at openssl.org>
Reviewed-by: Paul Dale <pauli at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16063)
-----------------------------------------------------------------------
Summary of changes:
crypto/evp/evp_pkey.c | 7 +++++++
crypto/evp/pmeth_lib.c | 24 +++++++++++++++++++++++-
doc/man3/EVP_PKEY_CTX_get0_libctx.pod | 19 ++++++++++++++-----
doc/man3/EVP_PKEY_is_a.pod | 15 ++++++++++++++-
doc/man3/EVP_PKEY_new.pod | 6 ------
include/openssl/evp.h | 4 +++-
util/libcrypto.num | 2 ++
7 files changed, 63 insertions(+), 14 deletions(-)
diff --git a/crypto/evp/evp_pkey.c b/crypto/evp/evp_pkey.c
index 6f0b3dbda9..8f3f150375 100644
--- a/crypto/evp/evp_pkey.c
+++ b/crypto/evp/evp_pkey.c
@@ -237,3 +237,10 @@ const char *EVP_PKEY_get0_type_name(const EVP_PKEY *key)
return name;
}
+
+const OSSL_PROVIDER *EVP_PKEY_get0_provider(const EVP_PKEY *key)
+{
+ if (evp_pkey_is_provided(key))
+ return EVP_KEYMGMT_get0_provider(key->keymgmt);
+ return NULL;
+}
diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c
index e5975081e1..7b835a5eb6 100644
--- a/crypto/evp/pmeth_lib.c
+++ b/crypto/evp/pmeth_lib.c
@@ -1531,11 +1531,33 @@ OSSL_LIB_CTX *EVP_PKEY_CTX_get0_libctx(EVP_PKEY_CTX *ctx)
return ctx->libctx;
}
-const char *EVP_PKEY_CTX_get0_propq(EVP_PKEY_CTX *ctx)
+const char *EVP_PKEY_CTX_get0_propq(const EVP_PKEY_CTX *ctx)
{
return ctx->propquery;
}
+const OSSL_PROVIDER *EVP_PKEY_CTX_get0_provider(const EVP_PKEY_CTX *ctx)
+{
+ if (EVP_PKEY_CTX_IS_SIGNATURE_OP(ctx)) {
+ if (ctx->op.sig.signature != NULL)
+ return EVP_SIGNATURE_get0_provider(ctx->op.sig.signature);
+ } else if (EVP_PKEY_CTX_IS_DERIVE_OP(ctx)) {
+ if (ctx->op.kex.exchange != NULL)
+ return EVP_KEYEXCH_get0_provider(ctx->op.kex.exchange);
+ } else if (EVP_PKEY_CTX_IS_KEM_OP(ctx)) {
+ if (ctx->op.encap.kem != NULL)
+ return EVP_KEM_get0_provider(ctx->op.encap.kem);
+ } else if (EVP_PKEY_CTX_IS_ASYM_CIPHER_OP(ctx)) {
+ if (ctx->op.ciph.cipher != NULL)
+ return EVP_ASYM_CIPHER_get0_provider(ctx->op.ciph.cipher);
+ } else if (EVP_PKEY_CTX_IS_GEN_OP(ctx)) {
+ if (ctx->keymgmt != NULL)
+ return EVP_KEYMGMT_get0_provider(ctx->keymgmt);
+ }
+
+ return NULL;
+}
+
/* Utility functions to send a string of hex string to a ctrl */
int EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str)
diff --git a/doc/man3/EVP_PKEY_CTX_get0_libctx.pod b/doc/man3/EVP_PKEY_CTX_get0_libctx.pod
index 33aa418462..9f84bd96c4 100644
--- a/doc/man3/EVP_PKEY_CTX_get0_libctx.pod
+++ b/doc/man3/EVP_PKEY_CTX_get0_libctx.pod
@@ -3,28 +3,37 @@
=head1 NAME
EVP_PKEY_CTX_get0_libctx,
-EVP_PKEY_CTX_get0_propq
-- functions for getting OSSL_LIB_CTX and property query data from an EVP_PKEY_CTX
+EVP_PKEY_CTX_get0_propq,
+EVP_PKEY_CTX_get0_provider
+- functions for getting diverse information from an EVP_PKEY_CTX
=head1 SYNOPSIS
#include <openssl/evp.h>
OSSL_LIB_CTX *EVP_PKEY_CTX_get0_libctx(EVP_PKEY_CTX *ctx);
- const char *EVP_PKEY_CTX_get0_propq(EVP_PKEY_CTX *ctx);
+ const char *EVP_PKEY_CTX_get0_propq(const EVP_PKEY_CTX *ctx);
+ const OSSL_PROVIDER *EVP_PKEY_CTX_get0_provider(const EVP_PKEY_CTX *ctx);
=head1 DESCRIPTION
-The EVP_PKEY_CTX_get0_libctx() and EVP_PKEY_CTX_get0_propq() functions obtain
-the OSSL_LIB_CTX and property query string values respectively that were
+EVP_PKEY_CTX_get0_libctx() and EVP_PKEY_CTX_get0_propq() obtain the
+OSSL_LIB_CTX and property query string values respectively that were
associated with the EVP_PKEY_CTX when it was constructed.
+EVP_PKEY_CTX_get0_provider() returns the provider associated with the
+ongoing B<EVP_PKEY_CTX> operation. If the operation is performed by
+en B<ENGINE>, this function returns NULL.
+
=head1 RETURN VALUES
EVP_PKEY_CTX_get0_libctx() and EVP_PKEY_CTX_get0_propq() functions return the
OSSL_LIB_CTX and property query string associated with the EVP_PKEY_CTX or NULL
if they are not set. The returned values should not be freed by the caller.
+EVP_PKEY_CTX_get0_provider() returns a provider if an operation performed by
+a provider is ongoing, otherwise NULL.
+
=head1 SEE ALSO
L<EVP_PKEY_CTX_new(3)>
diff --git a/doc/man3/EVP_PKEY_is_a.pod b/doc/man3/EVP_PKEY_is_a.pod
index 58c7ed7f8e..8bada052fa 100644
--- a/doc/man3/EVP_PKEY_is_a.pod
+++ b/doc/man3/EVP_PKEY_is_a.pod
@@ -3,7 +3,7 @@
=head1 NAME
EVP_PKEY_is_a, EVP_PKEY_can_sign, EVP_PKEY_type_names_do_all,
-EVP_PKEY_get0_type_name
+EVP_PKEY_get0_type_name, EVP_PKEY_get0_description, EVP_PKEY_get0_provider
- key type and capabilities functions
=head1 SYNOPSIS
@@ -16,6 +16,8 @@ EVP_PKEY_get0_type_name
void (*fn)(const char *name, void *data),
void *data);
const char *EVP_PKEY_get0_type_name(const EVP_PKEY *key);
+ const char *EVP_PKEY_get0_description(const EVP_PKEY *key);
+ const OSSL_PROVIDER *EVP_PKEY_get0_provider(const EVP_PKEY *key);
=head1 DESCRIPTION
@@ -38,6 +40,13 @@ that holds the key which one will be returned.
Ownership of the returned string is retained by the I<pkey> object and should
not be freed by the caller.
+EVP_PKEY_get0_description() returns a description of the type of B<EVP_PKEY>,
+meant for display and human consumption. The description is at the
+discretion of the key type implementation.
+
+EVP_PKEY_get0_provider() returns the provider of the B<EVP_PKEY>'s
+L<EVP_KEYMGMT(3)>.
+
=head1 RETURN VALUES
EVP_PKEY_is_a() returns 1 if I<pkey> has the key type I<name>,
@@ -48,6 +57,10 @@ supports signing, otherwise 0.
EVP_PKEY_get0_type_name() returns the name that is found or NULL on error.
+EVP_PKEY_get0_description() returns the description if found or NULL if not.
+
+EVP_PKEY_get0_provider() returns the provider if found or NULL if not.
+
EVP_PKEY_type_names_do_all() returns 1 if the callback was called for all
names. A return value of 0 means that the callback was not called for any
names.
diff --git a/doc/man3/EVP_PKEY_new.pod b/doc/man3/EVP_PKEY_new.pod
index 89b93c9bac..ee55396de3 100644
--- a/doc/man3/EVP_PKEY_new.pod
+++ b/doc/man3/EVP_PKEY_new.pod
@@ -7,7 +7,6 @@ EVP_PKEY_new,
EVP_PKEY_up_ref,
EVP_PKEY_dup,
EVP_PKEY_free,
-EVP_PKEY_get0_description,
EVP_PKEY_new_raw_private_key_ex,
EVP_PKEY_new_raw_private_key,
EVP_PKEY_new_raw_public_key_ex,
@@ -28,7 +27,6 @@ EVP_PKEY_get_raw_public_key
int EVP_PKEY_up_ref(EVP_PKEY *key);
EVP_PKEY *EVP_PKEY_dup(EVP_PKEY *key);
void EVP_PKEY_free(EVP_PKEY *key);
- const char *EVP_PKEY_get0_description(const EVP_PKEY *key);
EVP_PKEY *EVP_PKEY_new_raw_private_key_ex(OSSL_LIB_CTX *libctx,
const char *keytype,
@@ -92,10 +90,6 @@ a raw key, otherwise the duplication will fail.
EVP_PKEY_free() decrements the reference count of I<key> and, if the reference
count is zero, frees it up. If I<key> is NULL, nothing is done.
-EVP_PKEY_get0_description() returns a description of the type of B<EVP_PKEY>,
-meant for display and human consumption. The description is at the
-discretion of the key type implementation.
-
EVP_PKEY_new_raw_private_key_ex() allocates a new B<EVP_PKEY>. Unless an
engine should be used for the key type, a provider for the key is found using
the library context I<libctx> and the property query string I<propq>. The
diff --git a/include/openssl/evp.h b/include/openssl/evp.h
index f76c4a26d1..1c8ce48773 100644
--- a/include/openssl/evp.h
+++ b/include/openssl/evp.h
@@ -1380,6 +1380,7 @@ int EVP_PKEY_up_ref(EVP_PKEY *pkey);
EVP_PKEY *EVP_PKEY_dup(EVP_PKEY *pkey);
void EVP_PKEY_free(EVP_PKEY *pkey);
const char *EVP_PKEY_get0_description(const EVP_PKEY *pkey);
+const OSSL_PROVIDER *EVP_PKEY_get0_provider(const EVP_PKEY *key);
EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
long length);
@@ -2160,7 +2161,8 @@ int EVP_PKEY_get_group_name(const EVP_PKEY *pkey, char *name, size_t name_sz,
size_t *gname_len);
OSSL_LIB_CTX *EVP_PKEY_CTX_get0_libctx(EVP_PKEY_CTX *ctx);
-const char *EVP_PKEY_CTX_get0_propq(EVP_PKEY_CTX *ctx);
+const char *EVP_PKEY_CTX_get0_propq(const EVP_PKEY_CTX *ctx);
+const OSSL_PROVIDER *EVP_PKEY_CTX_get0_provider(const EVP_PKEY_CTX *ctx);
# ifdef __cplusplus
}
diff --git a/util/libcrypto.num b/util/libcrypto.num
index c7862c568d..3d4d7c37df 100644
--- a/util/libcrypto.num
+++ b/util/libcrypto.num
@@ -5423,3 +5423,5 @@ ASN1_item_d2i_fp_ex ? 3_0_0 EXIST::FUNCTION:STDIO
ASN1_item_d2i_bio_ex ? 3_0_0 EXIST::FUNCTION:
ASN1_item_d2i_ex ? 3_0_0 EXIST::FUNCTION:
ASN1_TIME_print_ex ? 3_0_0 EXIST::FUNCTION:
+EVP_PKEY_get0_provider ? 3_0_0 EXIST::FUNCTION:
+EVP_PKEY_CTX_get0_provider ? 3_0_0 EXIST::FUNCTION:
More information about the openssl-commits
mailing list