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