BN_CMP(3ossl)
Hii bestie!! Welcome to BN_CMP(3ossl) β the OpenSSL page for all the BIGNUM comparison and test functions. Buckle up, because these little math gremlins are lowkey iconic and youβre gonna understand every single one. π
β¨
π NAME π
Hereβs the whole squad, no cap:
BN_cmpBN_ucmpBN_is_zeroBN_is_oneBN_is_wordBN_abs_is_wordBN_is_oddBN_are_coprime
Theyβre all about BIGNUM comparison and test functions. Periodt. π
β¨ SYNOPSIS β¨
First things first, bestie β pull in the header:
#include <openssl/bn.h>
Then here are the exact signatures, character for character:
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 π
Okay so, letβs break the crew down.
BN_cmp()β compares the numbers a and b. Like a full vibe check on which one is bigger. πBN_ucmp()β compares their absolute values instead.BN_is_zero()β tests if a equals0.BN_is_one()β tests if a equals1.BN_is_word()β tests if a equals w.BN_abs_is_word()β tests if a equals|w|.BN_is_odd()β tests if a is odd.
And then thereβs BN_are_coprime(), the main character: it determines if a and b are coprime. The ctx is used internally for storing temporary variables. The values of a and b and ctx must not be NULL.
Bestie, seriously: a, b, and ctx must not be NULL. Thatβs a hard no. π«Ά
πΈ RETURN VALUES πΈ
BN_cmp()β returns-1if a < b,0if a == b, and1if a > b. πBN_ucmp()β same energy, but using the absolute values of a and b.BN_is_zero(),BN_is_one(),BN_is_word(),BN_abs_is_word()andBN_is_odd()β return1if the condition is true,0otherwise.BN_are_coprime()β returns1if the BIGNUMs are coprime, otherwise it returns0.
π¦ HISTORY π¦
Storytime, bestie:
- Prior to OpenSSL
1.1.0,BN_is_zero(),BN_is_one(),BN_is_word(),BN_abs_is_word()andBN_is_odd()were macros. The way they were macros before? Wild. π - The function
BN_are_coprime()was added in OpenSSL3.1.
π COPYRIGHT π
Legal era, unfortunately, but we keep it cute:
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. This one comes from OpenSSL 3.5.0, dated 2026-09-25, and its manual name is BN_CMP(3ossl). Mwah πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms