Exemple #1
0
        public void Init(byte[] H)
        {
            if (T == null)
            {
                T = new ulong[32][];
            }
            else if (Arrays.AreEqual(this.H, H))
            {
                return;
            }

            this.H = Arrays.Clone(H);

            for (int i = 0; i < 32; ++i)
            {
                ulong[] t = T[i] = new ulong[32];

                // t[0] = 0

                if (i == 0)
                {
                    // t[1] = H.p^3
                    GcmUtilities.AsUlongs(this.H, t, 2);
                    GcmUtilities.MultiplyP3(t, 2, t, 2);
                }
                else
                {
                    // t[1] = T[i-1][1].p^4
                    GcmUtilities.MultiplyP4(T[i - 1], 2, t, 2);
                }

                for (int n = 2; n < 16; n += 2)
                {
                    // t[2.n] = t[n].p^-1
                    GcmUtilities.DivideP(t, n, t, n << 1);

                    // t[2.n + 1] = t[2.n] + t[1]
                    GcmUtilities.Xor(t, n << 1, t, 2, t, (n + 1) << 1);
                }
            }
        }