BN_NEW(3SSL)
π BN_NEW(3SSL) β the BIGNUM babysitting page π
okay bestie, gather round, because this is BN_NEW(3SSL) from the OpenSSL manuals and it's literally all about making and unmaking BIGNUMs. Think of it as: how to birth a big number, and how to send it off respectfully (and sometimes, securely, into the void π).
β¨ NAME β¨
BN_new, BN_secure_new, BN_clear, BN_free, BN_clear_free β allocate and free BIGNUMs π«Ά
The whole friend group:
BN_newβ the standard issue allocator, main character energyBN_secure_newβ same but it lives in the secure heap, VIP section πBN_clearβ wipes a number's memory and zeroes it, so nobody can snoopBN_freeβ lets the pieces goBN_clear_freeβ lets the pieces go and scribbles over the data first, chaotic good
πΈ 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 π¦
BN_new() allocates and initializes a BIGNUM structure. That's it, that's the job. β¨
BN_secure_new() does the same exact thing, except the value gets stored using the secure heap, aka OPENSSL_secure_malloc(3). So if you've got secrets, this is the one you want π.
BN_clear() is your "oops, gotta destroy the evidence" bestie. Use it to destroy sensitive data β keys, the whole vibe β once you don't need them anymore. It erases the memory used by a and sets it to the value 0. And if a is NULL? Nothing happens. Nothing. We simply don't. π
BN_free() frees the components of the BIGNUM, and if it was created by BN_new(), it frees the structure itself too. π
BN_clear_free() is BN_free() but extra: it additionally overwrites the data before the memory is handed back to the system. If a is NULL, nothing is done here either. π
β RETURN VALUES β
BN_new() and BN_secure_new() return a pointer to the BIGNUM initialised to the value 0. Slay. But 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. They just do the thing. periodt.
π₯ SEE ALSO π₯
π HISTORY π
BN_init() was removed in OpenSSL 1.1.0; use BN_new() instead. She's gone, babe, we don't talk about her π
π 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>.
ngl if you're out here freeing BIGNUMs without clearing the sensitive ones first, the vibe check is failing π¨
okay that's the whole page, bestie, you ate it up π this was BN_NEW(3SSL) from the OpenSSL 4.0.3 manual, dated 2026-09-29. mwah, go allocate responsibly π§π
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms