PKCS7_FINAL(3)
π NAME π
okay so this is PKCS7_final(3), straight out of the Library Functions Manual, and it is literally here to read data from a BIO into a ContentInfo object. slay. π
β¨ SYNOPSIS β¨
#include <openssl/pkcs7.h>
int
PKCS7_final(PKCS7 *p7, BIO *data, int flags);
πΈ DESCRIPTION πΈ
okay bestie, here's the vibe: PKCS7_final() reads data and puts it into the appropriate content field of p7 itself or of its appropriate substructure. that substructure can be of type SignedData, EnvelopedData, SignedAndEnvelopedData, DigestedData, or arbitrary data. the PKCS7_dataFinal(3) manual explains which field exactly the data is put into. π«Ά
the following flags are recognized:
PKCS7_BINARYβ copy the data verbatim without changing any bytes. by default, line endings are replaced with two-byte"\r\n"sequences (ASCII CR+LF). if this flag is set,PKCS7_TEXTis ignored. πPKCS7_TEXTβ prepend"Content-Type: text/plain"followed by a blank line to the data. this flag is ignored ifPKCS7_BINARYis also set. β¨
if any other bits are set in flags, for example PKCS7_STREAM or PKCS7_PARTIAL, they are ignored, allowing you to pass the same flags argument that was already passed to PKCS7_sign(3) or PKCS7_encrypt(3). no cap. π
PKCS7_final() is most commonly used to finalize a p7 object returned from a call to PKCS7_sign(3) that used flags including PKCS7_PARTIAL or PKCS7_STREAM. with these flags, PKCS7_sign(3) ignores its data argument. the partial p7 object returned can then be customized, for example setting up multiple signers or non-default digest algorithms with PKCS7_sign_add_signer(3), before calling PKCS7_final(). main character energy fr fr. π
similarly, PKCS7_final() can be used to finalize a p7 object returned from a call to PKCS7_encrypt(3) that used flags including PKCS7_STREAM. π
since PKCS7_final() starts by calling PKCS7_dataInit(3) internally, using it to finalize a p7 object containing SignedAndEnvelopedData, DigestedData, or arbitrary data requires the setup described in the PKCS7_dataInit(3) manual. for SignedData and EnvelopedData, such manual setup is also feasible, but it is more easily performed with PKCS7_sign(3) or PKCS7_encrypt(3), respectively. π¦
PKCS7_final() is only one among several functions that can be used to finalize p7; alternatives include SMIME_write_PKCS7(3), PEM_write_bio_PKCS7_stream(3), and i2d_PKCS7_bio_stream(3). iykyk. π«
π«Ά RETURN VALUES π«Ά
PKCS7_final() returns 1 on success or 0 on failure. bestie, that's the whole vibe check. π
possible reasons for failure include:
p7isNULL.- the content field of
p7is empty. - the
contentTypeofp7is unsupported. - signing or digesting is requested and
p7is not configured to store a detached signature, but does not contain the required field to store the content either. - at least one signer lacks a usable digest algorithm.
- a cipher is required but none is configured.
- any required operation fails, for example signing or digesting.
- memory allocation fails.
signers lacking private keys do not cause failure but are silently skipped. π
π¦ SEE ALSO π¦
BIO_new(3)i2d_PKCS7_bio_stream(3)PEM_write_bio_PKCS7_stream(3)PKCS7_add_attribute(3)PKCS7_dataFinal(3)PKCS7_dataInit(3)PKCS7_encrypt(3)PKCS7_new(3)PKCS7_sign(3)SMIME_write_PKCS7(3)
π HISTORY π
PKCS7_final() first appeared in OpenSSL 1.0.0 and has been available since OpenBSD 4.9. iconic behavior. π
β οΈ CAVEATS β οΈ
this function does not support EncryptedData. periodt. π¨
k bye bestie! this page is from Debian, dated December 26, 2022, and you just read PKCS7_FINAL(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