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

# libressl-v2i\_ASN1\_BIT\_STRING(3)

ASN.1 BIT STRING utility functions for certificate extensions

## NAME

**v2i\_ASN1\_BIT\_STRING**, **i2v\_ASN1\_BIT\_STRING** – ASN.1 BIT STRING utility functions for certificate extensions

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*ASN1\_BIT\_STRING* *\**\

**v2i\_ASN1\_BIT\_STRING**(*X509V3\_EXT\_METHOD \*method*, *X509V3\_CTX \*ctx*, *STACK\_OF(CONF\_VALUE) \*nval*);

*STACK\_OF(CONF\_VALUE)* *\**\

**i2v\_ASN1\_BIT\_STRING**(*X509V3\_EXT\_METHOD \*method*, *ASN1\_BIT\_STRING \*bit\_string*, *STACK\_OF(CONF\_VALUE) \*nval*);

## DESCRIPTION

**v2i\_ASN1\_BIT\_STRING**() allocates a new ASN.1 *BIT* *STRING* object and initializes it from a list of bit names. The *nval* argument is essentially used as the list of the names of the bits to set. Both long names and short names can be used. One name is taken from each element of *nval*. The *ctx* argument and any section names or values contained in the elements of *nval* are ignored. To convert a C string containing a comma-separated list of names to the input format of this function, X509V3\_parse\_list(3) can be used.

**i2v\_ASN1\_BIT\_STRING**() translates the numbers of the bits that are set in the *bit\_string* to long names. For each bit that is set, one element containing the corresponding long name is added to *nval*. If a NULL pointer is passed for the *nval* argument, a new *STACK\_OF(CONF\_VALUE)* is allocated.

For both functions, the *method* argument is only used for the translation of bit names to bit numbers and vice versa. Any names and bit numbers that do not occur in the *usr\_data* translation table in the *method* are silently ignored.

For the following arguments, X509V3\_EXT\_get\_nid(3) returns static constant *method* objects supporting these functions:

- NID\_crl\_reason

  reason codes, RFC 5280 section 5.3.1

- NID\_key\_usage

  key usage purposes, RFC 5280 section 4.2.1.3

- NID\_netscape\_cert\_type

  Netscape certificate types (obsolete)

While an application program could theoretically provide its own *method* object containing a custom translation table, that is unlikely to be useful for any practical purpose.

## RETURN VALUES

**v2i\_ASN1\_BIT\_STRING**() returns the new *BIT* *STRING* object and **i2v\_ASN1\_BIT\_STRING**() the modified or new list of bit names. Both functions return NULL if an error occurs, in particular if memory allocation fails.

## SEE ALSO

ASN1\_BIT\_STRING\_new(3), ASN1\_BIT\_STRING\_set(3), i2s\_ASN1\_ENUMERATED\_TABLE(3), STACK\_OF(3), [tls\_peer\_ocsp\_crl\_reason(3)](/tls_peer_ocsp_crl_reason/3.md), X509\_get\_key\_usage(3), X509V3\_EXT\_get\_nid(3), X509V3\_get\_d2i(3), X509V3\_parse\_list(3)

## HISTORY

These functions first appeared in OpenSSL 0.9.8 and have been available since OpenBSD 4.5.
