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