PKCS7_SET_TYPE(3)
π NAME π
okay so this is the PKCS7_SET_TYPE(3) entry in the Library Functions Manual, bestie β it's all about PKCS7_set_type and PKCS7_set0_type_other, the functions that initialize the type of a PKCS#7 ContentInfo. iconic little setup behavior, no cap.
β¨ SYNOPSIS β¨
library βlibcryptoβ
#include <openssl/pkcs7.h>
int
PKCS7_set_type(PKCS7 *p7, int type);
int
PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *content);
π¦ DESCRIPTION π¦
These functions set the type of an unused ContentInfo structure p7. Like, p7 is the main character here, and you're giving it a whole new identity π
.
The function PKCS7_set_type() also allocates and initializes an empty child object in p7. The type argument can be any of these NIDs, creating a child object of the indicated data type:
NID_pkcs7_dataβ data type of child:ASN1_OCTET_STRING; version: n.a.NID_pkcs7_digestβ data type of child:PKCS7_DIGEST; version: 0NID_pkcs7_encryptedβ data type of child:PKCS7_ENCRYPT; version: 0NID_pkcs7_envelopedβ data type of child:PKCS7_ENVELOPE; version: 0NID_pkcs7_signedβ data type of child:PKCS7_SIGNED; version: 1NID_pkcs7_signedAndEnvelopedβ data type of child:PKCS7_SIGN_ENVELOPE; version: 1
If the provided type is invalid, p7 remains unchanged and PKCS7_set_type() fails. π«Ά
If memory allocation fails, PKCS7_set_type() fails and p7 may remain in an inconsistent state. That's the messy part, bestie β not cute, but important.
The function PKCS7_set0_type_other() accepts an arbitrary NID as the type and also sets the content, neither checking it in any way nor copying it. No vibe check, no copy, no notes. It just does the thing πΈ.
For both functions, the rest of the internal state of p7 remains unchanged.
π RETURN VALUES π
The function PKCS7_set_type() returns 1 on success or 0 on failure.
The function PKCS7_set0_type_other() does no error handling at all and always returns 1. yes, always. main character confidence ππ
π SEE ALSO π
ASN1_OCTET_STRING_new(3)ASN1_TYPE_new(3)PKCS7_encrypt(3)PKCS7_new(3)PKCS7_set_content(3)PKCS7_sign(3)
β HISTORY β
The function PKCS7_set_type() first appeared in SSLeay 0.8.1 and PKCS7_set0_type_other() in OpenSSL 0.9.8. Both have been available since OpenBSD 2.4. vintage behavior, honestly π.
π CAVEATS π
Ifp7has already been in use before being passed to one of these functions, it will report success even though it leaks memory. Later on, if other functions try to usep7in its former role, they are likely to misbehave.
so yeah β that's a real leak-and-chaos situation. not the slay we want. keep an eye on it, bestie π¨
mwah π this page comes from Debian, dated June 8, 2025, and its manual title is PKCS7_SET_TYPE(3) β bye bestie, go initialize responsibly π«Άβ¨
π¦ 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) 2020 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