1e71b7053SJung-uk Kim=pod 2e71b7053SJung-uk Kim 3e71b7053SJung-uk Kim=head1 NAME 4e71b7053SJung-uk Kim 5*b077aed3SPierre ProncheryEVP_PKEY_CTX_new, EVP_PKEY_CTX_new_id, EVP_PKEY_CTX_new_from_name, 6*b077aed3SPierre ProncheryEVP_PKEY_CTX_new_from_pkey, EVP_PKEY_CTX_dup, EVP_PKEY_CTX_free, 7*b077aed3SPierre ProncheryEVP_PKEY_CTX_is_a 8*b077aed3SPierre Pronchery- public key algorithm context functions 9e71b7053SJung-uk Kim 10e71b7053SJung-uk Kim=head1 SYNOPSIS 11e71b7053SJung-uk Kim 12e71b7053SJung-uk Kim #include <openssl/evp.h> 13e71b7053SJung-uk Kim 14e71b7053SJung-uk Kim EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e); 15e71b7053SJung-uk Kim EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e); 16*b077aed3SPierre Pronchery EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_name(OSSL_LIB_CTX *libctx, 17*b077aed3SPierre Pronchery const char *name, 18*b077aed3SPierre Pronchery const char *propquery); 19*b077aed3SPierre Pronchery EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_pkey(OSSL_LIB_CTX *libctx, 20*b077aed3SPierre Pronchery EVP_PKEY *pkey, 21*b077aed3SPierre Pronchery const char *propquery); 22*b077aed3SPierre Pronchery EVP_PKEY_CTX *EVP_PKEY_CTX_dup(const EVP_PKEY_CTX *ctx); 23e71b7053SJung-uk Kim void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx); 24*b077aed3SPierre Pronchery int EVP_PKEY_CTX_is_a(EVP_PKEY_CTX *ctx, const char *keytype); 25e71b7053SJung-uk Kim 26e71b7053SJung-uk Kim=head1 DESCRIPTION 27e71b7053SJung-uk Kim 28e71b7053SJung-uk KimThe EVP_PKEY_CTX_new() function allocates public key algorithm context using 29*b077aed3SPierre Proncherythe I<pkey> key type and ENGINE I<e>. 30e71b7053SJung-uk Kim 31e71b7053SJung-uk KimThe EVP_PKEY_CTX_new_id() function allocates public key algorithm context 32*b077aed3SPierre Proncheryusing the key type specified by I<id> and ENGINE I<e>. 33e71b7053SJung-uk Kim 34*b077aed3SPierre ProncheryThe EVP_PKEY_CTX_new_from_name() function allocates a public key algorithm 35*b077aed3SPierre Proncherycontext using the library context I<libctx> (see L<OSSL_LIB_CTX(3)>), the 36*b077aed3SPierre Proncherykey type specified by I<name> and the property query I<propquery>. None 37*b077aed3SPierre Proncheryof the arguments are duplicated, so they must remain unchanged for the 38*b077aed3SPierre Proncherylifetime of the returned B<EVP_PKEY_CTX> or of any of its duplicates. Read 39*b077aed3SPierre Proncheryfurther about the possible names in L</NOTES> below. 40e71b7053SJung-uk Kim 41*b077aed3SPierre ProncheryThe EVP_PKEY_CTX_new_from_pkey() function allocates a public key algorithm 42*b077aed3SPierre Proncherycontext using the library context I<libctx> (see L<OSSL_LIB_CTX(3)>) and the 43*b077aed3SPierre Proncheryalgorithm specified by I<pkey> and the property query I<propquery>. None of the 44*b077aed3SPierre Proncheryarguments are duplicated, so they must remain unchanged for the lifetime of the 45*b077aed3SPierre Proncheryreturned B<EVP_PKEY_CTX> or any of its duplicates. 46*b077aed3SPierre Pronchery 47*b077aed3SPierre ProncheryEVP_PKEY_CTX_new_id() and EVP_PKEY_CTX_new_from_name() are normally 48*b077aed3SPierre Proncheryused when no B<EVP_PKEY> structure is associated with the operations, 49*b077aed3SPierre Proncheryfor example during parameter generation or key generation for some 50*b077aed3SPierre Proncheryalgorithms. 51*b077aed3SPierre Pronchery 52*b077aed3SPierre ProncheryEVP_PKEY_CTX_dup() duplicates the context I<ctx>. It is not supported for a 53*b077aed3SPierre Proncherykeygen operation. 54*b077aed3SPierre Pronchery 55*b077aed3SPierre ProncheryEVP_PKEY_CTX_free() frees up the context I<ctx>. 56*b077aed3SPierre ProncheryIf I<ctx> is NULL, nothing is done. 57*b077aed3SPierre Pronchery 58*b077aed3SPierre ProncheryEVP_PKEY_is_a() checks if the key type associated with I<ctx> is I<keytype>. 59e71b7053SJung-uk Kim 60e71b7053SJung-uk Kim=head1 NOTES 61e71b7053SJung-uk Kim 62*b077aed3SPierre Pronchery=head2 On B<EVP_PKEY_CTX> 63*b077aed3SPierre Pronchery 64e71b7053SJung-uk KimThe B<EVP_PKEY_CTX> structure is an opaque public key algorithm context used 6558f35182SJung-uk Kimby the OpenSSL high-level public key API. Contexts B<MUST NOT> be shared between 66e71b7053SJung-uk Kimthreads: that is it is not permissible to use the same context simultaneously 67e71b7053SJung-uk Kimin two threads. 68e71b7053SJung-uk Kim 69*b077aed3SPierre Pronchery=head2 On Key Types 70*b077aed3SPierre Pronchery 71*b077aed3SPierre ProncheryWe mention "key type" in this manual, which is the same 72*b077aed3SPierre Proncheryas "algorithm" in most cases, allowing either term to be used 73*b077aed3SPierre Proncheryinterchangeably. There are algorithms where the I<key type> and the 74*b077aed3SPierre ProncheryI<algorithm> of the operations that use the keys are not the same, 75*b077aed3SPierre Proncherysuch as EC keys being used for ECDSA and ECDH operations. 76*b077aed3SPierre Pronchery 77*b077aed3SPierre ProncheryKey types are given in two different manners: 78*b077aed3SPierre Pronchery 79*b077aed3SPierre Pronchery=over 4 80*b077aed3SPierre Pronchery 81*b077aed3SPierre Pronchery=item Legacy NID or EVP_PKEY type 82*b077aed3SPierre Pronchery 83*b077aed3SPierre ProncheryThis is the I<id> used with EVP_PKEY_CTX_new_id(). 84*b077aed3SPierre Pronchery 85*b077aed3SPierre ProncheryThese are B<EVP_PKEY_RSA>, B<EVP_PKEY_RSA_PSS>, B<EVP_PKEY_DSA>, 86*b077aed3SPierre ProncheryB<EVP_PKEY_DH>, B<EVP_PKEY_EC>, B<EVP_PKEY_SM2>, B<EVP_PKEY_X25519>, 87*b077aed3SPierre ProncheryB<EVP_PKEY_X448>, and are used by legacy methods. 88*b077aed3SPierre Pronchery 89*b077aed3SPierre Pronchery=item Name strings 90*b077aed3SPierre Pronchery 91*b077aed3SPierre ProncheryThis is the I<name> used with EVP_PKEY_CTX_new_from_name(). 92*b077aed3SPierre Pronchery 93*b077aed3SPierre ProncheryThese are names like "RSA", "DSA", and what's available depends on what 94*b077aed3SPierre Proncheryproviders are currently accessible. 95*b077aed3SPierre Pronchery 96*b077aed3SPierre ProncheryThe OpenSSL providers offer a set of key types available this way, please 97*b077aed3SPierre Proncherysee L<OSSL_PROVIDER-FIPS(7)> and L<OSSL_PROVIDER-default(7)> and related 98*b077aed3SPierre Proncherydocumentation for more information. 99*b077aed3SPierre Pronchery 100*b077aed3SPierre Pronchery=back 101*b077aed3SPierre Pronchery 102e71b7053SJung-uk Kim=head1 RETURN VALUES 103e71b7053SJung-uk Kim 104*b077aed3SPierre ProncheryEVP_PKEY_CTX_new(), EVP_PKEY_CTX_new_id() and EVP_PKEY_CTX_dup() return either 105*b077aed3SPierre Proncherythe newly allocated B<EVP_PKEY_CTX> structure or B<NULL> if an error occurred. 106e71b7053SJung-uk Kim 107e71b7053SJung-uk KimEVP_PKEY_CTX_free() does not return a value. 108e71b7053SJung-uk Kim 109*b077aed3SPierre ProncheryEVP_PKEY_CTX_is_a() returns 1 for true and 0 for false. 110*b077aed3SPierre Pronchery 111e71b7053SJung-uk Kim=head1 SEE ALSO 112e71b7053SJung-uk Kim 113e71b7053SJung-uk KimL<EVP_PKEY_new(3)> 114e71b7053SJung-uk Kim 115e71b7053SJung-uk Kim=head1 HISTORY 116e71b7053SJung-uk Kim 117*b077aed3SPierre ProncheryThe EVP_PKEY_CTX_new(), EVP_PKEY_CTX_new_id(), EVP_PKEY_CTX_dup() and 118*b077aed3SPierre ProncheryEVP_PKEY_CTX_free() functions were added in OpenSSL 1.0.0. 119*b077aed3SPierre Pronchery 120*b077aed3SPierre ProncheryThe EVP_PKEY_CTX_new_from_name() and EVP_PKEY_CTX_new_from_pkey() functions were 121*b077aed3SPierre Proncheryadded in OpenSSL 3.0. 122e71b7053SJung-uk Kim 123e71b7053SJung-uk Kim=head1 COPYRIGHT 124e71b7053SJung-uk Kim 125*b077aed3SPierre ProncheryCopyright 2006-2021 The OpenSSL Project Authors. All Rights Reserved. 126e71b7053SJung-uk Kim 127*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 128e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 129e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 130e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 131e71b7053SJung-uk Kim 132e71b7053SJung-uk Kim=cut 133