1.\" $OpenBSD: EVP_PKCS82PKEY.3,v 1.2 2023/12/21 21:32:01 tb Exp $ 2.\" 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: December 21 2023 $ 18.Dt EVP_PKCS82PKEY 3 19.Os 20.Sh NAME 21.Nm EVP_PKCS82PKEY , 22.Nm EVP_PKEY2PKCS8 23.Nd convert between EVP_PKEY and PKCS#8 PrivateKeyInfo 24.Sh SYNOPSIS 25.In openssl/x509.h 26.Ft EVP_PKEY * 27.Fn EVP_PKCS82PKEY "const PKCS8_PRIV_KEY_INFO *keyinfo" 28.Ft PKCS8_PRIV_KEY_INFO * 29.Fn EVP_PKEY2PKCS8 "EVP_PKEY *pkey" 30.Sh DESCRIPTION 31.Fn EVP_PKCS82PKEY 32extracts the private key from a PKCS#8 33.Vt PrivateKeyInfo 34structure. 35.Pp 36.Fn EVP_PKEY2PKCS8 37creates a PKCS#8 38.Vt PrivateKeyInfo 39structure representing the private key contained in 40.Fa pkey . 41.Pp 42Supported algorithms include DH, DSA, EC, GOST2001, and RSA. 43.Sh RETURN VALUES 44These functions return a newly allocated object or 45.Dv NULL 46if the algorithm indicated in 47.Fa keyinfo 48or 49.Fa pkey 50is unsupported or if memory allocation, decoding, or encoding fails. 51.Sh SEE ALSO 52.Xr EVP_PKEY_base_id 3 , 53.Xr EVP_PKEY_new 3 , 54.Xr PKCS8_pkey_set0 3 , 55.Xr PKCS8_PRIV_KEY_INFO_new 3 , 56.Xr X509_ALGOR_get0 3 57.Sh HISTORY 58These functions first appeared in OpenSSL 0.9.3 59and have been available since 60.Ox 2.6 . 61