Fix for OSSL_PARAM sample code referencing OSSL_PARAM_UTF8_PTR

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18490)
This commit is contained in:
Michael Baentsch 2022-06-07 08:28:26 +02:00 committed by Tomas Mraz
parent 6d702cebfc
commit 809526a06c
4 changed files with 17 additions and 14 deletions

View File

@ -309,8 +309,8 @@ This example is for setting parameters on some object:
size_t foo_l = strlen(foo);
const char bar[] = "some other string";
OSSL_PARAM set[] = {
{ "foo", OSSL_PARAM_UTF8_STRING_PTR, &foo, foo_l, 0 },
{ "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar) - 1, 0 },
{ "foo", OSSL_PARAM_UTF8_PTR, &foo, foo_l, 0 },
{ "bar", OSSL_PARAM_UTF8_STRING, (void *)&bar, sizeof(bar) - 1, 0 },
{ NULL, 0, NULL, 0, 0 }
};
@ -323,7 +323,7 @@ This example is for requesting parameters on some object:
char bar[1024];
size_t bar_l;
OSSL_PARAM request[] = {
{ "foo", OSSL_PARAM_UTF8_STRING_PTR, &foo, 0 /*irrelevant*/, 0 },
{ "foo", OSSL_PARAM_UTF8_PTR, &foo, 0 /*irrelevant*/, 0 },
{ "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar), 0 },
{ NULL, 0, NULL, 0, 0 }
};

View File

@ -184,19 +184,22 @@ OSSL_PROVIDER_self_test() returns 1 if the self tests pass, or 0 on error.
=head1 EXAMPLES
This demonstrates how to load the provider module "foo" and ask for
its build number.
its build information.
#include <openssl/params.h>
#include <openssl/provider.h>
#include <openssl/err.h>
OSSL_PROVIDER *prov = NULL;
const char *build = NULL;
size_t built_l = 0;
OSSL_PARAM request[] = {
{ "build", OSSL_PARAM_UTF8_STRING_PTR, &build, 0, &build_l },
{ NULL, 0, NULL, 0, NULL }
{ "buildinfo", OSSL_PARAM_UTF8_PTR, &build, 0, 0 },
{ NULL, 0, NULL, 0, 0 }
};
if ((prov = OSSL_PROVIDER_load(NULL, "foo")) != NULL
&& OSSL_PROVIDER_get_params(prov, request))
printf("Provider 'foo' build %s\n", build);
printf("Provider 'foo' buildinfo: %s\n", build);
else
ERR_print_errors_fp(stderr);

View File

@ -416,17 +416,17 @@ provider_get_params() can return the following provider parameters to the core:
=over 4
=item "name" (B<OSSL_PROV_PARAM_NAME>) <UTF8 string ptr>
=item "name" (B<OSSL_PROV_PARAM_NAME>) <UTF8 ptr>
This points to a string that should give a unique name for the provider.
=item "version" (B<OSSL_PROV_PARAM_VERSION>) <UTF8 string ptr>
=item "version" (B<OSSL_PROV_PARAM_VERSION>) <UTF8 ptr>
This points to a string that is a version number associated with this provider.
OpenSSL in-built providers use OPENSSL_VERSION_STR, but this may be different
for any third party provider. This string is for informational purposes only.
=item "buildinfo" (B<OSSL_PROV_PARAM_BUILDINFO>) <UTF8 string ptr>
=item "buildinfo" (B<OSSL_PROV_PARAM_BUILDINFO>) <UTF8 ptr>
This points to a string that is a build information associated with this provider.
OpenSSL in-built providers use OPENSSL_FULL_VERSION_STR, but this may be

View File

@ -21,9 +21,9 @@ extern "C" {
#define OSSL_PROV_PARAM_CORE_MODULE_FILENAME "module-filename" /* utf8_ptr */
/* Well known parameter names that Providers can define */
#define OSSL_PROV_PARAM_NAME "name" /* utf8_string */
#define OSSL_PROV_PARAM_VERSION "version" /* utf8_string */
#define OSSL_PROV_PARAM_BUILDINFO "buildinfo" /* utf8_string */
#define OSSL_PROV_PARAM_NAME "name" /* utf8_ptr */
#define OSSL_PROV_PARAM_VERSION "version" /* utf8_ptr */
#define OSSL_PROV_PARAM_BUILDINFO "buildinfo" /* utf8_ptr */
#define OSSL_PROV_PARAM_STATUS "status" /* uint */
#define OSSL_PROV_PARAM_SECURITY_CHECKS "security-checks" /* uint */