1 1.1 christos =pod 2 1.1 christos 3 1.1 christos =head1 NAME 4 1.1 christos 5 1.1 christos PKCS8_decrypt, PKCS8_decrypt_ex, PKCS8_encrypt, PKCS8_encrypt_ex, 6 1.1 christos PKCS8_set0_pbe, PKCS8_set0_pbe_ex - PKCS8 encrypt/decrypt functions 7 1.1 christos 8 1.1 christos =head1 SYNOPSIS 9 1.1 christos 10 1.1 christos #include <openssl/x509.h> 11 1.1 christos 12 1.1 christos PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(const X509_SIG *p8, const char *pass, 13 1.1 christos int passlen); 14 1.1 christos PKCS8_PRIV_KEY_INFO *PKCS8_decrypt_ex(const X509_SIG *p8, const char *pass, 15 1.1 christos int passlen, OSSL_LIB_CTX *ctx, 16 1.1 christos const char *propq); 17 1.1 christos X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, 18 1.1 christos const char *pass, int passlen, unsigned char *salt, 19 1.1 christos int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8); 20 1.1 christos X509_SIG *PKCS8_encrypt_ex(int pbe_nid, const EVP_CIPHER *cipher, 21 1.1 christos const char *pass, int passlen, unsigned char *salt, 22 1.1 christos int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8, 23 1.1 christos OSSL_LIB_CTX *ctx, const char *propq); 24 1.1 christos X509_SIG *PKCS8_set0_pbe(const char *pass, int passlen, 25 1.1 christos PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe); 26 1.1 christos X509_SIG *PKCS8_set0_pbe_ex(const char *pass, int passlen, 27 1.1 christos PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe, 28 1.1 christos OSSL_LIB_CTX *ctx); 29 1.1 christos 30 1.1 christos =head1 DESCRIPTION 31 1.1 christos 32 1.1 christos PKCS8_encrypt() and PKCS8_encrypt_ex() perform encryption of an object I<p8> using 33 1.1 christos the password I<pass> of length I<passlen>, salt I<salt> of length I<saltlen> 34 1.1 christos and iteration count I<iter>. 35 1.1 christos The resulting B<X509_SIG> contains the encoded algorithm parameters and encrypted 36 1.1 christos key. 37 1.1 christos 38 1.1 christos PKCS8_decrypt() and PKCS8_decrypt_ex() perform decryption of an B<X509_SIG> in 39 1.1 christos I<p8> using the password I<pass> of length I<passlen> along with algorithm 40 1.1 christos parameters obtained from the I<p8>. 41 1.1 christos 42 1.1 christos PKCS8_set0_pbe() and PKCS8_set0_pbe_ex() perform encryption of the I<p8inf> 43 1.1 christos using the password I<pass> of length I<passlen> and parameters I<pbe>. 44 1.1 christos 45 1.1 christos Functions ending in _ex() allow for a library context I<ctx> and property query 46 1.1 christos I<propq> to be used to select algorithm implementations. 47 1.1 christos 48 1.1 christos =head1 RETURN VALUES 49 1.1 christos 50 1.1 christos PKCS8_encrypt(), PKCS8_encrypt_ex(), PKCS8_set0_pbe() and PKCS8_set0_pbe_ex() 51 1.1 christos return an encrypted key in a B<X509_SIG> structure or NULL if an error occurs. 52 1.1 christos 53 1.1 christos PKCS8_decrypt() and PKCS8_decrypt_ex() return a B<PKCS8_PRIV_KEY_INFO> or NULL 54 1.1 christos if an error occurs. 55 1.1 christos 56 1.1 christos =head1 CONFORMING TO 57 1.1 christos 58 1.1 christos IETF RFC 7292 (L<https://tools.ietf.org/html/rfc7292>) 59 1.1 christos 60 1.1 christos =head1 SEE ALSO 61 1.1 christos 62 1.1 christos L<crypto(7)> 63 1.1 christos 64 1.1 christos =head1 HISTORY 65 1.1 christos 66 1.1 christos PKCS8_decrypt_ex(), PKCS8_encrypt_ex() and PKCS8_set0_pbe_ex() were added in 67 1.1 christos OpenSSL 3.0. 68 1.1 christos 69 1.1 christos =head1 COPYRIGHT 70 1.1 christos 71 1.1 christos Copyright 2021 The OpenSSL Project Authors. All Rights Reserved. 72 1.1 christos 73 1.1 christos Licensed under the Apache License 2.0 (the "License"). You may not use 74 1.1 christos this file except in compliance with the License. You can obtain a copy 75 1.1 christos in the file LICENSE in the source distribution or at 76 1.1 christos L<https://www.openssl.org/source/license.html>. 77 1.1 christos 78 1.1 christos =cut 79