xref: /freebsd/crypto/openssl/doc/man3/b2i_PVK_bio_ex.pod (revision 7ef62cebc2f965b0f640263e179276928885e33d)
1=pod
2
3=head1 NAME
4
5b2i_PVK_bio, b2i_PVK_bio_ex, i2b_PVK_bio, i2b_PVK_bio_ex - Decode and encode
6functions for reading and writing MSBLOB format private keys
7
8=head1 SYNOPSIS
9
10 #include <openssl/pem.h>
11
12 EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
13 EVP_PKEY *b2i_PVK_bio_ex(BIO *in, pem_password_cb *cb, void *u,
14                          OSSL_LIB_CTX *libctx, const char *propq);
15 int i2b_PVK_bio(BIO *out, const EVP_PKEY *pk, int enclevel,
16                 pem_password_cb *cb, void *u);
17 int i2b_PVK_bio_ex(BIO *out, const EVP_PKEY *pk, int enclevel,
18                    pem_password_cb *cb, void *u,
19                    OSSL_LIB_CTX *libctx, const char *propq);
20
21=head1 DESCRIPTION
22
23b2i_PVK_bio_ex() decodes a private key of MSBLOB format read from a B<BIO>. It
24attempts to automatically determine the key type. If the key is encrypted then
25I<cb> is called with the user data I<u> in order to obtain a password to decrypt
26the key. The supplied library context I<libctx> and property query
27string I<propq> are used in any decrypt operation.
28
29b2i_PVK_bio() does the same as b2i_PVK_bio_ex() except that the default
30library context and property query string are used.
31
32i2b_PVK_bio_ex() encodes I<pk> using MSBLOB format. If I<enclevel> is 1 then
33a password obtained via I<pem_password_cb> is used to encrypt the private key.
34If I<enclevel> is 0 then no encryption is applied. The user data in I<u> is
35passed to the password callback. The supplied library context I<libctx> and
36property query string I<propq> are used in any decrypt operation.
37
38i2b_PVK_bio() does the same as i2b_PVK_bio_ex() except that the default
39library context and property query string are used.
40
41=head1 RETURN VALUES
42
43The b2i_PVK_bio() and b2i_PVK_bio_ex() functions return a valid B<EVP_KEY>
44structure or B<NULL> if an error occurs. The error code can be obtained by calling
45L<ERR_get_error(3)>.
46
47i2b_PVK_bio() and i2b_PVK_bio_ex() return the number of bytes successfully
48encoded or a negative value if an error occurs. The error code can be obtained
49by calling L<ERR_get_error(3)>.
50
51=head1 SEE ALSO
52
53L<crypto(7)>,
54L<d2i_PKCS8PrivateKey_bio(3)>
55
56=head1 HISTORY
57
58b2i_PVK_bio_ex() and i2b_PVK_bio_ex() were added in OpenSSL 3.0.
59
60=head1 COPYRIGHT
61
62Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
63
64Licensed under the Apache License 2.0 (the "License").  You may not use
65this file except in compliance with the License.  You can obtain a copy
66in the file LICENSE in the source distribution or at
67L<https://www.openssl.org/source/license.html>.
68
69=cut
70