internal static void Multiply(byte[] x, byte[] y)
 {
     uint[] t1 = GcmUtilities.AsUints(x);
     uint[] t2 = GcmUtilities.AsUints(y);
     GcmUtilities.Multiply(t1, t2);
     GcmUtilities.AsBytes(t1, x);
 }
Exemple #2
0
        public void Init(byte[] x)
        {
            uint[] y = GcmUtilities.AsUints(x);
            if (lookupPowX2 != null && Arrays.AreEqual(y, (uint[])lookupPowX2[0]))
            {
                return;
            }

            lookupPowX2 = Platform.CreateArrayList(8);
            lookupPowX2.Add(y);
        }
        public void Init(byte[] H)
        {
            if (M == null)
            {
                M = new uint[16][][];
            }
            else if (Arrays.AreEqual(this.H, H))
            {
                return;
            }

            this.H = Arrays.Clone(H);

            M[0]      = new uint[256][];
            M[0][0]   = new uint[4];
            M[0][128] = GcmUtilities.AsUints(H);
            for (int j = 64; j >= 1; j >>= 1)
            {
                uint[] tmp = (uint[])M[0][j + j].Clone();
                GcmUtilities.MultiplyP(tmp);
                M[0][j] = tmp;
            }
            for (int i = 0; ;)
            {
                for (int j = 2; j < 256; j += j)
                {
                    for (int k = 1; k < j; ++k)
                    {
                        uint[] tmp = (uint[])M[i][j].Clone();
                        GcmUtilities.Xor(tmp, M[i][k]);
                        M[i][j + k] = tmp;
                    }
                }

                if (++i == 16)
                {
                    return;
                }

                M[i]    = new uint[256][];
                M[i][0] = new uint[4];
                for (int j = 128; j > 0; j >>= 1)
                {
                    uint[] tmp = (uint[])M[i - 1][j].Clone();
                    GcmUtilities.MultiplyP8(tmp);
                    M[i][j] = tmp;
                }
            }
        }
 public void Init(byte[] x)
 {
     this.x = GcmUtilities.AsUints(x);
 }
 public void Init(byte[] H)
 {
     this.H = GcmUtilities.AsUints(H);
 }
 public void MultiplyH(byte[] x)
 {
     uint[] t = GcmUtilities.AsUints(x);
     GcmUtilities.Multiply(t, H);
     GcmUtilities.AsBytes(t, x);
 }