Update copyright year
[openssl.git] / doc / man3 / EVP_PKEY_gettable_params.pod
1 =pod
2
3 =head1 NAME
4
5 EVP_PKEY_gettable_params, EVP_PKEY_get_params,
6 EVP_PKEY_get_int_param, EVP_PKEY_get_size_t_param,
7 EVP_PKEY_get_bn_param, EVP_PKEY_get_utf8_string_param,
8 EVP_PKEY_get_octet_string_param
9 - retrieve key parameters from a key
10
11 =head1 SYNOPSIS
12
13  #include <openssl/evp.h>
14
15  const OSSL_PARAM *EVP_PKEY_gettable_params(EVP_PKEY *pkey);
16  int EVP_PKEY_get_params(const EVP_PKEY *pkey, OSSL_PARAM params[]);
17  int EVP_PKEY_get_int_param(const EVP_PKEY *pkey, const char *key_name,
18                             int *out);
19  int EVP_PKEY_get_size_t_param(const EVP_PKEY *pkey, const char *key_name,
20                                size_t *out);
21  int EVP_PKEY_get_bn_param(const EVP_PKEY *pkey, const char *key_name,
22                            BIGNUM **bn);
23  int EVP_PKEY_get_utf8_string_param(const EVP_PKEY *pkey, const char *key_name,
24                                     char *str, size_t max_buf_sz,
25                                     size_t *out_sz);
26  int EVP_PKEY_get_octet_string_param(const EVP_PKEY *pkey, const char *key_name,
27                                      unsigned char *buf, size_t max_buf_sz,
28                                      size_t *out_sz);
29
30 =head1 DESCRIPTION
31
32 EVP_PKEY_get_params() retrieves parameters from the key I<pkey>, according to
33 the contents of I<params>.
34 See L<OSSL_PARAM(3)> for information about parameters.
35
36 EVP_PKEY_gettable_params() returns a constant list of I<params> indicating
37 the names and types of key parameters that can be retrieved.
38 See L<OSSL_PARAM(3)> for information about parameters.
39
40 EVP_PKEY_get_int_param() retrieves a key I<pkey> integer value I<*out>
41 associated with a name of I<key_name>.
42
43 EVP_PKEY_get_size_t_param() retrieves a key I<pkey> size_t value I<*out>
44 associated with a name of I<key_name>.
45
46 EVP_PKEY_get_bn_param() retrieves a key I<pkey> BIGNUM value I<**bn>
47 associated with a name of I<key_name>. If I<*bn> is NULL then the BIGNUM
48 is allocated by the method.
49
50 EVP_PKEY_get_utf8_string_param() get a key I<pkey> UTF8 string value int a buffer
51 I<str> of maximum size I<max_buf_sz> associated with a name of I<key_name>.
52 I<*out_sz> is the returned size of the string if it is not NULL.
53
54 EVP_PKEY_get_octet_string_param() copy a I<pkey>'s octet string value into a buffer
55 I<buf> of maximum size I<max_buf_sz> associated with a name of I<key_name>.
56 I<*out_sz> is the returned size of the buffer if it is not NULL.
57
58 =head1 NOTES
59
60 These functions only work for B<EVP_PKEY>s that contain a provider side key.
61
62 =head1 RETURN VALUES
63
64 EVP_PKEY_gettable_params() returns NULL on error or if it is not supported,
65
66 All other methods return 1 if a value associated with the key's I<key_name> was
67 successfully returned, or 0 if there was an error.
68 An error may be returned by methods EVP_PKEY_get_utf8_string_param() and
69 EVP_PKEY_get_octet_string_param() if I<max_buf_sz> is not big enough to hold the
70 value.  If I<out_sz> is not NULL, I<*out_sz> will be assigned the required
71 buffer size to hold the value.
72
73 =head1 EXAMPLES
74
75  #include <openssl/evp.h>
76
77  char *curve_name[64];
78  unsigned char pub[256];
79  BIGNUM *bn_priv = NULL;
80
81  /*
82   * NB: assumes 'key' is set up before the next step. In this example the key
83   * is an EC key.
84   */
85
86  if (!EVP_PKEY_get_utf8_string_param(key, OSSL_PKEY_PARAM_GROUP_NAME,
87                                      curve_name, sizeof(curve_name), &len)) {
88    /* Error */
89  }
90  if (!EVP_PKEY_get_octet_string_param(key, OSSL_PKEY_PARAM_PUB_KEY,
91                                       pub, sizeof(pub), &len)) {
92      /* Error */
93  }
94  if (!EVP_PKEY_get_bn_param(key, OSSL_PKEY_PARAM_PRIV_KEY, &bn_priv)) {
95      /* Error */
96  }
97
98
99  BN_clear_free(bn_priv);
100
101 =head1 SEE ALSO
102
103 L<EVP_PKEY_CTX_new(3)>, L<provider-keymgmt(7)>, L<OSSL_PARAM(3)>
104
105 =head1 HISTORY
106
107 These functions were added in OpenSSL 3.0.
108
109 =head1 COPYRIGHT
110
111 Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
112
113 Licensed under the Apache License 2.0 (the "License").  You may not use
114 this file except in compliance with the License.  You can obtain a copy
115 in the file LICENSE in the source distribution or at
116 L<https://www.openssl.org/source/license.html>.
117
118 =cut
119