---
name: "libressl-PKCS7_new"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-PKCS7_new"
---

# libressl-PKCS7\_new(3)

PKCS#7 data structures

## NAME

**PKCS7\_new**, **PKCS7\_free**, **PKCS7\_SIGNED\_new**, **PKCS7\_SIGNED\_free**, **PKCS7\_ENVELOPE\_new**, **PKCS7\_ENVELOPE\_free**, **PKCS7\_SIGN\_ENVELOPE\_new**, **PKCS7\_SIGN\_ENVELOPE\_free**, **PKCS7\_DIGEST\_new**, **PKCS7\_DIGEST\_free**, **PKCS7\_ENCRYPT\_new**, **PKCS7\_ENCRYPT\_free**, **PKCS7\_ENC\_CONTENT\_new**, **PKCS7\_ENC\_CONTENT\_free**, **PKCS7\_SIGNER\_INFO\_new**, **PKCS7\_SIGNER\_INFO\_free**, **PKCS7\_RECIP\_INFO\_new**, **PKCS7\_RECIP\_INFO\_free**, **PKCS7\_ISSUER\_AND\_SERIAL\_new**, **PKCS7\_ISSUER\_AND\_SERIAL\_free** – PKCS#7 data structures

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/pkcs7.h\>**

*PKCS7* *\**\

**PKCS7\_new**(*void*);

*void*\

**PKCS7\_free**(*PKCS7 \*p7*);

*PKCS7\_SIGNED* *\**\

**PKCS7\_SIGNED\_new**(*void*);

*void*\

**PKCS7\_SIGNED\_free**(*PKCS7\_SIGNED \*signed*);

*PKCS7\_ENVELOPE* *\**\

**PKCS7\_ENVELOPE\_new**(*void*);

*void*\

**PKCS7\_ENVELOPE\_free**(*PKCS7\_ENVELOPE \*envelope*);

*PKCS7\_SIGN\_ENVELOPE* *\**\

**PKCS7\_SIGN\_ENVELOPE\_new**(*void*);

*void*\

**PKCS7\_SIGN\_ENVELOPE\_free**(*PKCS7\_SIGN\_ENVELOPE \*signed\_envelope*);

*PKCS7\_DIGEST* *\**\

**PKCS7\_DIGEST\_new**(*void*);

*void*\

**PKCS7\_DIGEST\_free**(*PKCS7\_DIGEST \*digested*);

*PKCS7\_ENCRYPT* *\**\

**PKCS7\_ENCRYPT\_new**(*void*);

*void*\

**PKCS7\_ENCRYPT\_free**(*PKCS7\_ENCRYPT \*encrypted*);

*PKCS7\_ENC\_CONTENT* *\**\

**PKCS7\_ENC\_CONTENT\_new**(*void*);

*void*\

**PKCS7\_ENC\_CONTENT\_free**(*PKCS7\_ENC\_CONTENT \*content*);

*PKCS7\_SIGNER\_INFO* *\**\

**PKCS7\_SIGNER\_INFO\_new**(*void*);

*void*\

**PKCS7\_SIGNER\_INFO\_free**(*PKCS7\_SIGNER\_INFO \*signer*);

*PKCS7\_RECIP\_INFO* *\**\

**PKCS7\_RECIP\_INFO\_new**(*void*);

*void*\

**PKCS7\_RECIP\_INFO\_free**(*PKCS7\_RECIP\_INFO \*recip*);

*PKCS7\_ISSUER\_AND\_SERIAL* *\**\

**PKCS7\_ISSUER\_AND\_SERIAL\_new**(*void*);

*void*\

**PKCS7\_ISSUER\_AND\_SERIAL\_free**(*PKCS7\_ISSUER\_AND\_SERIAL \*cert*);

## DESCRIPTION

PKCS#7 is an ASN.1-based format for transmitting data that has cryptography applied to it, in particular signed and encrypted data.

**PKCS7\_new**() allocates and initializes an empty *PKCS7* object, representing an ASN.1 *ContentInfo* structure defined in RFC 2315 section 7. It is the top-level data structure able to hold any kind of content that can be transmitted using PKCS#7. It can be used recursively in *PKCS7\_SIGNED* and *PKCS7\_DIGEST* objects. **PKCS7\_free**() frees *p7*.

**PKCS7\_SIGNED\_new**() allocates and initializes an empty *PKCS7\_SIGNED* object, representing an ASN.1 *SignedData* structure defined in RFC 2315 section 9. It can be used inside *PKCS7* objects and holds any kind of content together with signatures by zero or more signers and information about the signing algorithm and certificates used. **PKCS7\_SIGNED\_free**() frees *signed*.

**PKCS7\_ENVELOPE\_new**() allocates and initializes an empty *PKCS7\_ENVELOPE* object, representing an ASN.1 *EnvelopedData* structure defined in RFC 2315 section 10. It can be used inside *PKCS7* objects and holds any kind of encrypted content together with content-encryption keys for one or more recipients. **PKCS7\_ENVELOPE\_free**() frees *envelope*.

**PKCS7\_SIGN\_ENVELOPE\_new**() allocates and initializes an empty *PKCS7\_SIGN\_ENVELOPE* object, representing an ASN.1 *SignedAndEnvelopedData* structure defined in RFC 2315 section 11. It can be used inside *PKCS7* objects and holds any kind of encrypted content together with signatures by one or more signers, information about the signing algorithm and certificates used, and content-encryption keys for one or more recipients. **PKCS7\_SIGN\_ENVELOPE\_free**() frees *signed\_envelope*.

**PKCS7\_DIGEST\_new**() allocates and initializes an empty *PKCS7\_DIGEST* object, representing an ASN.1 *DigestedData* structure defined in RFC 2315 section 12. It can be used inside *PKCS7* objects and holds any kind of content together with a message digest for checking its integrity and information about the algorithm used. **PKCS7\_DIGEST\_free**() frees *digested*.

**PKCS7\_ENCRYPT\_new**() allocates and initializes an empty *PKCS7\_ENCRYPT* object, representing an ASN.1 *EncryptedData* structure defined in RFC 2315 section 13. It can be used inside *PKCS7* objects and holds any kind of encrypted content. Keys are not included and need to be communicated separately. **PKCS7\_ENCRYPT\_free**() frees *encrypted*.

**PKCS7\_ENC\_CONTENT\_new**() allocates and initializes an empty *PKCS7\_ENC\_CONTENT* object, representing an ASN.1 *EncryptedContentInfo* structure defined in RFC 2315 section 10.1. It can be used inside *PKCS7\_ENVELOPE*, *PKCS7\_SIGN\_ENVELOPE*, and *PKCS7\_ENCRYPT* objects and holds encrypted content together with information about the encryption algorithm used. **PKCS7\_ENC\_CONTENT\_free**() frees *content*.

**PKCS7\_SIGNER\_INFO\_new**() allocates and initializes an empty *PKCS7\_SIGNER\_INFO* object, representing an ASN.1 *SignerInfo* structure defined in RFC 2315 section 9.2. It can be used inside *PKCS7\_SIGNED* and *PKCS7\_SIGN\_ENVELOPE* objects and holds a signature together with information about the signer and the algorithms used. **PKCS7\_SIGNER\_INFO\_free**() frees *signer*.

**PKCS7\_RECIP\_INFO\_new**() allocates and initializes an empty *PKCS7\_RECIP\_INFO* object, representing an ASN.1 *RecipientInfo* structure defined in RFC 2315 section 10.2. It can be used inside *PKCS7\_ENVELOPE* and *PKCS7\_SIGN\_ENVELOPE* objects and holds a content-encryption key together with information about the intended recipient and the key encryption algorithm used. **PKCS7\_RECIP\_INFO\_free**() frees *recip*.

**PKCS7\_ISSUER\_AND\_SERIAL\_new**() allocates and initializes an empty *PKCS7\_ISSUER\_AND\_SERIAL* object, representing an ASN.1 *IssuerAndSerialNumber* structure defined in RFC 2315 section 6.7. It can be used inside *PKCS7\_SIGNER\_INFO* and *PKCS7\_RECIP\_INFO* objects and identifies a certificate by holding the distinguished name of the certificate issuer and an issuer-specific certificate serial number. **PKCS7\_ISSUER\_AND\_SERIAL\_free**() frees *cert*.

## SEE ALSO

[crypto(3)](/crypto/3.md), d2i\_PKCS7(3), i2d\_PKCS7\_bio\_stream(3), PEM\_read\_PKCS7(3), PEM\_write\_bio\_PKCS7\_stream(3), PKCS7\_add\_attribute(3), PKCS7\_dataFinal(3), PKCS7\_dataInit(3), PKCS7\_decrypt(3), PKCS7\_encrypt(3), PKCS7\_final(3), PKCS7\_get\_signer\_info(3), PKCS7\_ISSUER\_AND\_SERIAL\_digest(3), PKCS7\_set\_content(3), PKCS7\_set\_type(3), PKCS7\_sign(3), PKCS7\_sign\_add\_signer(3), PKCS7\_verify(3), SMIME\_read\_PKCS7(3), SMIME\_write\_PKCS7(3)

## STANDARDS

RFC 2315: PKCS #7: Cryptographic Message Syntax Version 1.5

## HISTORY

These functions first appeared in SSLeay 0.5.1 and have been available since OpenBSD 2.4.
