Skip to content

ASN1_STRING_new

NAME

ASN1_STRING_new, ASN1_STRING_type_new, ASN1_STRING_free, ASN1_STRING_new_not_owned - ASN1_STRING allocation functions

SYNOPSIS

#include <openssl/asn1.h>

ASN1_STRING *ASN1_STRING_new(void);
ASN1_STRING *ASN1_STRING_type_new(int type);
ASN1_STRING *ASN1_STRING_new_not_owned(int type, const uint8_t *data, size_t length);
void ASN1_STRING_free(ASN1_STRING *a);

DESCRIPTION

ASN1_STRING_new() returns an allocated ASN1_STRING structure. Its type is undefined.

ASN1_STRING_type_new() returns an allocated ASN1_STRING structure of type type.

ASN1_STRING_new_not_owned() returns an allocated ASN1_STRING structure of type type, and sets the data returned string to the bytes at data of length len. Ownership of data is not transferred, and it is the caller's responsibility to ensure that data outlives any successfully returned result. The provided type must not be V_ASN1_BIT_STRING, the provided length must be greater than 0, and data must not be NULL. It is an error if the provided data size exceeds the internal limit of the ASN1_STRING implementation.

ASN1_STRING_free() frees up a. If a is NULL nothing is done.

NOTES

Other string types call the ASN1_STRING functions. For example ASN1_OCTET_STRING_new() calls ASN1_STRING_type_new(V_ASN1_OCTET_STRING).

ASN1_STRING_new_not_owned() does not automatically call strlen() to determine a length, or guarantee that the data is a C string. The data contained in the string and the lifetime of it are the responsibility of the caller.

RETURN VALUES

ASN1_STRING_new(), ASN1_STRING_type_new(), and ASN1_STRING_new_not_owned() return a valid ASN1_STRING structure or NULL if an error occurred.

ASN1_STRING_free() does not return a value.

SEE ALSO

ERR_get_error(3)

HISTORY

ASN1_STRING_new_not_owned() was added in OpenSSL 4.1.

Copyright 2002-2023 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.