Sortix cisortix manual
This manual documents Sortix cisortix. You can instead view this document in the latest official manual.
NAME
BN_MONT_CTX_new, BN_MONT_CTX_init, BN_MONT_CTX_free, BN_MONT_CTX_set, BN_MONT_CTX_set_locked, BN_MONT_CTX_copy, BN_mod_mul_montgomery, BN_from_montgomery, BN_to_montgomery — Montgomery multiplicationSYNOPSIS
#include <openssl/bn.h>BN_MONT_CTX_new(void);
BN_MONT_CTX_init(BN_MONT_CTX *ctx);
BN_MONT_CTX_free(BN_MONT_CTX *mont);
BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *m, BN_CTX *ctx);
BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock, const BIGNUM *m, BN_CTX *ctx);
BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);
BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_MONT_CTX *mont, BN_CTX *ctx);
BN_from_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx);
BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx);
DESCRIPTION
These functions implement Montgomery multiplication. They are used automatically when BN_mod_exp(3) is called with suitable input, but they may be useful when several operations are to be performed using the same modulus.Mont(a, b) := a*
b* R^-1
r=
a* R^-1
Mont(a,R^2
) = a* R
typedef struct bn_mont_ctx_st { int ri; /* number of bits in R */ BIGNUM RR; /* R^2 (used to convert to Montgomery form) */ BIGNUM N; /* The modulus */ BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 * (Ni is only stored for bignum algorithm) */ BN_ULONG n0; /* least significant word of Ni */ int flags; } BN_MONT_CTX;