BN_ZERO(3)
π BN_ZERO(3) β bestie's guide to BIGNUM assignment π
okay so this is a Library Functions Manual page, section 3 of the manual, and it's literally all about the BIGNUM assignment operations. yes we're starting with the meta stuff, don't @ me π
β¨ NAME β¨
BN_zero, BN_one, BN_value_one, BN_set_word, BN_get_word β BIGNUM assignment operations π
like, the whole assignment squad. setting your big numbers to stuff. iconic behaviour honestly.
πΈ SYNOPSIS πΈ
library βlibcryptoβ #include <openssl/bn.h>
void
BN_zero(BIGNUM *a);
int
BN_one(BIGNUM *a);
const BIGNUM *
BN_value_one(void);
int
BN_set_word(BIGNUM *a, BN_ULONG w);
BN_ULONG
BN_get_word(const BIGNUM *a);
look at that little lineup π«Ά it's giving "five friends who all do one (1) thing very well."
π DESCRIPTION π
okay first things first, because this is the part everyone skips and then gets confused about:
BN_ULONG is a macro that expands to an unsigned integral type optimized for the most efficient implementation on the local platform. so it's not one fixed thing, it's whatever your machine likes best. π
specifically:
unsigned long(=uint64_t) on_LP64platformsunsigned int(=uint32_t) everywhere else
not me knowing platform typedef lore π anyway.
now the actual functions, bestie:
BN_zero(),BN_one(), andBN_set_word()setato the values0,1andwrespectively. yes it's that simple. that's the whole thing. slay. β¨BN_value_one()returns aBIGNUMconstant of value1. this constant is useful for comparisons and assignments β it's basically the emotional support constant of the library π₯Ή
π¦ RETURN VALUES π¦
BN_get_word()returns the valuea, or(BN_ULONG)-1ifacannot be represented as aBN_ULONG. so if it doesn't fit, you get that big ol' sentinel value, not a crash. πBN_one()andBN_set_word()return1on success,0otherwise.BN_value_one()returns the constant.
like, straightforward. no drama. well. mostly. π
π₯ SEE ALSO π₯
go read these too, iykwyk π (ok i made that spelling up but you get it)
β HISTORY β
BN_zero(),BN_one(),BN_value_one(), andBN_set_word()first appeared in SSLeay 0.5.1 β ancient. archaeological. they've been around longer than most of us. ποΈBN_get_word()first appeared in SSLeay 0.6.0 β late to the party but it made it.- these functions have been available since OpenBSD 2.4.
fr fr they're veterans. show some respect. π
π BUGS π
okay this is the scary section, pay attention π
- Someone might change the constant. π like, literally, some person could just... do that. and then your nice little
1isn't a1anymore. be aware. - If the value of a
BIGNUMis equal to aBN_ULONGwith all bits set, the return value ofBN_get_word()collides with return value used to indicate errors. so the "everything's set" answer and the "oops error" answer look identical. genuinely cursed design ngl π so unhelpful of it. BN_ULONGshould probably be a typedef rather than a macro. the manpage said it, not me, i'm just the messenger π«Ά
and that's the page bestie!! π you now know more about BIGNUM assignment than like 90% of people who use it, no cap. go forth and assign. π
mwah π β with love from the Debian crew, dated December 15, 2025 π¦
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2021, 2022 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2000, 2001, 2018 The OpenSSL Project
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms