MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / MontgomeryReduce

Function MontgomeryReduce

src/cryptlib/integer.cpp:739–748  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

737// U[N] --- multiplicative inverse of M mod 2**(WORD_BITS*N)
738
739void MontgomeryReduce(word *R, word *T, const word *X, const word *M, const word *U, unsigned int N)
740{
741 RecursiveMultiplyBottom(R, T, X, U, N);
742 RecursiveMultiplyTop(T, T+N, X, R, M, N);
743 if (Subtract(R, X+N, T, N))
744 {
745 word carry = Add(R, R, M, N);
746 assert(carry);
747 }
748}
749
750// R[N] --- result = X/(2**(WORD_BITS*N/2)) mod M
751// T[2*N] - temporary work space

Callers 4

MultiplyMethod · 0.85
SquareMethod · 0.85
ConvertOutMethod · 0.85
MultiplicativeInverseMethod · 0.85

Calls 3

RecursiveMultiplyBottomFunction · 0.85
RecursiveMultiplyTopFunction · 0.85
SubtractFunction · 0.85

Tested by

no test coverage detected