OpenBSD manual page server

Manual Page Search Parameters

PKCS7_SET_TYPE(3) Library Functions Manual PKCS7_SET_TYPE(3)

PKCS7_set_type, PKCS7_set0_type_otherinitialize type of PKCS#7 ContentInfo

#include <openssl/pkcs7.h>

int
PKCS7_set_type(PKCS7 *p7, int type);

int
PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *content);

These functions set the type of an unused ContentInfo structure p7.

The function () 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:

type argument data type of child version
ASN1_OCTET_STRING n.a.
PKCS7_DIGEST 0
PKCS7_ENCRYPT 0
PKCS7_ENVELOPE 0
PKCS7_SIGNED 1
PKCS7_SIGN_ENVELOPE 1

If the provided type is invalid, p7 remains unchanged and () fails.

If memory allocation fails, () fails and p7 may remain in an inconsistent state.

The function () accepts an arbitrary NID as the type and also sets the content, neither checking it in any way nor copying it.

For both functions, the rest of the internal state of p7 remains unchanged.

The function PKCS7_set_type() returns 1 on success or 0 on failure.

The function PKCS7_set0_type_other() does no error handling at all and always returns 1.

ASN1_OCTET_STRING_new(3), ASN1_TYPE_new(3), PKCS7_encrypt(3), PKCS7_new(3), PKCS7_set_content(3), PKCS7_sign(3)

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.

If p7 has already been in use before being passed to one of these functions, it will report success even though it leaks memory. Later on, if other functions try to use p7 in its former role, they are likely to misbehave.

May 20, 2020 OpenBSD-7.3