BN_MOD_INVERSE(3)

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

πŸ’– NAME πŸ’–

okay so BN_mod_inverse β€” compute inverse modulo m. This is the BN_MOD_INVERSE(3) page from the libcrypto manual, and it's lowkey iconic because modular inverses are literally everywhere, bestie.

✨ SYNOPSIS ✨

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

BIGNUM *
BN_mod_inverse(BIGNUM *r, const BIGNUM *a, const BIGNUM *m,
    BN_CTX *ctx);

You're pulling this from libcrypto and including <openssl/bn.h>, periodt. πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

BN_mod_inverse() computes the inverse of a modulo m and places the result in r, so that r satisfies a * r == 1 (mod m). If r is NULL, a new BIGNUM is allocated. Slay.

If the flag BN_FLG_CONSTTIME is set on a or m, it operates in constant time. No cap, that's the whole vibe.

ctx is a previously allocated BN_CTX used for temporary variables. r may be the same BIGNUM as a or m. Bestie, you can alias them β€” it's fine.

πŸŽ€ RETURN VALUES πŸŽ€

BN_mod_inverse() returns the BIGNUM containing the inverse, or NULL on error. The error codes can be obtained by ERR_get_error(3). So if it ghosts you, that's where the receipts live.

🌸 SEE ALSO 🌸

πŸ“œ HISTORY πŸ“œ

BN_mod_inverse() first appeared in SSLeay 0.5.1 and has been available since OpenBSD 2.4.

The r argument was added in SSLeay 0.9.1 and OpenBSD 2.6. ✨ character development ✨


mwah πŸ’‹ this page is brought to you by Debian, dated June 8, 2025 β€” BN_MOD_INVERSE(3) out πŸ’…πŸ«Ά

πŸ“¦ where this page comes from