PKCS12_PACK_P7ENCDATA(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’– PKCS12_pack_p7encdata πŸ’–

okay bestie, welcome to the 3ossl girlies' corner of the manual β€” yes, this is the OpenSSL one, and yes, we're gonna make it make sense 🫢

✨ NAME ✨

PKCS12_pack_p7encdata, PKCS12_pack_p7encdata_ex β€” the duo that packs a whole set of PKCS#12 safeBags into a PKCS#7 encrypted data object. it's giving "put it in a box and lock the box" energy πŸ”₯

🌸 SYNOPSIS 🌸

#include <openssl/pkcs12.h>

PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,
                             unsigned char *salt, int saltlen, int iter,
                             STACK_OF(PKCS12_SAFEBAG) *bags);
PKCS7 *PKCS12_pack_p7encdata_ex(int pbe_nid, const char *pass, int passlen,
                                unsigned char *salt, int saltlen, int iter,
                                STACK_OF(PKCS12_SAFEBAG) *bags,
                                OSSL_LIB_CTX *ctx, const char *propq);

πŸŽ€ DESCRIPTION πŸŽ€

so PKCS12_pack_p7encdata() literally generates a PKCS#7 ContentInfo object of encrypted-data type, and it makes it out of the set of safeBags in bags. main character behaviour honestly πŸ‘‘

the algorithm ID you hand over in pbe_nid can be a PKCS#12 password based encryption algorithm, a PKCS#5 password based encryption algorithm, or a cipher algorithm. plot twist: if you pass a cipher algorithm, then the PKCS#5 PBES2 algorithm gets used, with that cipher as a parameter. slay πŸ¦‹

the password pass of length passlen, the salt salt of length saltlen, and the iteration count iter are all inputs into the encryption operation. every single one of them, no skips πŸ’…

then there's PKCS12_pack_p7encdata_ex(), which operates similar to the above (same vibe, same job) but lowkey lets a library context ctx and a property query propq be used to select the algorithm implementation. fancy ✨

πŸ’– RETURN VALUES πŸ’–

you get a PKCS7 object if it worked β€” cute! β€” or NULL if an error occurred. that's it, that's the whole vibe check 😭

🌈 CONFORMING TO 🌈

IETF RFC 2315 (<https://tools.ietf.org/html/rfc2315>) β€” yes we cite our sources, we're not animals πŸŽ€

πŸ¦‹ SEE ALSO πŸ¦‹

PKCS12_pbe_crypt_ex(3) β€” go read that one next bestie, iykyk πŸ’œ

⭐ HISTORY ⭐

PKCS12_pack_p7encdata_ex() was added in OpenSSL 3.0. the _ex version is the newer sibling, we stan a glow-up πŸ’…

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>.


okay that's the whole page, no cap 🫢 this was OpenSSL 3.5.6, dated 2026-04-07, filed under the PKCS12_PACK_P7ENCDATA(3ossl) manual β€” mwah, go encrypt something gorgeous πŸ’–βœ¨

πŸ“¦ where this page comes from