1 1.1 christos =pod 2 1.1 christos 3 1.1 christos =head1 NAME 4 1.1 christos 5 1.1 christos EVP_KEYMGMT, 6 1.1 christos EVP_KEYMGMT_fetch, 7 1.1 christos EVP_KEYMGMT_up_ref, 8 1.1 christos EVP_KEYMGMT_free, 9 1.1 christos EVP_KEYMGMT_get0_provider, 10 1.1 christos EVP_KEYMGMT_is_a, 11 1.1 christos EVP_KEYMGMT_get0_description, 12 1.1 christos EVP_KEYMGMT_get0_name, 13 1.1 christos EVP_KEYMGMT_do_all_provided, 14 1.1 christos EVP_KEYMGMT_names_do_all, 15 1.1 christos EVP_KEYMGMT_gettable_params, 16 1.1 christos EVP_KEYMGMT_settable_params, 17 1.1 christos EVP_KEYMGMT_gen_settable_params 18 1.1 christos - EVP key management routines 19 1.1 christos 20 1.1 christos =head1 SYNOPSIS 21 1.1 christos 22 1.1 christos #include <openssl/evp.h> 23 1.1 christos 24 1.1 christos typedef struct evp_keymgmt_st EVP_KEYMGMT; 25 1.1 christos 26 1.1 christos EVP_KEYMGMT *EVP_KEYMGMT_fetch(OSSL_LIB_CTX *ctx, const char *algorithm, 27 1.1 christos const char *properties); 28 1.1 christos int EVP_KEYMGMT_up_ref(EVP_KEYMGMT *keymgmt); 29 1.1 christos void EVP_KEYMGMT_free(EVP_KEYMGMT *keymgmt); 30 1.1 christos const OSSL_PROVIDER *EVP_KEYMGMT_get0_provider(const EVP_KEYMGMT *keymgmt); 31 1.1 christos int EVP_KEYMGMT_is_a(const EVP_KEYMGMT *keymgmt, const char *name); 32 1.1 christos const char *EVP_KEYMGMT_get0_name(const EVP_KEYMGMT *keymgmt); 33 1.1 christos const char *EVP_KEYMGMT_get0_description(const EVP_KEYMGMT *keymgmt); 34 1.1 christos 35 1.1 christos void EVP_KEYMGMT_do_all_provided(OSSL_LIB_CTX *libctx, 36 1.1 christos void (*fn)(EVP_KEYMGMT *keymgmt, void *arg), 37 1.1 christos void *arg); 38 1.1 christos int EVP_KEYMGMT_names_do_all(const EVP_KEYMGMT *keymgmt, 39 1.1 christos void (*fn)(const char *name, void *data), 40 1.1 christos void *data); 41 1.1 christos const OSSL_PARAM *EVP_KEYMGMT_gettable_params(const EVP_KEYMGMT *keymgmt); 42 1.1 christos const OSSL_PARAM *EVP_KEYMGMT_settable_params(const EVP_KEYMGMT *keymgmt); 43 1.1 christos const OSSL_PARAM *EVP_KEYMGMT_gen_settable_params(const EVP_KEYMGMT *keymgmt); 44 1.1 christos 45 1.1 christos =head1 DESCRIPTION 46 1.1 christos 47 1.1 christos B<EVP_KEYMGMT> is a method object that represents key management 48 1.1 christos implementations for different cryptographic algorithms. 49 1.1 christos This method object provides functionality to have providers import key 50 1.1 christos material from the outside, as well as export key material to the 51 1.1 christos outside. 52 1.1 christos Most of the functionality can only be used internally and has no 53 1.1 christos public interface, this object is simply passed into other functions 54 1.1 christos when needed. 55 1.1 christos 56 1.1 christos EVP_KEYMGMT_fetch() looks for an algorithm within the provider that 57 1.1 christos has been loaded into the B<OSSL_LIB_CTX> given by I<ctx>, having the 58 1.1 christos name given by I<algorithm> and the properties given by I<properties>. 59 1.1 christos 60 1.1 christos EVP_KEYMGMT_up_ref() increments the reference count for the given 61 1.1 christos B<EVP_KEYMGMT> I<keymgmt>. 62 1.1 christos 63 1.1 christos EVP_KEYMGMT_free() decrements the reference count for the given 64 1.1 christos B<EVP_KEYMGMT> I<keymgmt>, and when the count reaches zero, frees it. 65 1.1.1.3 christos If the argument is NULL, nothing is done. 66 1.1 christos 67 1.1 christos EVP_KEYMGMT_get0_provider() returns the provider that has this particular 68 1.1 christos implementation. 69 1.1 christos 70 1.1 christos EVP_KEYMGMT_is_a() checks if I<keymgmt> is an implementation of an 71 1.1 christos algorithm that's identifiable with I<name>. 72 1.1 christos 73 1.1 christos EVP_KEYMGMT_get0_name() returns the algorithm name from the provided 74 1.1 christos implementation for the given I<keymgmt>. Note that the I<keymgmt> may have 75 1.1 christos multiple synonyms associated with it. In this case the first name from the 76 1.1 christos algorithm definition is returned. Ownership of the returned string is 77 1.1 christos retained by the I<keymgmt> object and should not be freed by the caller. 78 1.1 christos 79 1.1 christos EVP_KEYMGMT_names_do_all() traverses all names for the I<keymgmt>, and 80 1.1 christos calls I<fn> with each name and I<data>. 81 1.1 christos 82 1.1 christos EVP_KEYMGMT_get0_description() returns a description of the I<keymgmt>, meant 83 1.1 christos for display and human consumption. The description is at the discretion 84 1.1 christos of the I<keymgmt> implementation. 85 1.1 christos 86 1.1 christos EVP_KEYMGMT_do_all_provided() traverses all key keymgmt implementations by 87 1.1 christos all activated providers in the library context I<libctx>, and for each 88 1.1 christos of the implementations, calls I<fn> with the implementation method and 89 1.1 christos I<data> as arguments. 90 1.1 christos 91 1.1 christos EVP_KEYMGMT_gettable_params() and EVP_KEYMGMT_settable_params() return a 92 1.1 christos constant L<OSSL_PARAM(3)> array that describes the names and types of key 93 1.1 christos parameters that can be retrieved or set. 94 1.1 christos EVP_KEYMGMT_gettable_params() is used by L<EVP_PKEY_gettable_params(3)>. 95 1.1 christos 96 1.1 christos EVP_KEYMGMT_gen_settable_params() returns a constant L<OSSL_PARAM(3)> array that 97 1.1 christos describes the names and types of key generation parameters that can be set via 98 1.1 christos L<EVP_PKEY_CTX_set_params(3)>. 99 1.1 christos 100 1.1 christos =head1 NOTES 101 1.1 christos 102 1.1 christos EVP_KEYMGMT_fetch() may be called implicitly by other fetching 103 1.1 christos functions, using the same library context and properties. 104 1.1 christos Any other API that uses keys will typically do this. 105 1.1 christos 106 1.1 christos =head1 RETURN VALUES 107 1.1 christos 108 1.1 christos EVP_KEYMGMT_fetch() returns a pointer to the key management 109 1.1 christos implementation represented by an EVP_KEYMGMT object, or NULL on 110 1.1 christos error. 111 1.1 christos 112 1.1 christos EVP_KEYMGMT_up_ref() returns 1 on success, or 0 on error. 113 1.1 christos 114 1.1 christos EVP_KEYMGMT_names_do_all() returns 1 if the callback was called for all 115 1.1 christos names. A return value of 0 means that the callback was not called for any names. 116 1.1 christos 117 1.1 christos EVP_KEYMGMT_free() doesn't return any value. 118 1.1 christos 119 1.1 christos EVP_KEYMGMT_get0_provider() returns a pointer to a provider object, or NULL 120 1.1 christos on error. 121 1.1 christos 122 1.1 christos EVP_KEYMGMT_is_a() returns 1 of I<keymgmt> was identifiable, 123 1.1 christos otherwise 0. 124 1.1 christos 125 1.1 christos EVP_KEYMGMT_get0_name() returns the algorithm name, or NULL on error. 126 1.1 christos 127 1.1.1.2 christos EVP_KEYMGMT_get0_description() returns a pointer to a description, or NULL if 128 1.1 christos there isn't one. 129 1.1 christos 130 1.1 christos EVP_KEYMGMT_gettable_params(), EVP_KEYMGMT_settable_params() and 131 1.1 christos EVP_KEYMGMT_gen_settable_params() return a constant L<OSSL_PARAM(3)> array or 132 1.1 christos NULL on error. 133 1.1 christos 134 1.1 christos =head1 SEE ALSO 135 1.1 christos 136 1.1 christos L<EVP_MD_fetch(3)>, L<OSSL_LIB_CTX(3)> 137 1.1 christos 138 1.1 christos =head1 HISTORY 139 1.1 christos 140 1.1 christos The functions described here were added in OpenSSL 3.0. 141 1.1 christos 142 1.1 christos =head1 COPYRIGHT 143 1.1 christos 144 1.1.1.3 christos Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved. 145 1.1 christos 146 1.1 christos Licensed under the Apache License 2.0 (the "License"). You may not use 147 1.1 christos this file except in compliance with the License. You can obtain a copy 148 1.1 christos in the file LICENSE in the source distribution or at 149 1.1 christos L<https://www.openssl.org/source/license.html>. 150 1.1 christos 151 1.1 christos =cut 152