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

Function RecursiveInverseModPower2

src/cryptlib/integer.cpp:715–731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

713// A[N] ----- an odd number as input
714
715void RecursiveInverseModPower2(word *R, word *T, const word *A, unsigned int N)
716{
717 if (N==2)
718 AtomicInverseModPower2(R, A[0], A[1]);
719 else
720 {
721 const unsigned int N2 = N/2;
722 RecursiveInverseModPower2(R0, T0, A0, N2);
723 T0[0] = 1;
724 SetWords(T0+1, 0, N2-1);
725 RecursiveMultiplyTop(R1, T1, T0, R0, A0, N2);
726 RecursiveMultiplyBottom(T0, T1, R0, A1, N2);
727 Add(T0, R1, T0, N2);
728 TwosComplement(T0, N2);
729 RecursiveMultiplyBottom(R1, T1, R0, T0, N2);
730 }
731}
732
733// R[N] --- result = X/(2**(WORD_BITS*N)) mod M
734// T[3*N] - temporary work space

Callers 2

Calls 5

AtomicInverseModPower2Function · 0.85
SetWordsFunction · 0.85
RecursiveMultiplyTopFunction · 0.85
RecursiveMultiplyBottomFunction · 0.85
TwosComplementFunction · 0.85

Tested by

no test coverage detected