libressl-BN_mod_inverse3
Compute inverse modulo m
Usage
Crypto Library (libcrypto, -lcrypto)
#include <openssl/bn.h>
BIGNUM *
BN_mod_inverse(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
Overview
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.
If the flag BN_FLG_CONSTTIME is set on a or m, it operates in constant time.
ctx is a previously allocated BN_CTX used for temporary variables. r may be the same BIGNUM as a or m.
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).