BN_MOD_INVERSE(3ossl)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 15.1

πŸ’– BN_MOD_INVERSE(3ossl) β€” compute inverse modulo n πŸ’–

okay so bestie, welcome to the OpenSSL manual page for BN_mod_inverse β€” yes, the BN_MOD_INVERSE(3ossl) one. It's giving big math-girl energy, and honestly? iconic. ✨


✨ NAME ✨

BN_mod_inverse β€” compute inverse modulo n. That's the whole vibe: inverse modulo n, no cap. πŸ’…

🌸 SYNOPSIS 🌸

#include <openssl/bn.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

  • BN_mod_inverse() computes the inverse of a modulo n and places the result in r ("(a*r)%n==1"). Math bestie moment, fr fr.
  • If r is NULL, a new BIGNUM is created. Cute, it makes one for you. πŸŽ€
  • ctx is a previously allocated BN_CTX used for temporary variables. Like, it's the scratch space vibes.
  • r may be the same BIGNUM as a. So yes, that overlap is allowed.

⚠️ NOTES ⚠️

🚨 It is an error to use the same BIGNUM as n. Do not do that, bestie β€” that's an error, periodt.

🌈 RETURN VALUES 🌈

BN_mod_inverse() returns the BIGNUM containing the inverse, and NULL on error. The error codes can be obtained by ERR_get_error(3). So if it's giving NULL, go check the error codes. πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

Copyright 2000-2017 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>.

xoxo, your girl β€” page vibes from 3.5.6, dated 2026-04-07, manual BN_MOD_INVERSE(3ossl) πŸ’–πŸ’…βœ¨

πŸ“¦ where this page comes from