Esempio n. 1
0
        private void Update(byte[] providedData)
        {
            var data = Concat(v, 0, providedData);

            key = HMAC512.ComputeHash(key, data);
            v   = HMAC512.ComputeHash(key, v);
            if (providedData != null)
            {
                data = Concat(v, 0x01, providedData);
                key  = HMAC512.ComputeHash(key, data);
                v    = HMAC512.ComputeHash(key, v);
            }
        }
Esempio n. 2
0
        public void GetBytes(byte[] data)
        {
            if (data.Length * 8 > 7500)
            {
                throw new ArgumentException("Too many bytes requested: " + data.Length);
            }

            if (reseedCounter >= 10000)
            {
                throw new ArgumentException("A reseed is required");
            }

            int idx = 0;

            while (idx < data.Length)
            {
                v = HMAC512.ComputeHash(key, v);
                ByteArrayUtils.CopyBytes(v, 0, data, idx, Math.Min(v.Length, data.Length - idx));
                idx += v.Length;
            }

            Update(null);
            ++reseedCounter;
        }