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

# libressl-d2i\_BASIC\_CONSTRAINTS(3)

decode and encode X.509 key usage purposes

## NAME

**d2i\_BASIC\_CONSTRAINTS**, **i2d\_BASIC\_CONSTRAINTS**, **d2i\_EXTENDED\_KEY\_USAGE**, **i2d\_EXTENDED\_KEY\_USAGE** – decode and encode X.509 key usage purposes

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*BASIC\_CONSTRAINTS* *\**\

**d2i\_BASIC\_CONSTRAINTS**(*BASIC\_CONSTRAINTS \*\*val\_out*, *const unsigned char \*\*der\_in*, *long length*);

*int*\

**i2d\_BASIC\_CONSTRAINTS**(*BASIC\_CONSTRAINTS \*val\_in*, *unsigned char \*\*der\_out*);

*EXTENDED\_KEY\_USAGE* *\**\

**d2i\_EXTENDED\_KEY\_USAGE**(*EXTENDED\_KEY\_USAGE \*\*val\_out*, *const unsigned char \*\*der\_in*, *long length*);

*int*\

**i2d\_EXTENDED\_KEY\_USAGE**(*EXTENDED\_KEY\_USAGE \*val\_in*, *unsigned char \*\*der\_out*);

## DESCRIPTION

These functions decode and encode data structures describing the intended purposes that the key contained in an X.509 certificate is to be used for. For details about the semantics, examples, caveats, and bugs, see ASN1\_item\_d2i(3).

**d2i\_BASIC\_CONSTRAINTS**() and **i2d\_BASIC\_CONSTRAINTS**() decode and encode an ASN.1 *BasicConstraints* structure defined in RFC 5280 section 4.2.1.9.

**d2i\_EXTENDED\_KEY\_USAGE**() and **i2d\_EXTENDED\_KEY\_USAGE**() decode and encode an ASN.1 *ExtKeyUsageSyntax* structure defined in RFC 5280 section 4.2.1.12.

## RETURN VALUES

**d2i\_BASIC\_CONSTRAINTS**() and **d2i\_EXTENDED\_KEY\_USAGE**() return a *BASIC\_CONSTRAINTS* or *EXTENDED\_KEY\_USAGE* object, respectively, or NULL if an error occurs.

**i2d\_BASIC\_CONSTRAINTS**() and **i2d\_EXTENDED\_KEY\_USAGE**() return the number of bytes successfully encoded or a negative value if an error occurs.

## SEE ALSO

ASN1\_item\_d2i(3), BASIC\_CONSTRAINTS\_new(3), EXTENDED\_KEY\_USAGE\_new(3), X509\_EXTENSION\_new(3)

## STANDARDS

RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile

## HISTORY

**d2i\_BASIC\_CONSTRAINTS**() and **i2d\_BASIC\_CONSTRAINTS**() first appeared in OpenSSL 0.9.2b and have been available since OpenBSD 2.6.

**d2i\_EXTENDED\_KEY\_USAGE**() and **i2d\_EXTENDED\_KEY\_USAGE**() first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2.
