BN_NEW(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’– 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!!), and BN_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() and BN_secure_new() return a pointer to the BIGNUM initialised to the value 0. πŸ“ if the allocation fails, they return NULL and set an error code that you can grab with ERR_get_error(3).
  • BN_clear(), BN_free() and BN_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 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