BN_ZERO(3ossl)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 15.1

🌸 NAME 🌸

okay bestie, this is the BN_ZERO(3ossl) manual page, and it's all about BN_zero, BN_one, BN_value_one, BN_set_word, and BN_get_word β€” aka the BIGNUM assignment operations. no cap, that's the whole vibe.

✨ SYNOPSIS ✨

first the include, then the signatures β€” copy these exactly, bestie:

#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);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so BN_ULONG is a macro that will be an unsigned integral type β€” the kind optimized for the most efficient implementation on the local platform. it's giving "let the platform cook," and honestly, slay.

BN_zero(), BN_one(), and BN_set_word() set a to the values 0, 1, and w, respectively. BN_zero() and BN_one() are macros, iykyk.

BN_value_one() returns a BIGNUM constant of value 1. This constant is useful for use in comparisons and assignment β€” literally the main character constant for when you need a one.

BN_get_word() returns a, if it can be represented as a BN_ULONG.

πŸŽ€ RETURN VALUES πŸŽ€

BN_get_word() returns the value a, or all-bits-set if a cannot be represented as a single integer. so if it can't fit, you get the all-bits-set situation, no cap.

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. periodt.

πŸ’€ BUGS πŸ’€

🚨 warning bestie: if a BIGNUM is equal to the value of all-bits-set, it will collide with the error condition returned by BN_get_word() which uses that as an error value. that's a genuine vibe check fail.

BN_ULONG should probably be a typedef. not me side-eyeing the macro situation πŸ™ˆ.

🌈 SEE ALSO 🌈

🧚 HISTORY 🧚

In OpenSSL 0.9.8, BN_zero() was changed to not return a value; previous versions returned an int. so if you're time-traveling to old OpenSSL, mind the return type, 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>.


mwah πŸ’‹ β€” this BN_ZERO(3ossl) page is from OpenSSL 3.5.6, dated 2026-04-07. stay slaying those BIGNUMs, bestie 🫢

πŸ“¦ where this page comes from