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

# libressl-ASN1\_item\_pack(3)

pack an ASN.1 object into an ASN1\_STRING

## NAME

**ASN1\_item\_pack**, **ASN1\_item\_unpack** – pack an ASN.1 object into an ASN1\_STRING

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*ASN1\_STRING* *\**\

**ASN1\_item\_pack**(*void \*val\_in*, *const ASN1\_ITEM \*it*, *ASN1\_STRING \*\*string\_out*);

*void* *\**\

**ASN1\_item\_unpack**(*const ASN1\_STRING \*string\_in*, *const ASN1\_ITEM \*it*);

## DESCRIPTION

**ASN1\_item\_pack**() encodes the object pointed to by *val\_in* into DER format using ASN1\_item\_i2d(3) and stores the encoded form in \*\**string\_out*. If *string\_out* or \**string\_out* is a NULL pointer, a new *ASN1\_STRING* object is allocated and returned.

**ASN1\_item\_unpack**() interprets the data in *string\_in* as a DER- or BER-encoded byte array and decodes one value of the type *it* into a newly allocated object using ASN1\_item\_d2i(3).

## RETURN VALUES

**ASN1\_item\_pack**() returns the modified or new object or NULL if memory allocation or encoding fails.

**ASN1\_item\_unpack**() returns the new object or NULL if memory allocation or decoding fails.

## SEE ALSO

ASN1\_item\_d2i(3), ASN1\_item\_new(3), ASN1\_STRING\_new(3)

## HISTORY

**ASN1\_item\_pack**() and **ASN1\_item\_unpack**() first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2.

## BUGS

See the BUGS section in ASN1\_item\_i2d(3).
