| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | =pod | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =head1 NAME | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-12 09:32:12 +08:00
										 |  |  | EVP_PKEY_CTX_new, EVP_PKEY_CTX_new_id, EVP_PKEY_CTX_new_from_name, | 
					
						
							| 
									
										
										
										
											2021-02-10 23:55:19 +08:00
										 |  |  | EVP_PKEY_CTX_new_from_pkey, EVP_PKEY_CTX_dup, EVP_PKEY_CTX_free, | 
					
						
							|  |  |  | EVP_PKEY_CTX_is_a | 
					
						
							| 
									
										
										
										
											2019-10-15 19:08:17 +08:00
										 |  |  | - public key algorithm context functions | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | =head1 SYNOPSIS | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  #include <openssl/evp.h> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e); | 
					
						
							|  |  |  |  EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e); | 
					
						
							| 
									
										
										
										
											2020-10-15 17:55:50 +08:00
										 |  |  |  EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_name(OSSL_LIB_CTX *libctx, | 
					
						
							| 
									
										
										
										
											2020-01-12 09:32:12 +08:00
										 |  |  |                                           const char *name, | 
					
						
							|  |  |  |                                           const char *propquery); | 
					
						
							| 
									
										
										
										
											2020-10-15 17:55:50 +08:00
										 |  |  |  EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_pkey(OSSL_LIB_CTX *libctx, | 
					
						
							| 
									
										
										
										
											2020-06-03 12:28:06 +08:00
										 |  |  |                                           EVP_PKEY *pkey, | 
					
						
							|  |  |  |                                           const char *propquery); | 
					
						
							| 
									
										
										
										
											2019-01-16 04:51:25 +08:00
										 |  |  |  EVP_PKEY_CTX *EVP_PKEY_CTX_dup(const EVP_PKEY_CTX *ctx); | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  |  void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx); | 
					
						
							| 
									
										
										
										
											2021-02-10 23:55:19 +08:00
										 |  |  |  int EVP_PKEY_CTX_is_a(EVP_PKEY_CTX *ctx, const char *keytype); | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | =head1 DESCRIPTION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The EVP_PKEY_CTX_new() function allocates public key algorithm context using | 
					
						
							| 
									
										
										
										
											2019-12-18 20:24:27 +08:00
										 |  |  | the I<pkey> key type and ENGINE I<e>. | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | The EVP_PKEY_CTX_new_id() function allocates public key algorithm context | 
					
						
							| 
									
										
										
										
											2019-12-18 20:24:27 +08:00
										 |  |  | using the key type specified by I<id> and ENGINE I<e>. | 
					
						
							| 
									
										
										
										
											2019-10-15 19:08:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-12 09:32:12 +08:00
										 |  |  | The EVP_PKEY_CTX_new_from_name() function allocates a public key algorithm | 
					
						
							| 
									
										
										
										
											2020-10-15 17:55:50 +08:00
										 |  |  | context using the library context I<libctx> (see L<OSSL_LIB_CTX(3)>), the | 
					
						
							| 
									
										
										
										
											2019-12-18 20:24:27 +08:00
										 |  |  | key type specified by I<name> and the property query I<propquery>.  None | 
					
						
							| 
									
										
										
										
											2019-11-01 23:56:31 +08:00
										 |  |  | of the arguments are duplicated, so they  must remain unchanged for the | 
					
						
							| 
									
										
										
										
											2020-03-06 21:55:49 +08:00
										 |  |  | lifetime of the returned B<EVP_PKEY_CTX> or of any of its duplicates.  Read | 
					
						
							|  |  |  | further about the possible names in L</NOTES> below. | 
					
						
							| 
									
										
										
										
											2019-10-15 19:08:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-12 09:32:12 +08:00
										 |  |  | The EVP_PKEY_CTX_new_from_pkey() function allocates a public key algorithm | 
					
						
							| 
									
										
										
										
											2020-10-15 17:55:50 +08:00
										 |  |  | context using the library context I<libctx> (see L<OSSL_LIB_CTX(3)>) and the | 
					
						
							| 
									
										
										
										
											2020-01-15 19:10:43 +08:00
										 |  |  | algorithm specified by I<pkey> and the property query I<propquery>. None of the | 
					
						
							|  |  |  | arguments are duplicated, so they must remain unchanged for the lifetime of the | 
					
						
							|  |  |  | returned B<EVP_PKEY_CTX> or any of its duplicates. | 
					
						
							| 
									
										
										
										
											2020-01-12 09:32:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | EVP_PKEY_CTX_new_id() and EVP_PKEY_CTX_new_from_name() are normally | 
					
						
							| 
									
										
										
										
											2019-10-15 19:08:17 +08:00
										 |  |  | used when no B<EVP_PKEY> structure is associated with the operations, | 
					
						
							|  |  |  | for example during parameter generation or key generation for some | 
					
						
							|  |  |  | algorithms. | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-25 13:21:52 +08:00
										 |  |  | EVP_PKEY_CTX_dup() duplicates the context I<ctx>. It is not supported for a | 
					
						
							|  |  |  | keygen operation. | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-15 22:55:00 +08:00
										 |  |  | EVP_PKEY_CTX_free() frees up the context I<ctx>. | 
					
						
							|  |  |  | If I<ctx> is NULL, nothing is done. | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-10 23:55:19 +08:00
										 |  |  | EVP_PKEY_is_a() checks if the key type associated with I<ctx> is I<keytype>. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | =head1 NOTES | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-06 21:55:49 +08:00
										 |  |  | =head2 On B<EVP_PKEY_CTX> | 
					
						
							| 
									
										
										
										
											2019-12-18 20:24:27 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | The B<EVP_PKEY_CTX> structure is an opaque public key algorithm context used | 
					
						
							| 
									
										
										
										
											2020-06-30 03:13:07 +08:00
										 |  |  | by the OpenSSL high-level public key API. Contexts B<MUST NOT> be shared between | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | threads: that is it is not permissible to use the same context simultaneously | 
					
						
							|  |  |  | in two threads. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-06 21:55:49 +08:00
										 |  |  | =head2 On Key Types | 
					
						
							| 
									
										
										
										
											2019-12-18 20:24:27 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | We mention "key type" in this manual, which is the same | 
					
						
							|  |  |  | as "algorithm" in most cases, allowing either term to be used | 
					
						
							|  |  |  | interchangeably.  There are algorithms where the I<key type> and the | 
					
						
							|  |  |  | I<algorithm> of the operations that use the keys are not the same, | 
					
						
							|  |  |  | such as EC keys being used for ECDSA and ECDH operations. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-06 21:55:49 +08:00
										 |  |  | Key types are given in two different manners: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =over 4 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =item Legacy NID or EVP_PKEY type | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This is the I<id> used with EVP_PKEY_CTX_new_id(). | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | These are B<EVP_PKEY_RSA>, B<EVP_PKEY_RSA_PSS>, B<EVP_PKEY_DSA>, | 
					
						
							|  |  |  | B<EVP_PKEY_DH>, B<EVP_PKEY_EC>, B<EVP_PKEY_SM2>, B<EVP_PKEY_X25519>, | 
					
						
							|  |  |  | B<EVP_PKEY_X448>, and are used by legacy methods. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =item Name strings | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This is the I<name> used with EVP_PKEY_CTX_new_from_name(). | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | These are names like "RSA", "DSA", and what's available depends on what | 
					
						
							|  |  |  | providers are currently accessible. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The OpenSSL providers offer a set of key types available this way, please | 
					
						
							|  |  |  | see L<OSSL_PROVIDER-FIPS(7)> and L<OSSL_PROVIDER-default(7)> and related | 
					
						
							|  |  |  | documentation for more information. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-18 20:24:27 +08:00
										 |  |  | =back | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | =head1 RETURN VALUES | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-25 13:21:52 +08:00
										 |  |  | EVP_PKEY_CTX_new(), EVP_PKEY_CTX_new_id() and EVP_PKEY_CTX_dup() return either | 
					
						
							| 
									
										
										
										
											2020-06-18 16:09:04 +08:00
										 |  |  | the newly allocated B<EVP_PKEY_CTX> structure or B<NULL> if an error occurred. | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | EVP_PKEY_CTX_free() does not return a value. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-10 23:55:19 +08:00
										 |  |  | EVP_PKEY_CTX_is_a() returns 1 for true and 0 for false. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | =head1 SEE ALSO | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-18 03:21:33 +08:00
										 |  |  | L<EVP_PKEY_new(3)> | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | =head1 HISTORY | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-12 09:32:12 +08:00
										 |  |  | The EVP_PKEY_CTX_new(), EVP_PKEY_CTX_new_id(), EVP_PKEY_CTX_dup() and | 
					
						
							|  |  |  | EVP_PKEY_CTX_free() functions were added in OpenSSL 1.0.0. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The EVP_PKEY_CTX_new_from_name() and EVP_PKEY_CTX_new_from_pkey() functions were | 
					
						
							|  |  |  | added in OpenSSL 3.0. | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-18 23:44:05 +08:00
										 |  |  | =head1 COPYRIGHT | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-11 21:27:36 +08:00
										 |  |  | Copyright 2006-2021 The OpenSSL Project Authors. All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2016-05-18 23:44:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-06 21:04:44 +08:00
										 |  |  | Licensed under the Apache License 2.0 (the "License").  You may not use | 
					
						
							| 
									
										
										
										
											2016-05-18 23:44:05 +08:00
										 |  |  | this file except in compliance with the License.  You can obtain a copy | 
					
						
							|  |  |  | in the file LICENSE in the source distribution or at | 
					
						
							|  |  |  | L<https://www.openssl.org/source/license.html>. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =cut |