BN_mod_inverse

Compute the modular inverse of a modulo n.

Synopsis

Declared in <openssl/bn.h>

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

Return Value

Result BIGNUM (possibly newly allocated) on success, or NULL if no inverse exists / on error.

Parameters

NameDescription
retExisting BIGNUM to receive the result, or NULL to allocate.
aValue to invert.
nModulus; must be non-zero.
ctxBN_CTX scratch space.