private static bool VerifySignedHash(RSAParameters key, byte[] hash, byte[] signature) { byte[] numArray = new byte[(int)key.Modulus.Length]; byte[] numArray1 = new byte[(int)key.Exponent.Length]; byte[] numArray2 = new byte[(int)signature.Length]; Array.Copy(key.Modulus, numArray, (int)key.Modulus.Length); Array.Copy(key.Exponent, numArray1, (int)key.Exponent.Length); Array.Copy(signature, numArray2, (int)signature.Length); Array.Reverse(numArray); Array.Reverse(numArray1); Array.Reverse(numArray2); BigInteger bigInteger = new BigInteger(numArray); BigInteger bigInteger1 = new BigInteger(numArray1); BigInteger bigInteger2 = BigInteger.PowMod(new BigInteger(numArray2), bigInteger1, bigInteger); byte[] numArray3 = new byte[(int)key.Modulus.Length]; byte[] fieldHandle = new byte[] { typeof(< PrivateImplementationDetails >).GetField("$field-2FFAC053D2D8FD53E1733DCE28216805289D3E35").FieldHandle }; if (!SslSocket.MakePKCS1SignatureBlock(hash, (int)hash.Length, fieldHandle, (int)fieldHandle.Length, numArray3, (int)key.Modulus.Length)) { return(false); } byte[] numArray4 = new byte[(int)numArray3.Length]; Array.Copy(numArray3, numArray4, (int)numArray3.Length); Array.Reverse(numArray4); return((new BigInteger(numArray4)).CompareTo(bigInteger2) == 0); }
private static bool VerifySignedHash(RSAParameters key, byte[] hash, byte[] signature) { byte[] array = new byte[key.Modulus.Length]; byte[] array2 = new byte[key.Exponent.Length]; byte[] array3 = new byte[signature.Length]; Array.Copy(key.Modulus, array, key.Modulus.Length); Array.Copy(key.Exponent, array2, key.Exponent.Length); Array.Copy(signature, array3, signature.Length); Array.Reverse(array); Array.Reverse(array2); Array.Reverse(array3); BigInteger mod = new BigInteger(array); BigInteger exp = new BigInteger(array2); BigInteger b = new BigInteger(array3); BigInteger value = BigInteger.PowMod(b, exp, mod); byte[] array4 = new byte[key.Modulus.Length]; byte[] array5 = new byte[] { 48, 49, 48, 13, 6, 9, 96, 134, 72, 1, 101, 3, 4, 2, 1, 5, 0, 4, 32 }; if (!SslSocket.MakePKCS1SignatureBlock(hash, hash.Length, array5, array5.Length, array4, key.Modulus.Length)) { return(false); } byte[] array6 = new byte[array4.Length]; Array.Copy(array4, array6, array4.Length); Array.Reverse(array6); BigInteger bigInteger = new BigInteger(array6); return(bigInteger.CompareTo(value) == 0); }