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

# libressl-ASN1\_STRING\_new(3)

allocate and free ASN1\_STRING objects

## NAME

**ASN1\_STRING\_new**, **ASN1\_STRING\_type\_new**, **ASN1\_STRING\_free**, **ASN1\_OCTET\_STRING\_new**, **ASN1\_OCTET\_STRING\_free**, **ASN1\_BIT\_STRING\_new**, **ASN1\_BIT\_STRING\_free**, **ASN1\_INTEGER\_new**, **ASN1\_INTEGER\_free**, **ASN1\_ENUMERATED\_new**, **ASN1\_ENUMERATED\_free**, **ASN1\_UTF8STRING\_new**, **ASN1\_UTF8STRING\_free**, **ASN1\_IA5STRING\_new**, **ASN1\_IA5STRING\_free**, **ASN1\_UNIVERSALSTRING\_new**, **ASN1\_UNIVERSALSTRING\_free**, **ASN1\_BMPSTRING\_new**, **ASN1\_BMPSTRING\_free**, **ASN1\_GENERALSTRING\_new**, **ASN1\_GENERALSTRING\_free**, **ASN1\_T61STRING\_new**, **ASN1\_T61STRING\_free**, **ASN1\_VISIBLESTRING\_new**, **ASN1\_VISIBLESTRING\_free**, **ASN1\_PRINTABLESTRING\_new**, **ASN1\_PRINTABLESTRING\_free**, **ASN1\_PRINTABLE\_new**, **ASN1\_PRINTABLE\_free**, **DIRECTORYSTRING\_new**, **DIRECTORYSTRING\_free**, **DISPLAYTEXT\_new**, **DISPLAYTEXT\_free**, **ASN1\_GENERALIZEDTIME\_new**, **ASN1\_GENERALIZEDTIME\_free**, **ASN1\_UTCTIME\_new**, **ASN1\_UTCTIME\_free**, **ASN1\_TIME\_new**, **ASN1\_TIME\_free** – allocate and free ASN1\_STRING objects

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*ASN1\_STRING* *\**\

**ASN1\_STRING\_new**(*void*);

*ASN1\_STRING* *\**\

**ASN1\_STRING\_type\_new**(*int type*);

*void*\

**ASN1\_STRING\_free**(*ASN1\_STRING \*a*);

*ASN1\_OCTET\_STRING* *\**\

**ASN1\_OCTET\_STRING\_new**(*void*);

*void*\

**ASN1\_OCTET\_STRING\_free**(*ASN1\_OCTET\_STRING \*a*);

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

**ASN1\_BIT\_STRING\_new**(*void*);

*void*\

**ASN1\_BIT\_STRING\_free**(*ASN1\_BIT\_STRING \*a*);

*ASN1\_INTEGER* *\**\

**ASN1\_INTEGER\_new**(*void*);

*void*\

**ASN1\_INTEGER\_free**(*ASN1\_INTEGER \*a*);

*ASN1\_ENUMERATED* *\**\

**ASN1\_ENUMERATED\_new**(*void*);

*void*\

**ASN1\_ENUMERATED\_free**(*ASN1\_ENUMERATED \*a*);

*ASN1\_UTF8STRING* *\**\

**ASN1\_UTF8STRING\_new**(*void*);

*void*\

**ASN1\_UTF8STRING\_free**(*ASN1\_UTF8STRING \*a*);

*ASN1\_IA5STRING* *\**\

**ASN1\_IA5STRING\_new**(*void*);

*void*\

**ASN1\_IA5STRING\_free**(*ASN1\_IA5STRING \*a*);

*ASN1\_UNIVERSALSTRING* *\**\

**ASN1\_UNIVERSALSTRING\_new**(*void*);

*void*\

**ASN1\_UNIVERSALSTRING\_free**(*ASN1\_UNIVERSALSTRING \*a*);

*ASN1\_BMPSTRING* *\**\

**ASN1\_BMPSTRING\_new**(*void*);

*void*\

**ASN1\_BMPSTRING\_free**(*ASN1\_BMPSTRING \*a*);

*ASN1\_GENERALSTRING* *\**\

**ASN1\_GENERALSTRING\_new**(*void*);

*void*\

**ASN1\_GENERALSTRING\_free**(*ASN1\_GENERALSTRING \*a*);

*ASN1\_T61STRING* *\**\

**ASN1\_T61STRING\_new**(*void*);

*void*\

**ASN1\_T61STRING\_free**(*ASN1\_T61STRING \*a*);

*ASN1\_VISIBLESTRING* *\**\

**ASN1\_VISIBLESTRING\_new**(*void*);

*void*\

**ASN1\_VISIBLESTRING\_free**(*ASN1\_VISIBLESTRING \*a*);

*ASN1\_PRINTABLESTRING* *\**\

**ASN1\_PRINTABLESTRING\_new**(*void*);

*void*\

**ASN1\_PRINTABLESTRING\_free**(*ASN1\_PRINTABLESTRING \*a*);

*ASN1\_STRING* *\**\

**ASN1\_PRINTABLE\_new**(*void*);

*void*\

**ASN1\_PRINTABLE\_free**(*ASN1\_STRING \*a*);

*ASN1\_STRING* *\**\

**DIRECTORYSTRING\_new**(*void*);

*void*\

**DIRECTORYSTRING\_free**(*ASN1\_STRING \*a*);

*ASN1\_STRING* *\**\

**DISPLAYTEXT\_new**(*void*);

*void*\

**DISPLAYTEXT\_free**(*ASN1\_STRING \*a*);

*ASN1\_GENERALIZEDTIME* *\**\

**ASN1\_GENERALIZEDTIME\_new**(*void*);

*void*\

**ASN1\_GENERALIZEDTIME\_free**(*ASN1\_GENERALIZEDTIME \*a*);

*ASN1\_UTCTIME* *\**\

**ASN1\_UTCTIME\_new**(*void*);

*void*\

**ASN1\_UTCTIME\_free**(*ASN1\_UTCTIME \*a*);

*ASN1\_TIME* *\**\

**ASN1\_TIME\_new**(*void*);

*void*\

**ASN1\_TIME\_free**(*ASN1\_TIME \*a*);

## DESCRIPTION

The *ASN1\_STRING* object can represent a variety of ASN.1 built-in types. It can store a type and a value.

All the **\*\_new**() functions allocate and initialize an empty *ASN1\_STRING* object. The following table shows the type assigned to the new object, and which ASN.1 type it represents.

| | | |
| --- | --- | --- |
| *constructor* *function* | *OpenSSL* *type* | *ASN.1* *type* |
|  |  |
| **ASN1\_STRING\_new**() | V\_ASN1\_OCTET\_STRING |
| **ASN1\_STRING\_type\_new**() | *type* argument |
|  |  |
| **ASN1\_OCTET\_STRING\_new**() | V\_ASN1\_OCTET\_STRING | OCTET STRING |
| **ASN1\_BIT\_STRING\_new**() | V\_ASN1\_BIT\_STRING | BIT STRING |
| **ASN1\_INTEGER\_new**() | V\_ASN1\_INTEGER | INTEGER |
| **ASN1\_ENUMERATED\_new**() | V\_ASN1\_ENUMERATED | ENUMERATED |
|  |  |
| **ASN1\_UTF8STRING\_new**() | V\_ASN1\_UTF8STRING | UTF8String |
| **ASN1\_IA5STRING\_new**() | V\_ASN1\_IA5STRING | IA5String |
|  |  |
| **ASN1\_UNIVERSALSTRING\_new**() | V\_ASN1\_UNIVERSALSTRING | UniversalString |
| **ASN1\_BMPSTRING\_new**() | V\_ASN1\_BMPSTRING | BMPString |
| **ASN1\_GENERALSTRING\_new**() | V\_ASN1\_GENERALSTRING | GeneralString |
| **ASN1\_T61STRING\_new**() | V\_ASN1\_T61STRING | T61String |
| **ASN1\_VISIBLESTRING\_new**() | V\_ASN1\_VISIBLESTRING | VisibleString |
| **ASN1\_PRINTABLESTRING\_new**() | V\_ASN1\_PRINTABLESTRING | PrintableString |
|  |  |
| **ASN1\_PRINTABLE\_new**() | V\_ASN1\_UNDEF |
| **DIRECTORYSTRING\_new**() | V\_ASN1\_UNDEF |
| **DISPLAYTEXT\_new**() | V\_ASN1\_UNDEF |
|  |  |
| **ASN1\_GENERALIZEDTIME\_new**() | V\_ASN1\_GENERALIZEDTIME | GeneralizedTime |
| **ASN1\_UTCTIME\_new**() | V\_ASN1\_UTCTIME | UTCTime |
| **ASN1\_TIME\_new**() | V\_ASN1\_UNDEF | TIME |

All the **\*\_free**() functions free *a* including any data contained in it. If *a* is a NULL pointer, no action occurs.

## RETURN VALUES

All the **\*\_new**() functions return the new *ASN1\_STRING* object if successful; otherwise NULL is returned and an error code can be retrieved with ERR\_get\_error(3).

## SEE ALSO

a2i\_ipadd(3), ASN1\_BIT\_STRING\_set(3), ASN1\_INTEGER\_get(3), ASN1\_item\_pack(3), ASN1\_mbstring\_copy(3), ASN1\_PRINTABLE\_type(3), ASN1\_STRING\_length(3), ASN1\_STRING\_print\_ex(3), ASN1\_TIME\_set(3), ASN1\_TYPE\_get(3), ASN1\_UNIVERSALSTRING\_to\_string(3), d2i\_ASN1\_OBJECT(3), d2i\_ASN1\_OCTET\_STRING(3), i2a\_ASN1\_STRING(3), s2i\_ASN1\_INTEGER(3), X509\_cmp\_time(3), X509\_EXTENSION\_get\_object(3), X509\_get\_ext\_by\_OBJ(3), X509\_NAME\_ENTRY\_get\_object(3)

## HISTORY

**ASN1\_OCTET\_STRING\_new**(), **ASN1\_OCTET\_STRING\_free**(), **ASN1\_BIT\_STRING\_new**(), **ASN1\_BIT\_STRING\_free**(), **ASN1\_INTEGER\_new**(), **ASN1\_INTEGER\_free**(), **ASN1\_IA5STRING\_new**(), **ASN1\_IA5STRING\_free**(), **ASN1\_T61STRING\_new**(), **ASN1\_T61STRING\_free**(), **ASN1\_PRINTABLESTRING\_new**(), **ASN1\_PRINTABLESTRING\_free**(), **ASN1\_PRINTABLE\_new**(), **ASN1\_PRINTABLE\_free**(), **ASN1\_UTCTIME\_new**(), and **ASN1\_UTCTIME\_free**() first appeared in SSLeay 0.5.1. **ASN1\_STRING\_new**(), **ASN1\_STRING\_type\_new**(), and **ASN1\_STRING\_free**() first appeared in SSLeay 0.6.5. **ASN1\_UNIVERSALSTRING\_new**(), **ASN1\_UNIVERSALSTRING\_free**(), **ASN1\_GENERALSTRING\_new**(), and **ASN1\_GENERALSTRING\_free**() first appeared in SSLeay 0.8.0. **ASN1\_BMPSTRING\_new**(), **ASN1\_BMPSTRING\_free**(), **ASN1\_GENERALIZEDTIME\_new**(), and **ASN1\_GENERALIZEDTIME\_free**() first appeared in SSLeay 0.9.0. All these functions have been available since OpenBSD 2.4.

**ASN1\_ENUMERATED\_new**(), **ASN1\_ENUMERATED\_free**(), **ASN1\_TIME\_new**(), and **ASN1\_TIME\_free**() first appeared in OpenSSL 0.9.2b. **ASN1\_UTF8STRING\_new**(), **ASN1\_UTF8STRING\_free**(), **ASN1\_VISIBLESTRING\_new**(), **ASN1\_VISIBLESTRING\_free**(), **DIRECTORYSTRING\_new**(), **DIRECTORYSTRING\_free**(), **DISPLAYTEXT\_new**(), and **DISPLAYTEXT\_free**() first appeared in OpenSSL 0.9.3. These functions have been available since OpenBSD 2.6.

## BUGS

*ASN1\_OCTET\_STRING*, *ASN1\_BIT\_STRING*, *ASN1\_INTEGER*, *ASN1\_ENUMERATED*, *ASN1\_UTF8STRING*, *ASN1\_IA5STRING*, *ASN1\_UNIVERSALSTRING*, *ASN1\_BMPSTRING*, *ASN1\_GENERALSTRING*, *ASN1\_T61STRING*, *ASN1\_VISIBLESTRING*, *ASN1\_PRINTABLESTRING*, *ASN1\_GENERALIZEDTIME*, *ASN1\_UTCTIME*, and *ASN1\_TIME* are merely typedef aliases of *ASN1\_STRING* and provide no type safety whatsoever.
