PKCS7_SET_TYPE(3)
π PKCS7_SET_TYPE(3) β Library Functions Manual π
okay bestie, welcome to the PKCS7_SET_TYPE(3) page from the Library Functions Manual β weβre doing PKCS#7 ContentInfo type stuff and itβs honestly giving βtiny setup functions with big main-character energyβ β¨
π NAME π
PKCS7_set_type, PKCS7_set0_type_other β initialize type of PKCS#7 ContentInfo π
π¦ SYNOPSIS π¦
#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 πΈ
So these functions set the type of an unused ContentInfo structure p7 β like, it has to be unused, okay? Donβt come in here with a p7 thatβs already been living its best life π
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β child data type:ASN1_OCTET_STRING; version:n.a.NID_pkcs7_digestβ child data type:PKCS7_DIGEST; version:0NID_pkcs7_encryptedβ child data type:PKCS7_ENCRYPT; version:0NID_pkcs7_envelopedβ child data type:PKCS7_ENVELOPE; version:0NID_pkcs7_signedβ child data type:PKCS7_SIGNED; version:1NID_pkcs7_signedAndEnvelopedβ child data type:PKCS7_SIGN_ENVELOPE; version:1
If the provided type is invalid, p7 remains unchanged and PKCS7_set_type() fails. No spontaneous glow-up for p7, sadly π
If memory allocation fails, PKCS7_set_type() fails and p7 may remain in an inconsistent state. Yeah, thatβs the messy part β not iconic, just inconsistent π
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. Likeβ¦ zero vibe check, zero copy, just straight in π«Ά
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. Simple slay.
The function PKCS7_set0_type_other() does no error handling at all and always returns 1. Not me trusting the process fr fr π
π 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 but still relevant, iykyk π
π CAVEATS π
If p7 has already been in use before being passed to one of these functions, it will report success even though it leaks memory. Yikes. Later on, if other functions try to use p7 in its former role, they are likely to misbehave. Thatβs the βit said yes but it was lyingβ energy β please respect the unused-structure rule, bestie π¨
xoxo, this little page comes from Debian, dated May 20, 2020 β periodt π
π
π¦ where this page comes from
- opensuse-leap 16.0: libressl-devel-doc 4.1.0-bp160.1.1 Β· 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