diff options
author | Matt Caswell <matt@openssl.org> | 2021-11-05 08:43:10 +0000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-11-08 09:01:33 +1000 |
commit | 4ce64ed79d301939c7f2844a9e5e5fdd2033605f (patch) | |
tree | 5a90bde0af2198f7fc9747199643f5900812f3ec | |
parent | e6a10b074e90f1ce3d8e9ae0ca740a835ff29bb9 (diff) |
Fix errors in EVP_PKEY_fromdata examples
The EVP_PKEY_fromdata man page has some code examples with various
errors in them. This fixes those errors.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16973)
-rw-r--r-- | doc/man3/EVP_PKEY_fromdata.pod | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/doc/man3/EVP_PKEY_fromdata.pod b/doc/man3/EVP_PKEY_fromdata.pod index b968150bb6..fdab94cd4f 100644 --- a/doc/man3/EVP_PKEY_fromdata.pod +++ b/doc/man3/EVP_PKEY_fromdata.pod @@ -138,6 +138,7 @@ TODO Write a set of cookbook documents and link to them. #include <openssl/evp.h> #include <openssl/param_build.h> + #include <openssl/ec.h> /* * Fixed data to represent the private and public key. @@ -160,12 +161,6 @@ TODO Write a set of cookbook documents and link to them. 0x8f, 0xb9, 0x33, 0x6e, 0xcf, 0x12, 0x16, 0x2f, 0x5c, 0xcd, 0x86, 0x71, 0xa8, 0xbf, 0x1a, 0x47 }; - const OSSL_PARAM params[] = { - OSSL_PARAM_utf8_string("group", "prime256v1", 10), - OSSL_PARAM_BN("priv", priv, sizeof(priv)), - OSSL_PARAM_BN("pub", pub, sizeof(pub)), - OSSL_PARAM_END - }; int main() { @@ -181,15 +176,15 @@ TODO Write a set of cookbook documents and link to them. param_bld = OSSL_PARAM_BLD_new(); if (priv != NULL && param_bld != NULL && OSSL_PARAM_BLD_push_utf8_string(param_bld, "group", - "prime256v1", 0); - && OSSL_PARAM_BLD_push_BN(param_bld, "priv", priv); + "prime256v1", 0) + && OSSL_PARAM_BLD_push_BN(param_bld, "priv", priv) && OSSL_PARAM_BLD_push_octet_string(param_bld, "pub", pub_data, sizeof(pub_data))) params = OSSL_PARAM_BLD_to_param(param_bld); ctx = EVP_PKEY_CTX_new_from_name(NULL, "EC", NULL); if (ctx == NULL - || params != NULL + || params == NULL || EVP_PKEY_fromdata_init(ctx) <= 0 || EVP_PKEY_fromdata(ctx, &pkey, EVP_PKEY_KEYPAIR, params) <= 0) { exitcode = 1; @@ -209,12 +204,13 @@ TODO Write a set of cookbook documents and link to them. =head2 Finding out params for an unknown key type #include <openssl/evp.h> + #include <openssl/core.h> /* Program expects a key type as first argument */ int main(int argc, char *argv[]) { EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new_from_name(NULL, argv[1], NULL); - const *OSSL_PARAM *settable_params = NULL; + const OSSL_PARAM *settable_params = NULL; if (ctx == NULL) exit(1); @@ -247,9 +243,9 @@ TODO Write a set of cookbook documents and link to them. } printf("%s : %s ", settable_params->key, datatype); if (settable_params->data_size == 0) - printf("(unlimited size)"); + printf("(unlimited size)\n"); else - printf("(maximum size %zu)", settable_params->data_size); + printf("(maximum size %zu)\n", settable_params->data_size); } } |