| 1073 | // M[N] - modulus |
| 1074 | |
| 1075 | void DivideByPower2Mod(word *R, const word *A, unsigned int k, const word *M, unsigned int N) |
| 1076 | { |
| 1077 | CopyWords(R, A, N); |
| 1078 | |
| 1079 | while (k--) |
| 1080 | { |
| 1081 | if (R[0]%2==0) |
| 1082 | ShiftWordsRightByBits(R, N, 1); |
| 1083 | else |
| 1084 | { |
| 1085 | word carry = Add(R, R, M, N); |
| 1086 | ShiftWordsRightByBits(R, N, 1); |
| 1087 | R[N-1] += carry<<(WORD_BITS-1); |
| 1088 | } |
| 1089 | } |
| 1090 | } |
| 1091 | |
| 1092 | // R[N] - result = A*(2^k) mod M |
| 1093 | // A[N] - input |
no test coverage detected