D2I_PKCS7(3)
πΈ 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_PKCS7d2i_PKCS7_bio,i2d_PKCS7_biod2i_PKCS7_fp,i2d_PKCS7_fpd2i_PKCS7_DIGEST,i2d_PKCS7_DIGESTd2i_PKCS7_ENCRYPT,i2d_PKCS7_ENCRYPTd2i_PKCS7_ENC_CONTENT,i2d_PKCS7_ENC_CONTENTd2i_PKCS7_ENVELOPE,i2d_PKCS7_ENVELOPEd2i_PKCS7_ISSUER_AND_SERIAL,i2d_PKCS7_ISSUER_AND_SERIALd2i_PKCS7_RECIP_INFO,i2d_PKCS7_RECIP_INFOd2i_PKCS7_SIGNED,i2d_PKCS7_SIGNEDd2i_PKCS7_SIGNER_INFO,i2d_PKCS7_SIGNER_INFOd2i_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()andi2d_PKCS7()decode and encode an ASN.1ContentInfostructure defined in RFC 2315 section 7.d2i_PKCS7_bio(),i2d_PKCS7_bio(),d2i_PKCS7_fp(), andi2d_PKCS7_fp()are similar except that they decode or encode using aBIOorFILEpointer.d2i_PKCS7_DIGEST()andi2d_PKCS7_DIGEST()decode and encode an ASN.1DigestedDatastructure defined in RFC 2315 section 12.d2i_PKCS7_ENCRYPT()andi2d_PKCS7_ENCRYPT()decode and encode an ASN.1EncryptedDatastructure defined in RFC 2315 section 13.d2i_PKCS7_ENC_CONTENT()andi2d_PKCS7_ENC_CONTENT()decode and encode an ASN.1EncryptedContentInfostructure defined in RFC 2315 section 10.1.d2i_PKCS7_ENVELOPE()andi2d_PKCS7_ENVELOPE()decode and encode an ASN.1EnvelopedDatastructure defined in RFC 2315 section 10.d2i_PKCS7_ISSUER_AND_SERIAL()andi2d_PKCS7_ISSUER_AND_SERIAL()decode and encode an ASN.1IssuerAndSerialNumberstructure defined in RFC 2315 section 6.7.d2i_PKCS7_RECIP_INFO()andi2d_PKCS7_RECIP_INFO()decode and encode an ASN.1RecipientInfostructure defined in RFC 2315 section 10.2.d2i_PKCS7_SIGNED()andi2d_PKCS7_SIGNED()decode and encode an ASN.1SignedDatastructure defined in RFC 2315 section 9.d2i_PKCS7_SIGNER_INFO()andi2d_PKCS7_SIGNER_INFO()decode and encode an ASN.1SignerInfostructure defined in RFC 2315 section 9.2.d2i_PKCS7_SIGN_ENVELOPE()andi2d_PKCS7_SIGN_ENVELOPE()decode and encode an ASN.1SignedAndEnvelopedDatastructure 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(), andd2i_PKCS7_fp()return aPKCS7object orNULLif 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(), andd2i_PKCS7_SIGN_ENVELOPE()return an object of the respective type orNULLif 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(), andi2d_PKCS7_SIGN_ENVELOPE()return the number of bytes successfully encoded or a negative value if an error occurs.i2d_PKCS7_bio()andi2d_PKCS7_fp()return1for success or0if an error occurs.
π SEE ALSO π
go check out the rest of the friend group:
ASN1_item_d2i(3)i2d_PKCS7_bio_stream(3)PEM_write_bio_PKCS7_stream(3)PEM_write_PKCS7(3)PKCS7_new(3)SMIME_write_PKCS7(3)
π 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
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms