libressl-ASN1_item_pack(3)

libressl-ASN1_item_pack3

Pack an asn.1 object into an asn1_string

Usage

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);

Overview

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.

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).

From libressl 4.4.0-1 in Arch Linux 2026-11-01. Parsed by carta from the page's mdoc source.