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

# libressl-d2i\_ASN1\_NULL(3)

decode and encode an ASN.1 NULL type

## NAME

**d2i\_ASN1\_NULL**, **i2d\_ASN1\_NULL** – decode and encode an ASN.1 NULL type

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*ASN1\_NULL* *\**\

**d2i\_ASN1\_NULL**(*ASN1\_NULL \*\*val\_out*, *const unsigned char \*\*der\_in*, *long length*);

*int*\

**i2d\_ASN1\_NULL**(*ASN1\_NULL \*val\_in*, *unsigned char \*\*der\_out*);

## DESCRIPTION

These functions decode and encode the ASN.1 value NULL of type NULL. For details about the semantics, examples, caveats, and bugs, see ASN1\_item\_d2i(3).

**d2i\_ASN1\_NULL**() verifies that the BER-encoded value at \**der\_in* is NULL and of type NULL. It fails if *length* is less than 2 or if the first two bytes of \**der\_in* differ from 0x05 and 0x00. In case of success, \**der\_in* is advanced by two bytes and \**val\_out* is set to a specific invalid pointer representing the unique *ASN1\_NULL* object.

**i2d\_ASN1\_NULL**() ignores *val\_in* and encodes the ASN.1 value NULL of type NULL using DER. Specifically, it writes the identifier octet for the type NULL, 0x05, followed by the length octet 0x00, and no content or end-of-content octets.

## RETURN VALUES

**d2i\_ASN1\_NULL**() returns a specific invalid pointer representing the unique *ASN1\_NULL* object or NULL if an error occurs.

**i2d\_ASN1\_NULL**() returns 2 if successful or 0 if an error occurs.

## SEE ALSO

ASN1\_item\_d2i(3), ASN1\_item\_new(3), ASN1\_NULL\_new(3), ASN1\_TYPE\_get(3)

## STANDARDS

ITU-T Recommendation X.690, also known as ISO/IEC 8825-1: Information technology - ASN.1 encoding rules: Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER), section 8.8: Encoding of a null value

## HISTORY

**d2i\_ASN1\_NULL**() and **i2d\_ASN1\_NULL**() first appeared in OpenSSL 0.9.5 and have been available since OpenBSD 2.7.
