BN_ZERO(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… BN_ZERO(3ossl) β€” the OpenSSL one, bestie

Okay so this page is all about BIGNUM assignment operations, and it lives in the OpenSSL manual. That's the vibe. Let's get into it 🫢


✨ NAME ✨

BN_zero, BN_one, BN_value_one, BN_set_word, BN_get_word β€” literally just BIGNUM assignment operations. Setting numbers. That's the whole gig. πŸŽ€


🌸 SYNOPSIS 🌸

#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);
unsigned BN_ULONG BN_get_word(BIGNUM *a);

(Yes, that last line really does say unsigned BN_ULONG. We'll get to that. It's giving cursed, and the BUGS section is gonna confirm your suspicions 😭)


πŸ¦‹ DESCRIPTION πŸ¦‹

So first off: BN_ULONG is a macro, not a typedef, and it expands to an unsigned integral type that's optimized for the most efficient implementation on the local platform. Local platform agenda πŸ’…

Now the actual functions:

  • BN_zero(), BN_one() and BN_set_word() set a to the values 0, 1 and w respectively. That's it, that's the assignment. No cap.
  • Also lowkey important: BN_zero() and BN_one() are macros. Not real functions. Sneaky little guys ✨
  • BN_value_one() returns a BIGNUM constant of value 1. This constant is genuinely useful for comparisons and assignments β€” it's the main character of "just gimme a one" moments πŸ‘‘
  • BN_get_word() returns a, but only if it can actually be represented as a BN_ULONG. If it can't… yeah, see RETURN VALUES. πŸ™ˆ

πŸ’– RETURN VALUES πŸ’–

  • BN_get_word() returns the value a, or all-bits-set if a cannot be represented as a single integer. So that's the failure signal. Remember it. It's gonna come back around in BUGS. πŸ’€
  • BN_one() and BN_set_word() return 1 on success, 0 otherwise.
  • BN_value_one() returns the constant.
  • BN_zero() never fails and returns no value. Iconic behavior, honestly β€” zero effort king 🌈

πŸ”₯ BUGS πŸ”₯

Real talk, this one's a genuine trap: if a BIGNUM happens to be equal to the value of all-bits-set, it will collide with the error condition returned by BN_get_word(), which uses that exact value as its error value. So you literally cannot tell "the number was all-bits-set" apart from "this didn't fit." Not me being dramatic, that's just the spec. 😭

Also: BN_ULONG should probably be a typedef. It isn't. That's the bug. We said what we said πŸ’…


🌟 SEE ALSO 🌟


⭐ HISTORY ⭐

Back in OpenSSL 0.9.8, BN_zero() was changed to not return a value β€” earlier versions returned an int. Glow-up era, fr fr. πŸ¦‹


Copyright 2000-2018 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 bestie that's the whole page, we ate and left no crumbs πŸ“ This was OpenSSL 3.5.0, dated 2026-09-25, and the page is BN_ZERO(3ossl) β€” go forth and assign your numbers responsibly, mwah πŸ’‹πŸŽ€

πŸ“¦ where this page comes from