ASN1_STRING_NEW(3ssl)

πŸ“¦ version 4.1.0, in nixos 26.05, nixpkgs unstable

πŸ’… ASN1_STRING_NEW β€” the ASN1_STRING allocation girlies

okay so bestie, this is the 3ssl manual page for ASN1_STRING_NEW, and it's literally all about making and unmaking ASN1_STRING structures. allocation functions, that's the vibe. let's get into it ✨


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

like, copy-paste it exactly pls, don't be out here retyping signatures from memory 😭


πŸ’– DESCRIPTION πŸ’–

  • ASN1_STRING_new() β€” hands you back an allocated ASN1_STRING structure. its type? undefined. literally no type. it's giving "figuring itself out" energy πŸ¦‹
  • ASN1_STRING_type_new() β€” same deal, an allocated ASN1_STRING structure, except this one is of type type. you're deciding for it. main character move πŸ‘‘
  • ASN1_STRING_new_not_owned() β€” returns an allocated ASN1_STRING structure of type type, and sets the data of the returned string to the bytes at data of length len. and here's the key part, bestie β€” ownership of data is NOT transferred. it is the caller's responsibility to make sure data outlives any successfully returned result. so like, keep it alive, don't let it get freed out from under you πŸ™ˆ

also the rules for this one, and they are strict:

  • the provided type must not be V_ASN1_BIT_STRING
  • the provided length must be greater than 0
  • data must not be NULL
  • and it is an error if the provided data size exceeds the internal limit of the ASN1_STRING implementation πŸ’€
  • ASN1_STRING_free() β€” frees a. and if a is NULL, nothing is done. no drama, no crash, it just ✨nothing✨

πŸŽ€ NOTES πŸŽ€

other string types call the ASN1_STRING functions, iykyk. for example, ASN1_OCTET_STRING_new() calls ASN1_STRING_type_new(V_ASN1_OCTET_STRING). see? they're all connected, it's a whole ecosystem 🌈

ASN1_STRING_new_not_owned() does not automatically call strlen() to figure out a length, and it does not guarantee that the data is a C string. nope! the data contained in the string and the lifetime of it are 100% the responsibility of the caller. you're on your own with that one bestie, no cap 🫢


⭐ 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 😭 so like, always check. always.

ASN1_STRING_free() does not return a value. it's a void girlie, she gives nothing back and that's fine πŸ’…


πŸ¦‹ SEE ALSO πŸ¦‹

  • ERR_get_error(3) β€” go read it, it's how you find out what went wrong πŸ‘€

πŸ”₯ HISTORY πŸ”₯

ASN1_STRING_new_not_owned() was added in OpenSSL 4.1. new girl on the block, freshly iconic ✨


Copyright 2002-2026 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>.


and that's the page bestie!! this one's from version 4.1.0, dated 2026-10-23, and it's the ASN1_STRING_NEW(3ssl) manual β€” go forth and allocate responsibly πŸ“πŸ’œπŸ§š

πŸ“¦ where this page comes from