D2I_PKCS7(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

🌸 NAME 🌸

okay so bestie, welcome to the D2I_PKCS7(3) page β€” this is the libcrypto manual for decoding and encoding PKCS#7 data structures, and the whole squad is here:

  • d2i_PKCS7, i2d_PKCS7
  • d2i_PKCS7_bio, i2d_PKCS7_bio
  • d2i_PKCS7_fp, i2d_PKCS7_fp
  • d2i_PKCS7_DIGEST, i2d_PKCS7_DIGEST
  • d2i_PKCS7_ENCRYPT, i2d_PKCS7_ENCRYPT
  • d2i_PKCS7_ENC_CONTENT, i2d_PKCS7_ENC_CONTENT
  • d2i_PKCS7_ENVELOPE, i2d_PKCS7_ENVELOPE
  • d2i_PKCS7_ISSUER_AND_SERIAL, i2d_PKCS7_ISSUER_AND_SERIAL
  • d2i_PKCS7_RECIP_INFO, i2d_PKCS7_RECIP_INFO
  • d2i_PKCS7_SIGNED, i2d_PKCS7_SIGNED
  • d2i_PKCS7_SIGNER_INFO, i2d_PKCS7_SIGNER_INFO
  • d2i_PKCS7_SIGN_ENVELOPE, i2d_PKCS7_SIGN_ENVELOPE

β€” decode and encode PKCS#7 data structures. periodt πŸ’…


✨ SYNOPSIS ✨

okay so here’s the exact synopsis, no cap 🫢

library β€œlibcrypto” #include <openssl/pkcs7.h>

PKCS7 *
d2i_PKCS7(PKCS7 **val_out, const unsigned char **der_in, long length);

int
i2d_PKCS7(PKCS7 *val_in, unsigned char **der_out);

PKCS7 *
d2i_PKCS7_bio(BIO *in_bio, PKCS7 **val_out);

int
i2d_PKCS7_bio(BIO *out_bio, PKCS7 *val_in);

PKCS7 *
d2i_PKCS7_fp(FILE *in_fp, PKCS7 **val_out);

int
i2d_PKCS7_fp(FILE *out_fp, PKCS7 *val_in);

PKCS7_DIGEST *
d2i_PKCS7_DIGEST(PKCS7_DIGEST **val_out, const unsigned char **der_in,
    long length);

int
i2d_PKCS7_DIGEST(PKCS7_DIGEST *val_in, unsigned char **der_out);

PKCS7_ENCRYPT *
d2i_PKCS7_ENCRYPT(PKCS7_ENCRYPT **val_out, const unsigned char **der_in,
    long length);

int
i2d_PKCS7_ENCRYPT(PKCS7_ENCRYPT *val_in, unsigned char **der_out);

PKCS7_ENC_CONTENT *
d2i_PKCS7_ENC_CONTENT(PKCS7_ENC_CONTENT **val_out,
    const unsigned char **der_in, long length);

int
i2d_PKCS7_ENC_CONTENT(PKCS7_ENC_CONTENT *val_in,
    unsigned char **der_out);

PKCS7_ENVELOPE *
d2i_PKCS7_ENVELOPE(PKCS7_ENVELOPE **val_out,
    const unsigned char **der_in, long length);

int
i2d_PKCS7_ENVELOPE(PKCS7_ENVELOPE *val_in, unsigned char **der_out);

PKCS7_ISSUER_AND_SERIAL *
d2i_PKCS7_ISSUER_AND_SERIAL(PKCS7_ISSUER_AND_SERIAL **val_out,
    const unsigned char **der_in, long length);

int
i2d_PKCS7_ISSUER_AND_SERIAL(PKCS7_ISSUER_AND_SERIAL *val_in,
    unsigned char **der_out);

PKCS7_RECIP_INFO *
d2i_PKCS7_RECIP_INFO(PKCS7_RECIP_INFO **val_out,
    const unsigned char **der_in, long length);

int
i2d_PKCS7_RECIP_INFO(PKCS7_RECIP_INFO *val_in, unsigned char **der_out);

PKCS7_SIGNED *
d2i_PKCS7_SIGNED(PKCS7_SIGNED **val_out, const unsigned char **der_in,
    long length);

int
i2d_PKCS7_SIGNED(PKCS7_SIGNED *val_in, unsigned char **der_out);

PKCS7_SIGNER_INFO *
d2i_PKCS7_SIGNER_INFO(PKCS7_SIGNER_INFO **val_out,
    const unsigned char **der_in, long length);

int
i2d_PKCS7_SIGNER_INFO(PKCS7_SIGNER_INFO *val_in,
    unsigned char **der_out);

PKCS7_SIGN_ENVELOPE *
d2i_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE **val_out,
    const unsigned char **der_in, long length);

int
i2d_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE *val_in,
    unsigned char **der_out);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so these functions decode and encode PKCS#7 data structures. For the full tea on semantics, examples, caveats, and bugs, see ASN1_item_d2i(3). 🫢

  • d2i_PKCS7() and i2d_PKCS7() decode and encode an ASN.1 ContentInfo structure defined in RFC 2315 section 7. d2i_PKCS7_bio(), i2d_PKCS7_bio(), d2i_PKCS7_fp(), and i2d_PKCS7_fp() are similar except that they decode or encode using a BIO or FILE pointer.
  • d2i_PKCS7_DIGEST() and i2d_PKCS7_DIGEST() decode and encode an ASN.1 DigestedData structure defined in RFC 2315 section 12.
  • d2i_PKCS7_ENCRYPT() and i2d_PKCS7_ENCRYPT() decode and encode an ASN.1 EncryptedData structure defined in RFC 2315 section 13.
  • d2i_PKCS7_ENC_CONTENT() and i2d_PKCS7_ENC_CONTENT() decode and encode an ASN.1 EncryptedContentInfo structure defined in RFC 2315 section 10.1.
  • d2i_PKCS7_ENVELOPE() and i2d_PKCS7_ENVELOPE() decode and encode an ASN.1 EnvelopedData structure defined in RFC 2315 section 10.
  • d2i_PKCS7_ISSUER_AND_SERIAL() and i2d_PKCS7_ISSUER_AND_SERIAL() decode and encode an ASN.1 IssuerAndSerialNumber structure defined in RFC 2315 section 6.7.
  • d2i_PKCS7_RECIP_INFO() and i2d_PKCS7_RECIP_INFO() decode and encode an ASN.1 RecipientInfo structure defined in RFC 2315 section 10.2.
  • d2i_PKCS7_SIGNED() and i2d_PKCS7_SIGNED() decode and encode an ASN.1 SignedData structure defined in RFC 2315 section 9.
  • d2i_PKCS7_SIGNER_INFO() and i2d_PKCS7_SIGNER_INFO() decode and encode an ASN.1 SignerInfo structure defined in RFC 2315 section 9.2.
  • d2i_PKCS7_SIGN_ENVELOPE() and i2d_PKCS7_SIGN_ENVELOPE() decode and encode an ASN.1 SignedAndEnvelopedData structure defined in RFC 2315 section 11.

πŸ’– RETURN VALUES πŸ’–

okay so the returns are giving β€œobject or NULL” and β€œbytes or negative” energy:

  • d2i_PKCS7(), d2i_PKCS7_bio(), and d2i_PKCS7_fp() return a PKCS7 object or NULL if an error occurs.
  • d2i_PKCS7_DIGEST(), d2i_PKCS7_ENCRYPT(), d2i_PKCS7_ENC_CONTENT(), d2i_PKCS7_ENVELOPE(), d2i_PKCS7_ISSUER_AND_SERIAL(), d2i_PKCS7_RECIP_INFO(), d2i_PKCS7_SIGNED(), d2i_PKCS7_SIGNER_INFO(), and d2i_PKCS7_SIGN_ENVELOPE() return an object of the respective type or NULL if an error occurs.
  • i2d_PKCS7(), i2d_PKCS7_DIGEST(), i2d_PKCS7_ENCRYPT(), i2d_PKCS7_ENC_CONTENT(), i2d_PKCS7_ENVELOPE(), i2d_PKCS7_ISSUER_AND_SERIAL(), i2d_PKCS7_RECIP_INFO(), i2d_PKCS7_SIGNED(), i2d_PKCS7_SIGNER_INFO(), and i2d_PKCS7_SIGN_ENVELOPE() return the number of bytes successfully encoded or a negative value if an error occurs.
  • i2d_PKCS7_bio() and i2d_PKCS7_fp() return 1 for success or 0 if an error occurs.

πŸ‘‘ SEE ALSO πŸ‘‘

go check out the rest of the friend group:


🌈 STANDARDS 🌈

the standards bestie is: RFC 2315: PKCS #7: Cryptographic Message Syntax Version 1.5


πŸŽ€ HISTORY πŸŽ€

okay so history check: d2i_PKCS7(), i2d_PKCS7(), d2i_PKCS7_bio(), i2d_PKCS7_bio(), d2i_PKCS7_fp(), i2d_PKCS7_fp(), d2i_PKCS7_DIGEST(), i2d_PKCS7_DIGEST(), d2i_PKCS7_ENCRYPT(), i2d_PKCS7_ENCRYPT(), d2i_PKCS7_ENC_CONTENT(), i2d_PKCS7_ENC_CONTENT(), d2i_PKCS7_ENVELOPE(), i2d_PKCS7_ENVELOPE(), d2i_PKCS7_ISSUER_AND_SERIAL(), i2d_PKCS7_ISSUER_AND_SERIAL(), d2i_PKCS7_RECIP_INFO(), i2d_PKCS7_RECIP_INFO(), d2i_PKCS7_SIGNED(), i2d_PKCS7_SIGNED(), d2i_PKCS7_SIGNER_INFO(), i2d_PKCS7_SIGNER_INFO(), d2i_PKCS7_SIGN_ENVELOPE(), and i2d_PKCS7_SIGN_ENVELOPE() first appeared in SSLeay 0.5.1 and have been available since OpenBSD 2.4.

🧚 later bestie β€” source/version: Debian, dated June 8, 2025 πŸ’œ

πŸ“¦ where this page comes from