7 NAMESPACE_BEGIN(CryptoPP)
9 GF2_32::Element
GF2_32::Multiply(Element a, Element b)
const
16 table[2] = m_modulus ^ (a<<1);
22 table[3] = m_modulus ^ (a<<1);
25 #if CRYPTOPP_FAST_ROTATE(32)
26 b = rotrFixed(b, 30U);
27 word32 result = table[b&2];
29 for (
int i=29; i>=0; --i)
32 result = (result<<1) ^ table[(b&2) + (result>>31)];
35 return (b&1) ? result ^ a : result;
37 word32 result = table[(b>>30) & 2];
39 for (
int i=29; i>=0; --i)
40 result = (result<<1) ^ table[((b>>i)&2) + (result>>31)];
42 return (b&1) ? result ^ a : result;
46 GF2_32::Element GF2_32::MultiplicativeInverse(Element a)
const
52 word32 g0=m_modulus, g1=a, g2=a;
53 word32 v0=0, v1=1, v2=1;
57 while (!(g2 & 0x80000000))
71 if (g1 < g0 || ((g0^g1) < g0 && (g0^g1) < g1))
73 assert(BitPrecision(g1) <= BitPrecision(g0));
79 assert(BitPrecision(g1) > BitPrecision(g0));
80 g2 = g0; g0 = g1; g1 = g2;
81 v2 = v0; v0 = v1; v1 = v2;
86 assert(BitPrecision(g0) > BitPrecision(g2));
91 assert(BitPrecision(g0) == BitPrecision(g2));
GF(2^32) with polynomial basis.