コード例 #1
0
        /**
         * @return <c>true</c> if the keyDigest is compatible with the specified saltData and saltHash
         */
        public bool Validate(byte[] saltData, byte[] saltHash)
        {
            Check16Bytes(saltData, "saltData");
            Check16Bytes(saltHash, "saltHash");

            // validation uses the RC4 for block zero
            RC4 rc4 = CreateRC4(0);

            byte[] saltDataPrime = new byte[saltData.Length];
            Array.Copy(saltData, saltDataPrime, saltData.Length);
            rc4.Encrypt(saltDataPrime);

            byte[] saltHashPrime = new byte[saltHash.Length];
            Array.Copy(saltHash, saltHashPrime, saltHash.Length);
            rc4.Encrypt(saltHashPrime);

            using (MD5 md5 = new MD5CryptoServiceProvider())
            {
                byte[] finalSaltResult = md5.ComputeHash(saltDataPrime);

                //if (false)
                //{ // set true to see a valid saltHash value
                //    byte[] saltHashThatWouldWork = xor(saltHash, xor(saltHashPrime, finalSaltResult));
                //    Console.WriteLine(HexDump.ToHex(saltHashThatWouldWork));
                //}

                return(Arrays.Equals(saltHashPrime, finalSaltResult));
            }
        }
コード例 #2
0
ファイル: Biff8RC4.cs プロジェクト: leo0530/Zephyr
 private void RekeyForNextBlock()
 {
     _currentKeyIndex   = _streamPos / RC4_REKEYING_INTERVAL;
     _rc4               = _key.CreateRC4(_currentKeyIndex);
     _nextRC4BlockStart = (_currentKeyIndex + 1) * RC4_REKEYING_INTERVAL;
 }
コード例 #3
0
ファイル: Biff8RC4.cs プロジェクト: Johnnyfly/source20131023
 private void RekeyForNextBlock()
 {
     _currentKeyIndex = _streamPos / RC4_REKEYING_INTERVAL;
     _rc4 = _key.CreateRC4(_currentKeyIndex);
     _nextRC4BlockStart = (_currentKeyIndex + 1) * RC4_REKEYING_INTERVAL;
 }