public static byte[] process(byte[] secretKey, byte[] data, int length)
        {
            SHA1HashFunction sha  = new SHA1HashFunction();
            SHA1HashFunction sha2 = new SHA1HashFunction();

            byte[] buffer   = new byte[SHA1HashFunction.HashSize];
            byte[] buffer2  = new byte[SHA1HashFunction.HashSize];
            int    arg_28_0 = SHA1HashFunction.HashSize;

            byte[] buffer3  = new byte[SHA1HashFunction.BlockSize];
            int    hashSize = secretKey.Length;

            if (hashSize > SHA1HashFunction.BlockSize)
            {
                SHA1HashFunction sha3 = new SHA1HashFunction();
                sha3.Reset();
                sha3.Input(secretKey);
                secretKey = sha3.Result();
                hashSize  = SHA1HashFunction.HashSize;
            }
            sha.Reset();
            for (int num = 0; num < hashSize; num++)
            {
                buffer3[num] = (byte)(secretKey[num] ^ 54);
            }
            for (int num = hashSize; num < SHA1HashFunction.BlockSize; num++)
            {
                buffer3[num] = 54;
            }
            sha.Input(buffer3);
            sha.Input(data);
            buffer = sha.Result();
            sha2.Reset();
            for (int num = 0; num < hashSize; num++)
            {
                buffer3[num] = (byte)(secretKey[num] ^ 92);
            }
            for (int num = hashSize; num < SHA1HashFunction.BlockSize; num++)
            {
                buffer3[num] = 92;
            }
            sha2.Input(buffer3);
            sha2.Input(buffer);
            buffer2 = sha2.Result();
            length  = ((length > SHA1HashFunction.HashSize) ? SHA1HashFunction.HashSize : length);
            byte[] buffer4 = new byte[length];
            CryptoEngineHMACSHA1.truncate(buffer2, buffer4, length);
            return(buffer4);
        }
Beispiel #2
0
        /// <summary>
        /// </summary>
        /// <param name="secretKey"></param>
        /// <param name="data"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public static byte[] process(byte[] secretKey, byte[] data, int length)
        {
            int num;
            SHA1HashFunction sha  = new SHA1HashFunction();
            SHA1HashFunction sha2 = new SHA1HashFunction();

            byte[] buffer   = new byte[SHA1HashFunction.HashSize];
            byte[] buffer2  = new byte[SHA1HashFunction.HashSize];
            byte[] buffer3  = new byte[SHA1HashFunction.HashSize];
            byte[] buffer4  = new byte[SHA1HashFunction.BlockSize];
            int    hashSize = secretKey.Length;

            if (hashSize > SHA1HashFunction.BlockSize)
            {
                SHA1HashFunction sha3 = new SHA1HashFunction();
                sha3.Reset();
                sha3.Input(secretKey);
                secretKey = sha3.Result();
                hashSize  = SHA1HashFunction.HashSize;
            }
            sha.Reset();
            for (num = 0; num < hashSize; num++)
            {
                buffer4[num] = (byte)(secretKey[num] ^ 0x36);
            }
            for (num = hashSize; num < SHA1HashFunction.BlockSize; num++)
            {
                buffer4[num] = 0x36;
            }
            sha.Input(buffer4);
            sha.Input(data);
            buffer = sha.Result();
            sha2.Reset();
            for (num = 0; num < hashSize; num++)
            {
                buffer4[num] = (byte)(secretKey[num] ^ 0x5c);
            }
            for (num = hashSize; num < SHA1HashFunction.BlockSize; num++)
            {
                buffer4[num] = 0x5c;
            }
            sha2.Input(buffer4);
            sha2.Input(buffer);
            buffer2 = sha2.Result();
            length  = (length > SHA1HashFunction.HashSize) ? SHA1HashFunction.HashSize : length;
            byte[] buffer5 = new byte[length];
            truncate(buffer2, buffer5, length);
            return(buffer5);
        }
 /// <summary>
 /// </summary>
 /// <param name="secretKey"></param>
 /// <param name="data"></param>
 /// <param name="length"></param>
 /// <returns></returns>
 public static byte[] process(byte[] secretKey, byte[] data, int length)
 {
     int num;
     SHA1HashFunction sha = new SHA1HashFunction();
     SHA1HashFunction sha2 = new SHA1HashFunction();
     byte[] buffer = new byte[SHA1HashFunction.HashSize];
     byte[] buffer2 = new byte[SHA1HashFunction.HashSize];
     byte[] buffer3 = new byte[SHA1HashFunction.HashSize];
     byte[] buffer4 = new byte[SHA1HashFunction.BlockSize];
     int hashSize = secretKey.Length;
     if (hashSize > SHA1HashFunction.BlockSize)
     {
         SHA1HashFunction sha3 = new SHA1HashFunction();
         sha3.Reset();
         sha3.Input(secretKey);
         secretKey = sha3.Result();
         hashSize = SHA1HashFunction.HashSize;
     }
     sha.Reset();
     for (num = 0; num < hashSize; num++)
     {
         buffer4[num] = (byte)(secretKey[num] ^ 0x36);
     }
     for (num = hashSize; num < SHA1HashFunction.BlockSize; num++)
     {
         buffer4[num] = 0x36;
     }
     sha.Input(buffer4);
     sha.Input(data);
     buffer = sha.Result();
     sha2.Reset();
     for (num = 0; num < hashSize; num++)
     {
         buffer4[num] = (byte)(secretKey[num] ^ 0x5c);
     }
     for (num = hashSize; num < SHA1HashFunction.BlockSize; num++)
     {
         buffer4[num] = 0x5c;
     }
     sha2.Input(buffer4);
     sha2.Input(buffer);
     buffer2 = sha2.Result();
     length = (length > SHA1HashFunction.HashSize) ? SHA1HashFunction.HashSize : length;
     byte[] buffer5 = new byte[length];
     truncate(buffer2, buffer5, length);
     return buffer5;
 }
		public static byte[] process(byte[] secretKey, byte[] data, int length)
		{
			SHA1HashFunction sha = new SHA1HashFunction();
			SHA1HashFunction sha2 = new SHA1HashFunction();
			byte[] buffer = new byte[SHA1HashFunction.HashSize];
			byte[] buffer2 = new byte[SHA1HashFunction.HashSize];
			int arg_28_0 = SHA1HashFunction.HashSize;
			byte[] buffer3 = new byte[SHA1HashFunction.BlockSize];
			int hashSize = secretKey.Length;
			if (hashSize > SHA1HashFunction.BlockSize)
			{
				SHA1HashFunction sha3 = new SHA1HashFunction();
				sha3.Reset();
				sha3.Input(secretKey);
				secretKey = sha3.Result();
				hashSize = SHA1HashFunction.HashSize;
			}
			sha.Reset();
			for (int num = 0; num < hashSize; num++)
			{
				buffer3[num] = (byte)(secretKey[num] ^ 54);
			}
			for (int num = hashSize; num < SHA1HashFunction.BlockSize; num++)
			{
				buffer3[num] = 54;
			}
			sha.Input(buffer3);
			sha.Input(data);
			buffer = sha.Result();
			sha2.Reset();
			for (int num = 0; num < hashSize; num++)
			{
				buffer3[num] = (byte)(secretKey[num] ^ 92);
			}
			for (int num = hashSize; num < SHA1HashFunction.BlockSize; num++)
			{
				buffer3[num] = 92;
			}
			sha2.Input(buffer3);
			sha2.Input(buffer);
			buffer2 = sha2.Result();
			length = ((length > SHA1HashFunction.HashSize) ? SHA1HashFunction.HashSize : length);
			byte[] buffer4 = new byte[length];
			CryptoEngineHMACSHA1.truncate(buffer2, buffer4, length);
			return buffer4;
		}