예제 #1
0
        public static byte[] GenerateKey(byte[] sessionKey)
        {
            byte[] firstBuffer = new byte[64];
            byte[] secondBuffer = new byte[64];

            memset(firstBuffer, 0x36);
            memset(secondBuffer, 0x5C);

            for (int i = 0; i < SeedKey.Length; i++)
            {
                firstBuffer[i] = (byte)(SeedKey[i] ^ firstBuffer[i]);
                secondBuffer[i] = (byte)(SeedKey[i] ^ secondBuffer[i]);
            }

            SHA1Internal sha = new SHA1Internal();

            sha.Update(firstBuffer, 0, 64);
            sha.Update(sessionKey, 0, 40);

            byte[] tempDigest = sha.Finalize();

            sha = new SHA1Internal();

            sha.Update(secondBuffer, 0, 64);
            sha.Update(tempDigest, 0, 20);

            byte[] finalKey = sha.Finalize();

            return finalKey;
        }