Sortix main manual
This manual documents Sortix main. You can instead view this document in the latest official manual.
NAME
BN_mod_mul_reciprocal, BN_RECP_CTX_new, BN_RECP_CTX_init, BN_RECP_CTX_free, BN_RECP_CTX_set, BN_div_recp, BN_reciprocal — modular multiplication using reciprocalSYNOPSIS
#include <openssl/bn.h>BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_RECP_CTX *recp, BN_CTX *ctx);
BN_RECP_CTX_new(void);
BN_RECP_CTX_init(BN_RECP_CTX *recp);
BN_RECP_CTX_free(BN_RECP_CTX *recp);
BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *m, BN_CTX *ctx);
BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, BN_RECP_CTX *recp, BN_CTX *ctx);
BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);
DESCRIPTION
BN_mod_mul_reciprocal() can be used to perform an efficient BN_mod_mul(3) operation when the operation will be performed repeatedly with the same modulus. It computes r=(a*b)%m using recp=1/m, which is set as described below. ctx is a previously allocated BN_CTX used for temporary variables.typedef struct bn_recp_ctx_st { BIGNUM N; /* the divisor */ BIGNUM Nr; /* the reciprocal */ int num_bits; int shift; int flags; } BN_RECP_CTX;