PKCS8_ENCRYPT(3SSL)
π PKCS8_ENCRYPT π
okay bestie, welcome to the OpenSSL manual, section 3SSL β¨ this is the page all about the PKCS8 encrypt/decrypt glow-up β PKCS8_decrypt, PKCS8_decrypt_ex, PKCS8_encrypt, PKCS8_encrypt_ex, PKCS8_set0_pbe, PKCS8_set0_pbe_ex, aka the PKCS8 encrypt/decrypt functions π
πΈ NAME πΈ
PKCS8_decrypt, PKCS8_decrypt_ex, PKCS8_encrypt, PKCS8_encrypt_ex, PKCS8_set0_pbe, PKCS8_set0_pbe_ex β PKCS8 encrypt/decrypt functions π
β¨ SYNOPSIS β¨
#include <openssl/x509.h>
PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(const X509_SIG *p8, const char *pass,
int passlen);
PKCS8_PRIV_KEY_INFO *PKCS8_decrypt_ex(const X509_SIG *p8, const char *pass,
int passlen, OSSL_LIB_CTX *ctx,
const char *propq);
X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,
const char *pass, int passlen, unsigned char *salt,
int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8);
X509_SIG *PKCS8_encrypt_ex(int pbe_nid, const EVP_CIPHER *cipher,
const char *pass, int passlen, unsigned char *salt,
int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8,
OSSL_LIB_CTX *ctx, const char *propq);
X509_SIG *PKCS8_set0_pbe(const char *pass, int passlen,
PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe);
X509_SIG *PKCS8_set0_pbe_ex(const char *pass, int passlen,
PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe,
OSSL_LIB_CTX *ctx);
π¦ DESCRIPTION π¦
so PKCS8_encrypt() and PKCS8_encrypt_ex() are the ones doing the encryption of an object p8 π«Ά they use the password pass (length passlen), the salt salt (length saltlen), and the iteration count iter. and the resulting X509_SIG is literally carrying the encoded algorithm parameters and the encrypted key, no cap π
PKCS8_decrypt() and PKCS8_decrypt_ex() do the decryption β they take an X509_SIG in p8 and decrypt it with the password pass of length passlen, plus the algorithm parameters they grab from the p8 itself πΈ
PKCS8_set0_pbe() and PKCS8_set0_pbe_ex() handle encryption of the p8inf using the password pass of length passlen and the parameters pbe β¨
and here's the tea: any function whose name ends in _ex() lets you use a library context ctx and a property query propq to pick which algorithm implementations get used π
π₯ RETURN VALUES π₯
PKCS8_encrypt(), PKCS8_encrypt_ex(), PKCS8_set0_pbe() and PKCS8_set0_pbe_ex() hand back an encrypted key inside an X509_SIG structure β or NULL if something goes wrong π
PKCS8_decrypt() and PKCS8_decrypt_ex() give you a PKCS8_PRIV_KEY_INFO β or NULL if something goes wrong π
π CONFORMING TO π
IETF RFC 7292 (<https://tools.ietf.org/html/rfc7292>) β
π SEE ALSO π
π HISTORY π
PKCS8_decrypt_ex(), PKCS8_encrypt_ex() and PKCS8_set0_pbe_ex() were added in OpenSSL 3.0 π¦ (the ex era began, iconic)
π COPYRIGHT π
Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole page bestie, no notes π
mwah β this was the OpenSSL 4.0.3 version, dated 2026-09-29, and it's the PKCS8_ENCRYPT(3SSL) page π«Ά go encrypt something responsibly, ily β¨π
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms