public void Init(byte[] H) { if (T == null) { T = new ulong[512]; } else if (Arrays.AreEqual(this.H, H)) { return; } this.H = Arrays.Clone(H); // T[0] = 0 // T[1] = H.p^7 GcmUtilities.AsUlongs(this.H, T, 2); GcmUtilities.MultiplyP7(T, 2, T, 2); for (int n = 2; n < 256; 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); } }
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); } } }