private static bool VerifyBundleSignature(byte[] signedBundleData)
        {
            int length = (int)signedBundleData.Length - (SslSocket.s_magicBundleSignaturePreamble.Length + 256);

            if (length <= 0)
            {
                return(false);
            }
            byte[] bytes = Encoding.ASCII.GetBytes(SslSocket.s_magicBundleSignaturePreamble);
            for (int i = 0; i < (int)bytes.Length; i++)
            {
                if (signedBundleData[length + i] != bytes[i])
                {
                    return(false);
                }
            }
            SHA256 sHA256 = SHA256.Create();

            sHA256.Initialize();
            sHA256.TransformBlock(signedBundleData, 0, length, null, 0);
            byte[] numArray = Encoding.ASCII.GetBytes("Blizzard Certificate Bundle");
            sHA256.TransformBlock(numArray, 0, (int)numArray.Length, null, 0);
            sHA256.TransformFinalBlock(new byte[1], 0, 0);
            byte[] hash      = sHA256.Hash;
            byte[] numArray1 = new byte[256];
            Array.Copy(signedBundleData, length + SslSocket.s_magicBundleSignaturePreamble.Length, numArray1, 0, 256);
            List <RSAParameters> rSAParameters = new List <RSAParameters>();
            RSAParameters        rSAParameter  = new RSAParameters()
            {
                Modulus  = SslSocket.s_standardPublicModulus,
                Exponent = SslSocket.s_standardPublicExponent
            };

            rSAParameters.Add(rSAParameter);
            RSAParameters rSAParameter1 = new RSAParameters()
            {
                Modulus  = SslSocket.s_debugPublicModulus,
                Exponent = SslSocket.s_debugPublicExponent
            };

            rSAParameters.Add(rSAParameter1);
            bool flag = false;
            int  num  = 0;

            while (num < rSAParameters.Count)
            {
                if (!SslSocket.VerifySignedHash(rSAParameters[num], hash, numArray1))
                {
                    num++;
                }
                else
                {
                    flag = true;
                    break;
                }
            }
            return(flag);
        }
Exemplo n.º 2
0
        private static bool VerifyBundleSignature(byte[] signedBundleData)
        {
            int num = signedBundleData.Length - (SslSocket.s_magicBundleSignaturePreamble.Length + 256);

            if (num <= 0)
            {
                return(false);
            }
            byte[] bytes = Encoding.ASCII.GetBytes(SslSocket.s_magicBundleSignaturePreamble);
            for (int i = 0; i < bytes.Length; i++)
            {
                if (signedBundleData[num + i] != bytes[i])
                {
                    return(false);
                }
            }
            SHA256 sha = SHA256.Create();

            sha.Initialize();
            sha.TransformBlock(signedBundleData, 0, num, null, 0);
            string s = "Blizzard Certificate Bundle";

            byte[] bytes2 = Encoding.ASCII.GetBytes(s);
            sha.TransformBlock(bytes2, 0, bytes2.Length, null, 0);
            sha.TransformFinalBlock(new byte[1], 0, 0);
            byte[] hash  = sha.Hash;
            byte[] array = new byte[256];
            Array.Copy(signedBundleData, num + SslSocket.s_magicBundleSignaturePreamble.Length, array, 0, 256);
            List <RSAParameters> list = new List <RSAParameters>();

            list.Add(new RSAParameters
            {
                Modulus  = SslSocket.s_standardPublicModulus,
                Exponent = SslSocket.s_standardPublicExponent
            });
            list.Add(new RSAParameters
            {
                Modulus  = SslSocket.s_debugPublicModulus,
                Exponent = SslSocket.s_debugPublicExponent
            });
            bool result = false;

            for (int j = 0; j < list.Count; j++)
            {
                RSAParameters key = list[j];
                if (SslSocket.VerifySignedHash(key, hash, array))
                {
                    result = true;
                    break;
                }
            }
            return(result);
        }