BN_ZERO(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ’… 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 _LP64 platforms
  • unsigned int (= uint32_t) everywhere else

not me knowing platform typedef lore πŸ’€ anyway.

now the actual functions, bestie:

  • BN_zero(), BN_one(), and BN_set_word() set a to the values 0, 1 and w respectively. yes it's that simple. that's the whole thing. slay. ✨
  • BN_value_one() returns a BIGNUM constant of value 1. 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 value a, or (BN_ULONG)-1 if a cannot be represented as a BN_ULONG. so if it doesn't fit, you get that big ol' sentinel value, not a crash. πŸ™ˆ
  • BN_one() and BN_set_word() return 1 on success, 0 otherwise.
  • 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(), and BN_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 1 isn't a 1 anymore. be aware.
  • If the value of a BIGNUM is equal to a BN_ULONG with all bits set, the return value of BN_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_ULONG should 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