BN_CMP(3)

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

πŸ’– BN_CMP(3) β€” BIGNUM comparison and test functions πŸ’–

hey bestie!! 🫢 this is the BN_CMP(3) page from the Library Functions Manual, and it's literally all about BIGNUM comparison and test functions. no cap, we're gonna make it make sense. ✨


πŸŽ€ NAME πŸŽ€

BN_cmp, BN_ucmp, BN_is_zero, BN_is_one, BN_is_word, BN_abs_is_word, BN_is_odd β€” BIGNUM comparison and test functions. that's the whole squad, and yes they ate. πŸ’…

✨ SYNOPSIS ✨

okay so first the library tea:

library β€œlibcrypto” #include <openssl/bn.h>

then the function signatures, exactly as they are, bestie β€” these are the int-returning icons:

int
BN_cmp(const BIGNUM *a, const BIGNUM *b);

int
BN_ucmp(const BIGNUM *a, const BIGNUM *b);

int
BN_is_zero(const BIGNUM *a);

int
BN_is_one(const BIGNUM *a);

int
BN_is_word(const BIGNUM *a, const BN_ULONG w);

int
BN_abs_is_word(const BIGNUM *a, const BN_ULONG w);

int
BN_is_odd(const BIGNUM *a);

πŸ’… DESCRIPTION πŸ’…

BN_cmp() compares the numbers a and b. BN_ucmp() compares their absolute values. that's the difference, bestie β€” BN_ucmp() is the absolute-value twin. πŸ¦‹

BN_is_zero(), BN_is_one(), and BN_is_word() test if a equals 0, 1, or w, respectively. BN_abs_is_word() tests if the absolute value of a equals w. BN_is_odd() tests if a is odd. literally just little vibe checks for your BIGNUM. πŸ”₯

BN_ULONG is a macro that expands to unsigned long (= uint64_t) on _LP64 platforms and unsigned int (= uint32_t) elsewhere. periodt. πŸ’œ

🌈 RETURN VALUES 🌈

  • BN_cmp() returns -1 if a<b, 0 if a==b, and 1 if a>b. iconic. ⭐
  • BN_ucmp() is the same using the absolute values of a and b.
  • BN_is_zero(), BN_is_one(), BN_is_word(), BN_abs_is_word(), and BN_is_odd() return 1 if the condition is true, 0 otherwise. so it's giving yes/no, true/false, 1/0 realness. πŸ’–

πŸ¦‹ SEE ALSO πŸ¦‹

BN_new(3) β€” go read that one too, bestie, it's the BIGNUM origin story. 🌸

πŸ‘‘ HISTORY πŸ‘‘

BN_cmp(), BN_ucmp(), BN_is_zero(), BN_is_one(), and BN_is_word() first appeared in SSLeay 0.5.1. BN_is_odd() first appeared in SSLeay 0.8.0. These functions have been available since OpenBSD 2.4. πŸ“œ

BN_abs_is_word() first appeared in OpenSSL 0.9.7 and has been available since OpenBSD 3.2. the way this one has its own little timeline?? obsessed. πŸ•°οΈ


mwah πŸ’‹ and that's the footer tea: source/version is Debian, date is June 8, 2025. thank you for coming to my TED talk, now go compare some BIGNUMs. πŸ’…βœ¨

πŸ“¦ where this page comes from