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