BN_NEW(3ossl)
π BN_NEW(3ossl) β the OpenSSL glow-up for BIGNUM memory π
okay bestie, this is the BN_NEW(3ossl) page from the OpenSSL manual set, and it's literally all about allocating and freeing BIGNUMs. no cap, it's a short one, but it's giving essential self-care for your big numbers β¨
π NAME π
BN_new, BN_secure_new, BN_clear, BN_free, BN_clear_free β allocate and free BIGNUMs π«Ά
β¨ SYNOPSIS β¨
#include <openssl/bn.h>
BIGNUM *BN_new(void);
BIGNUM *BN_secure_new(void);
void BN_clear(BIGNUM *a);
void BN_free(BIGNUM *a);
void BN_clear_free(BIGNUM *a);
like, five little functions, all icon behavior π§
πΈ DESCRIPTION πΈ
BN_new() allocates and initializes a BIGNUM structure. BN_secure_new() is the exact same vibe except that the secure heap OPENSSL_secure_malloc(3) is the thing used to store the value. same energy, fancier storage, iykyk π₯
BN_clear() is your βwait, delete thatβ function β it's used to destroy sensitive data such as keys when they are no longer needed. it erases the memory used by a and sets it to the value 0. and if a is NULL, nothing is done. no drama, no crash, we love a graceful no-op π
BN_free() frees the components of the BIGNUM, and if it was created by BN_new(), also the structure itself. BN_clear_free() is the extra one: it additionally overwrites the data before the memory is returned to the system. π«§ again, if a is NULL, nothing is done.
ok important little note bestie:BN_clear()is the one you reach for when the data is sensitive (keys!!), andBN_clear_free()is the one you reach for when you're yeeting that sensitive data entirely. don't skip the overwrite step if the data is spicy πΆοΈ
β RETURN VALUES β
BN_new()andBN_secure_new()return a pointer to theBIGNUMinitialised to the value0. π if the allocation fails, they returnNULLand set an error code that you can grab withERR_get_error(3).BN_clear(),BN_free()andBN_clear_free()have no return values. periodt. they return nothing and they're at peace with that π
π¦ SEE ALSO π¦
ERR_get_error(3), OPENSSL_secure_malloc(3) π go read those too, they're the supporting cast
π HISTORY π
BN_init() was removed in OpenSSL 1.1.0; use BN_new() instead. rip to a real one π but like, BN_new() ate and left no crumbs, so we're fine β¨
π COPYRIGHT π
Copyright 2000-2017 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 whole page, bestie! this one's from 3.5.6, dated 2026-04-07, and it lives under BN_NEW(3ossl) in the OpenSSL docs β mwah, go free your BIGNUMs responsibly πππ¦
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms