PKCS7_SET_CONTENT(3)
πΈ NAME πΈ
okay bestie, welcome to PKCS7_SET_CONTENT(3) from the Library Functions Manual β header line folded in, cutely, and we're moving on. The main characters are PKCS7_set_content and PKCS7_content_new, and their whole job is setting the nested contentInfo in a PKCS#7 structure. That's the name; no cap.
β¨ SYNOPSIS β¨
#include <openssl/pkcs7.h>
int
PKCS7_set_content(PKCS7 *outer, PKCS7 *inner);
int
PKCS7_content_new(PKCS7 *outer, int inner_type);
π DESCRIPTION π
So picture outer as the main character PKCS7 structure, right? If its contentType is SignedData or DigestedData, then PKCS7_set_content() sets the contentInfo field of the content field of outer to inner β and it does not copy inner, bestie. If there was a previous contentInfo, it gets freed rather than overwritten. The rest of the internal state of outer and of its content stays unchanged. Iconic, minimal, lowkey no messy copy energy.
PKCS7_content_new() is similar, except it first allocates and initializes a shiny new empty inner object of the given inner_type using PKCS7_new(3) and PKCS7_set_type(3). The inner_type can be any of the NIDs listed in the PKCS7_set_type(3) manual. That's the whole menu, iykyk.
π RETURN VALUES π
These functions return 1 on success or 0 on failure. They fail if the contentType of outer is unsupported. PKCS7_content_new() can also fail when memory is exhausted. In case of failure, outer remains unchanged. So yeah: fail gracefully, no surprise glow-down. Slay.
π₯ SEE ALSO π₯
π STANDARDS π
RFC 2315: PKCS #7: Cryptographic Message Syntax Version 1.5
- Section 7. General syntax
- Section 9. Signed-data content type
- Section 12. Digested-data content type
Standards queen behavior, honestly.
π¦ HISTORY π¦
These functions first appeared in SSLeay 0.8.1 and have been available since OpenBSD 2.4. Vintage but still serving.
π CAVEATS π
β οΈ plot twist, bestie: despite the function names, these functions do not set thecontentfield ofouter, but only thecontentInfofield inside it. The rest of thecontentremains unchanged. So don't let the name catfish you, periodt.
okay that's the whole page β brought to you by Debian, dated May 24, 2020, and titled PKCS7_SET_CONTENT(3). mwah π
π¦ 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