ASN1_ITEM_PACK(3) | Library Functions Manual | ASN1_ITEM_PACK(3)

# NAME

`ASN1_item_pack`, `ASN1_item_unpack` — pack an ASN.1 object into an ASN1_STRING

# SYNOPSIS

library “libcrypto”
`#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).

June 8, 2025 | Debian