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

Name

Description

ret

Existing BIGNUM to receive the result, or NULL to allocate.

a

Value to invert.

n

Modulus; must be non‐zero.

ctx

BN_CTX scratch space.

Created with MrDocs