Make evp_pkey_ctx_get0_libctx/propq public API

These were previously added as an internal API. But since the CMS code
needs them, other code might do too.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/13088)
This commit is contained in:
Matt Caswell 2020-10-12 17:12:03 +01:00
parent 0d30e15a57
commit 29000e43ea
6 changed files with 54 additions and 7 deletions

View File

@ -100,10 +100,9 @@ static int ecdh_cms_set_peerkey(EVP_PKEY_CTX *pctx,
if (!EVP_PKEY_copy_parameters(pkpeer, pk))
goto err;
} else {
/* TODO(3.0): Should the get0_libctx/propq calls actually be public API? */
pkpeer = pkey_type2param(atype, aval,
evp_pkey_ctx_get0_libctx(pctx),
evp_pkey_ctx_get0_propq(pctx));
EVP_PKEY_CTX_get0_libctx(pctx),
EVP_PKEY_CTX_get0_propq(pctx));
if (pkpeer == NULL)
goto err;
}

View File

@ -1762,12 +1762,12 @@ int evp_pkey_ctx_use_cached_data(EVP_PKEY_CTX *ctx)
return ret;
}
OPENSSL_CTX *evp_pkey_ctx_get0_libctx(EVP_PKEY_CTX *ctx)
OPENSSL_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(EVP_PKEY_CTX *ctx)
{
return ctx->propquery;
}

View File

@ -0,0 +1,45 @@
=pod
=head1 NAME
EVP_PKEY_CTX_get0_libctx,
EVP_PKEY_CTX_get0_propq
- functions for getting OPENSSL_CTX and property query data from an EVP_PKEY_CTX
=head1 SYNOPSIS
#include <openssl/evp.h>
OPENSSL_CTX *EVP_PKEY_CTX_get0_libctx(EVP_PKEY_CTX *ctx);
const char *EVP_PKEY_CTX_get0_propq(EVP_PKEY_CTX *ctx);
=head1 DESCRIPTION
The EVP_PKEY_CTX_get0_libctx() and EVP_PKEY_CTX_get0_propq() functions obtain
the OPENSSL_CTX and property query string values respectively that were
associated with the EVP_PKEY_CTX when it was constructed.
=head1 RETURN VALUES
EVP_PKEY_CTX_get0_libctx() and EVP_PKEY_CTX_get0_propq() functions return the
OPENSSL_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.
=head1 SEE ALSO
L<EVP_PKEY_CTX_new(3)>
=head1 HISTORY
All functions were added in OpenSSL 3.0.
=head1 COPYRIGHT
Copyright 2020 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
in the file LICENSE in the source distribution or at
L<https://www.openssl.org/source/license.html>.
=cut

View File

@ -835,8 +835,6 @@ int evp_pkey_ctx_get1_id_len_prov(EVP_PKEY_CTX *ctx, size_t *id_len);
int evp_pkey_ctx_use_cached_data(EVP_PKEY_CTX *ctx);
#endif /* !defined(FIPS_MODULE) */
OPENSSL_CTX *evp_pkey_ctx_get0_libctx(EVP_PKEY_CTX *ctx);
const char *evp_pkey_ctx_get0_propq(EVP_PKEY_CTX *ctx);
void evp_method_store_flush(OPENSSL_CTX *libctx);
int evp_set_default_properties_int(OPENSSL_CTX *libctx, const char *propq,
int loadconfig);

View File

@ -1966,6 +1966,9 @@ int EVP_hex2ctrl(int (*cb)(void *ctx, int cmd, void *buf, size_t buflen),
int EVP_PKEY_CTX_set_group_name(EVP_PKEY_CTX *ctx, const char *name);
int EVP_PKEY_CTX_get_group_name(EVP_PKEY_CTX *ctx, char *name, size_t namelen);
OPENSSL_CTX *EVP_PKEY_CTX_get0_libctx(EVP_PKEY_CTX *ctx);
const char *EVP_PKEY_CTX_get0_propq(EVP_PKEY_CTX *ctx);
# ifdef __cplusplus
}
# endif

View File

@ -5288,3 +5288,5 @@ PKCS7_type_is_other ? 3_0_0 EXIST::FUNCTION:
PKCS7_get_octet_string ? 3_0_0 EXIST::FUNCTION:
OSSL_DECODER_from_data ? 3_0_0 EXIST::FUNCTION:
OSSL_ENCODER_to_data ? 3_0_0 EXIST::FUNCTION:
EVP_PKEY_CTX_get0_libctx ? 3_0_0 EXIST::FUNCTION:
EVP_PKEY_CTX_get0_propq ? 3_0_0 EXIST::FUNCTION: