| 
									
										
										
										
											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, | 
					
						
							|  |  |  | EVP_PKEY_CTX_new_from_pkey, EVP_PKEY_CTX_dup, EVP_PKEY_CTX_free | 
					
						
							| 
									
										
										
										
											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-01-12 09:32:12 +08:00
										 |  |  |  EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_name(OPENSSL_CTX *libctx, | 
					
						
							|  |  |  |                                           const char *name, | 
					
						
							|  |  |  |                                           const char *propquery); | 
					
						
							|  |  |  |  EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_pkey(OPENSSL_CTX *libctx, | 
					
						
							|  |  |  |                                           EVP_PKEY *pkey); | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =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 | 
					
						
							| 
									
										
										
										
											2019-11-01 23:56:31 +08:00
										 |  |  | context using the library context I<libctx> (see L<OPENSSL_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 | 
					
						
							|  |  |  | lifetime of the returned B<EVP_PKEY_CTX> or of any of its duplicates. | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  | context using the library context I<libctx> (see L<OPENSSL_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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-15 22:55:00 +08:00
										 |  |  | EVP_PKEY_CTX_dup() duplicates the context I<ctx>. | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							|  |  |  | =head1 NOTES | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-18 20:24:27 +08:00
										 |  |  | =over 4 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =item 1. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | The B<EVP_PKEY_CTX> structure is an opaque public key algorithm context used | 
					
						
							|  |  |  | by the OpenSSL high level public key API. Contexts B<MUST NOT> be shared between | 
					
						
							|  |  |  | threads: that is it is not permissible to use the same context simultaneously | 
					
						
							|  |  |  | in two threads. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-18 20:24:27 +08:00
										 |  |  | =item 2. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 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. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =back | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-08 18:45:08 +08:00
										 |  |  | =head1 RETURN VALUES | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | EVP_PKEY_CTX_new(), EVP_PKEY_CTX_new_id(), EVP_PKEY_CTX_dup() returns either | 
					
						
							|  |  |  | the newly allocated B<EVP_PKEY_CTX> structure of B<NULL> if an error occurred. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | EVP_PKEY_CTX_free() does not return a value. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =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 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 |