BN_NEW(3ossl)
π NAME π
BN_new, BN_secure_new, BN_clear, BN_free, BN_clear_free β the whole "make a BIGNUM, then clean up after yourself" situation, bestie. It's giving memory management, it's giving big numbers, it's giving don't leak, babe. β¨
π 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);
π¦ DESCRIPTION π¦
Okay so, BN_new() allocates and initializes a BIGNUM structure. Iconic. Main character. It's literally making you a big number out of thin air. π
BN_secure_new() does the exact same thing, no notes β except that the secure heap OPENSSL_secure_malloc(3) is used to store the value. Same energy, fancier closet. π
BN_clear() is the one you call when you're done with sensitive data like keys and you do not want them just vibing in memory. It erases the memory used by a and sets it to the value 0. And if a is NULL? Nothing happens. No drama, no crash. π«Ά
BN_free() frees the components of the BIGNUM, and if it was created by BN_new(), it frees the structure itself too. Like, the whole thing, gone. β¨
BN_clear_free() is BN_free() but extra β it additionally overwrites the data before the memory is returned to the system. If a is NULL, nothing is done. Same chill energy. π
Real talk bestie: if you've got keys or secrets in aBIGNUM, you wantBN_clear()orBN_clear_free(), not just a plain free. Leaving sensitive data lying around in memory is not the move. π«
πΈ RETURN VALUES πΈ
BN_new() and BN_secure_new() return a pointer to the BIGNUM initialised to the value 0. Zero! Starting fresh! Clean slate! π§
If the allocation fails, they return NULL and set an error code that you can grab with ERR_get_error(3). So like, if you get a NULL, don't just stare at it β go get that error code. π
BN_clear(), BN_free() and BN_clear_free() have no return values. They just do the thing. Periodt. π
π SEE ALSO π
β HISTORY β
Fun little lore drop for you: BN_init() was removed in OpenSSL 1.1.0. If you're out here still calling it, that's a no from the compiler. Use BN_new() instead. We love growth. π±
π 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.
Okay that's the whole page, bestie, you ate that. This was OpenSSL 3.5.9, dated 2026-09-29, and it lives at BN_NEW(3ossl) in the manual. Go free your BIGNUMs. πβ¨π¦
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms