---
name: "libressl-d2i_X509_SIG"
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-d2i_X509_SIG"
---

# libressl-d2i\_X509\_SIG(3)

decode and encode PKCS#7 digest information

## NAME

**d2i\_X509\_SIG**, **i2d\_X509\_SIG**, **d2i\_PKCS8\_bio**, **i2d\_PKCS8\_bio**, **d2i\_PKCS8\_fp**, **i2d\_PKCS8\_fp** – decode and encode PKCS#7 digest information

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*X509\_SIG* *\**\

**d2i\_X509\_SIG**(*X509\_SIG \*\*val\_out*, *const unsigned char \*\*der\_in*, *long length*);

*int*\

**i2d\_X509\_SIG**(*X509\_SIG \*val\_in*, *unsigned char \*\*der\_out*);

*X509\_SIG* *\**\

**d2i\_PKCS8\_bio**(*BIO \*in\_bio*, *X509\_SIG \*\*val\_out*);

*int*\

**i2d\_PKCS8\_bio**(*BIO \*out\_bio*, *X509\_SIG \*val\_in*);

*X509\_SIG* *\**\

**d2i\_PKCS8\_fp**(*FILE \*in\_fp*, *X509\_SIG \*\*val\_out*);

*int*\

**i2d\_PKCS8\_fp**(*FILE \*out\_fp*, *X509\_SIG \*val\_in*);

## DESCRIPTION

**d2i\_X509\_SIG**() and **i2d\_X509\_SIG**() decode and encode an ASN.1 *DigestInfo* structure defined in RFC 2315 section 9.4 and equivalently in RFC 8017 section 9.2. For details about the semantics, examples, caveats, and bugs, see ASN1\_item\_d2i(3).

**d2i\_PKCS8\_bio**() and **d2i\_PKCS8\_fp**() are similar to **d2i\_X509\_SIG**() except that they read from a *BIO* or *FILE* pointer.

**i2d\_PKCS8\_bio**() and **i2d\_PKCS8\_fp**() are similar to **i2d\_X509\_SIG**() except that they write to a *BIO* or *FILE* pointer.

## RETURN VALUES

**d2i\_X509\_SIG**(), **d2i\_PKCS8\_bio**(), and **d2i\_PKCS8\_fp**() return an *X509\_SIG* object or NULL if an error occurs.

**i2d\_X509\_SIG**() returns the number of bytes successfully encoded or a negative value if an error occurs.

**i2d\_PKCS8\_bio**() and **i2d\_PKCS8\_fp**() return 1 for success or 0 if an error occurs.

## SEE ALSO

ASN1\_item\_d2i(3), PKCS7\_new(3), RSA\_sign(3), X509\_SIG\_new(3)

## STANDARDS

RFC 2315: PKCS #7: Cryptographic Message Syntax, section 9: Signed-data content type

RFC 8017: PKCS #1: RSA Cryptography Specifications, section 9: Encoding Methods for Signatures

## HISTORY

**d2i\_X509\_SIG**() and **i2d\_X509\_SIG**() first appeared in SSLeay 0.5.1 and have been available since OpenBSD 2.4.

**d2i\_PKCS8\_bio**(), **i2d\_PKCS8\_bio**(), **d2i\_PKCS8\_fp**(), and **i2d\_PKCS8\_fp**() first appeared in OpenSSL 0.9.4 and have been available since OpenBSD 2.6.

## BUGS

**d2i\_PKCS8\_bio**(), **i2d\_PKCS8\_bio**(), **d2i\_PKCS8\_fp**(), and **i2d\_PKCS8\_fp**() are severely misnamed and should have been called “d2i\_X509\_SIG\_bio” and so on.

Or arguably, the *X509\_SIG* object is misnamed itself, considering that it represents *DigestInfo* from PKCS#7 and PKCS#1. Then again, calling it “PKCS8” instead clearly isn't an improvement.

Either way, these names just don't fit.
