Esempio n. 1
0
        public static ulong[] GetH(ICryptoTransform key)
        {
            var bytes = new byte[16];

            key.TransformBlock(bytes, 0, 16, bytes, 0);
            int offset = 0;
            var h1     = Utils.ReadUInt64(bytes, ref offset);
            var h2     = Utils.ReadUInt64(bytes, ref offset);

            Utils.ClearArray(bytes);
            return(Construct(h1, h2));
        }
Esempio n. 2
0
        public static bool GCMAD(ICryptoTransform key, byte[] iv, byte[] data, int offset, int len, ulong seqNum, byte contentType, ulong[] h, byte[] temp512)
        {
            int   tOffset = offset + len;
            ulong s1      = Utils.ReadUInt64(data, ref tOffset);
            ulong s2      = Utils.ReadUInt64(data, ref tOffset);

            CalcHash(key, iv, data, offset, len, seqNum, GetHeader(contentType, len), h, temp512);
            tOffset = offset + len;
            ulong s1p = Utils.ReadUInt64(data, ref tOffset);
            ulong s2p = Utils.ReadUInt64(data, ref tOffset);

            if (s1 != s1p || s2 != s2p)
            {
                return(false);
            }
            Encrypt(data, offset, len, key, iv, 2, temp512);
            return(true);
        }