| 737 | // U[N] --- multiplicative inverse of M mod 2**(WORD_BITS*N) |
| 738 | |
| 739 | void 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 |
no test coverage detected