PKCS8_encrypt.pod 2.9 KB

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