PKCS7_DATAFINAL(3)
β¨ NAME β¨
okay bestie, this page is PKCS7_DATAFINAL(3), from the Library Functions Manual π«Ά and it's all about PKCS7_dataFinal β move data from a BIO chain to a ContentInfo object. slay.
π¦ SYNOPSIS π¦
#include <openssl/pkcs7.h>
int
PKCS7_dataFinal(PKCS7 *p7, BIO *chain);
π DESCRIPTION π
PKCS7_dataFinal() transfers the data from the memory BIO at the end of the given chain into the appropriate content field of p7 itself or of its appropriate substructure. Itβs typically used as the final step of populating p7, after creating the chain with PKCS7_dataInit(3) and after writing the data into it. periodt β¨
After calling PKCS7_dataFinal(), the program can call BIO_free_all(3) on the chain because such chains are not designed for reuse π
ββοΈπ
.
Depending on the contentType of p7, PKCS7_dataFinal() sets the following fields:
- for
SignedDataorDigestedData: in substructures of thecontentfield ofp7: thecontentfield in theContentInfostructure (unlessp7is configured to store a detached signature) and theencryptedDigestfields in all theSignerInfostructures - for
EnvelopedDataorSignedAndEnvelopedData: theencryptedContentfield in theEncryptedContentInfostructure contained in thecontentfield ofp7 - for arbitrary data: the
contentfield ofp7itself
π RETURN VALUES π
PKCS7_dataFinal() returns 1 on success or 0 on failure π.
Possible reasons for failure include:
p7isNULL.- The
contentfield ofp7is empty. - The
contentTypeofp7is unsupported. - The chain does not contain the expected memory
BIO. - Signing or digesting is requested and
p7is not configured to store a detached signature, but does not contain the required field to store thecontenteither. - At least one signer lacks a usable digest algorithm.
- Signing or digesting fails.
- Memory allocation fails.
Signers lacking private keys do not cause failure but are silently skipped π€«.
π SEE ALSO π
BIO_new(3), PKCS7_dataInit(3), PKCS7_final(3), PKCS7_new(3), PKCS7_sign(3) π
π§ HISTORY π§
PKCS7_dataFinal() first appeared in SSLeay 0.9.1 and has been available since OpenBSD 2.6. iconic π
β οΈ CAVEATS β οΈ
This function does not support EncryptedData. no cap π«
Even though this function is typically used after PKCS7_dataInit(3) and even though PKCS7_dataInit(3) also supports reading from ContentInfo structures that are already fully populated, do not use PKCS7_dataFinal() on fully populated structures. It is only intended for putting data into new structures and it is neither needed nor suitable for reading π.
bestie, read that caveat again: fully populatedContentInfostructure = not the vibe forPKCS7_dataFinal(). It's for new structures only. π
xoxo, Debian β December 26, 2022 π
π¦ 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