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 numbersaandb. 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()β isaequal to0?BN_is_one()β isaequal to1?BN_is_word()β isaequal tow?BN_abs_is_word()β isaequal to|w|? (absolute value ofw, yes bestie) πBN_is_odd()β isaodd? that's it, that's the whole question.
and then the main character:
BN_are_coprime()β figures out ifaandbare coprime.ctxgets used internally to store temporary variables, she's just holding their stuff while they figure it out. π«Ά
π¨ IMPORTANT: the values ofaandbandctxmust not be NULL. not even a little. don't do it. π
π RETURN VALUES π
BN_cmp() is a whole mood scale:
- returns
-1ifa < b - returns
0ifa == b - returns
1ifa > 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()andBN_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 π
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
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms