BN_CMP(3ossl)

✨ BN_CMP(3ossl) β€” the BIGNUM vibe check page ✨

okay bestie, so this is the BN_CMP page from the OpenSSL manual, and it's literally just a whole bunch of lil functions that compare your BIGNUMs and ask them questions about themselves. no cap. πŸ’–


🌸 NAME 🌸

BN_cmp, BN_ucmp, BN_is_zero, BN_is_one, BN_is_word, BN_abs_is_word, BN_is_odd, BN_are_coprime β€” the BIGNUM comparison and test functions. they're giving "who's bigger" and "are you what i think you are" energy πŸŽ€


✨ SYNOPSIS ✨

#include <openssl/bn.h>

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

int BN_are_coprime(BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);

πŸ¦‹ DESCRIPTION πŸ¦‹

so first up, the two compare girls:

  • BN_cmp() β€” compares the actual numbers a and b. like, signed, the whole personality. πŸ’…
  • BN_ucmp() β€” same thing but it only looks at their absolute values. it does not care about the minus sign, she's unbothered. ✨

then the test squad, who all just want to know things about a:

  • BN_is_zero() β€” is a equal to 0?
  • BN_is_one() β€” is a equal to 1?
  • BN_is_word() β€” is a equal to w?
  • BN_abs_is_word() β€” is a equal to |w|? (absolute value of w, yes bestie) 🌈
  • BN_is_odd() β€” is a odd? that's it, that's the whole question.

and then the main character:

  • BN_are_coprime() β€” figures out if a and b are coprime. ctx gets used internally to store temporary variables, she's just holding their stuff while they figure it out. 🫢
🚨 IMPORTANT: the values of a and b and ctx must not be NULL. not even a little. don't do it. πŸ’€

πŸ‘‘ RETURN VALUES πŸ‘‘

BN_cmp() is a whole mood scale:

  • returns -1 if a < b
  • returns 0 if a == b
  • returns 1 if a > b

BN_ucmp() does exactly the same thing, except it's using the absolute values of a and b to make that call.

BN_is_zero(), BN_is_one(), BN_is_word(), BN_abs_is_word() and BN_is_odd() return 1 if the condition is true and 0 otherwise. yes/no, that's the vibe check. πŸŽ€

BN_are_coprime() returns 1 if the BIGNUM's are coprime, otherwise it returns 0. periodt. πŸ’…


πŸ“œ HISTORY πŸ“œ

  • back before OpenSSL 1.1.0, BN_is_zero(), BN_is_one(), BN_is_word(), BN_abs_is_word() and BN_is_odd() were macros. glow-up era fr fr. ✨
  • BN_are_coprime() is the baby of the group β€” it was added in OpenSSL 3.1. 🍼

Copyright 2000-2021 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 that's the whole page bestie, you ate πŸ’…βœ¨ no cap, go compare some numbers πŸŽ€πŸ’–

this has been the OpenSSL 3ossl manual, version 3.5.9, dated 2026-09-29 β€” mwah, love u, bye πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from