1 1.1 christos =pod 2 1.1 christos 3 1.1 christos =head1 NAME 4 1.1 christos 5 1.1 christos d2i_PKCS8PrivateKey_bio, d2i_PKCS8PrivateKey_fp, 6 1.1 christos i2d_PKCS8PrivateKey_bio, i2d_PKCS8PrivateKey_fp, 7 1.1 christos i2d_PKCS8PrivateKey_nid_bio, i2d_PKCS8PrivateKey_nid_fp - PKCS#8 format private key functions 8 1.1 christos 9 1.1 christos =head1 SYNOPSIS 10 1.1 christos 11 1.1.1.3 christos #include <openssl/pem.h> 12 1.1 christos 13 1.1 christos EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u); 14 1.1 christos EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u); 15 1.1 christos 16 1.1.1.2 christos int i2d_PKCS8PrivateKey_bio(BIO *bp, const EVP_PKEY *x, const EVP_CIPHER *enc, 17 1.1 christos char *kstr, int klen, 18 1.1 christos pem_password_cb *cb, void *u); 19 1.1 christos 20 1.1.1.2 christos int i2d_PKCS8PrivateKey_fp(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc, 21 1.1 christos char *kstr, int klen, 22 1.1 christos pem_password_cb *cb, void *u); 23 1.1 christos 24 1.1.1.2 christos int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, const EVP_PKEY *x, int nid, 25 1.1 christos char *kstr, int klen, 26 1.1 christos pem_password_cb *cb, void *u); 27 1.1 christos 28 1.1.1.2 christos int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, const EVP_PKEY *x, int nid, 29 1.1 christos char *kstr, int klen, 30 1.1 christos pem_password_cb *cb, void *u); 31 1.1 christos 32 1.1 christos =head1 DESCRIPTION 33 1.1 christos 34 1.1 christos The PKCS#8 functions encode and decode private keys in PKCS#8 format using both 35 1.1 christos PKCS#5 v1.5 and PKCS#5 v2.0 password based encryption algorithms. 36 1.1 christos 37 1.1 christos Other than the use of DER as opposed to PEM these functions are identical to the 38 1.1 christos corresponding B<PEM> function as described in L<PEM_read_PrivateKey(3)>. 39 1.1 christos 40 1.1 christos =head1 NOTES 41 1.1 christos 42 1.1 christos These functions are currently the only way to store encrypted private keys using DER format. 43 1.1 christos 44 1.1 christos Currently all the functions use BIOs or FILE pointers, there are no functions which 45 1.1 christos work directly on memory: this can be readily worked around by converting the buffers 46 1.1 christos to memory BIOs, see L<BIO_s_mem(3)> for details. 47 1.1 christos 48 1.1 christos These functions make no assumption regarding the pass phrase received from the 49 1.1 christos password callback. 50 1.1 christos It will simply be treated as a byte sequence. 51 1.1 christos 52 1.1 christos =head1 RETURN VALUES 53 1.1 christos 54 1.1 christos d2i_PKCS8PrivateKey_bio() and d2i_PKCS8PrivateKey_fp() return a valid B<EVP_PKEY> 55 1.1 christos structure or NULL if an error occurred. 56 1.1 christos 57 1.1 christos i2d_PKCS8PrivateKey_bio(), i2d_PKCS8PrivateKey_fp(), i2d_PKCS8PrivateKey_nid_bio() 58 1.1 christos and i2d_PKCS8PrivateKey_nid_fp() return 1 on success or 0 on error. 59 1.1 christos 60 1.1 christos =head1 SEE ALSO 61 1.1 christos 62 1.1 christos L<PEM_read_PrivateKey(3)>, 63 1.1 christos L<passphrase-encoding(7)> 64 1.1 christos 65 1.1 christos =head1 COPYRIGHT 66 1.1 christos 67 1.1.1.3 christos Copyright 2002-2023 The OpenSSL Project Authors. All Rights Reserved. 68 1.1 christos 69 1.1.1.2 christos Licensed under the Apache License 2.0 (the "License"). You may not use 70 1.1 christos this file except in compliance with the License. You can obtain a copy 71 1.1 christos in the file LICENSE in the source distribution or at 72 1.1 christos L<https://www.openssl.org/source/license.html>. 73 1.1 christos 74 1.1 christos =cut 75