PKCS7_SET_CONTENT(3)

πŸ“¦ version 4.1.0, in opensuse-leap 16.0

🌸 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 the content field of outer, but only the contentInfo field inside it. The rest of the content remains 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