日期:2014-05-16 浏览次数:20992 次
/// <summary>
/// 验证RSA签名
/// </summary>
/// <param name="str_DataToVerify">待签名的字符串</param>
/// <param name="str_SignedData">对方生成的RSA签名</param>
/// <param name="str_Public_Key">对方公钥</param>
public static bool VerifySignedHash(string str_DataToVerify, string str_SignedData, string str_Public_Key)
{
byte[] SignedData = Convert.FromBase64String(str_SignedData);
ASCIIEncoding ByteConverter = new ASCIIEncoding();
byte[] DataToVerify = ByteConverter.GetBytes(str_DataToVerify);
try
{
RSACryptoServiceProvider RSAalg = new RSACryptoServiceProvider();
byte[] pubKeyBytes = Convert.FromBase64String(str_Public_Key);
RSAalg.ImportCspBlob(pubKeyBytes);
return RSAalg.VerifyData(DataToVerify, new SHA1CryptoServiceProvider(), SignedData);
}
catch (CryptographicException e)
{
return false;
}
}
SEQUENCE(2 elem)
--SEQUENCE(2 elem)
----OBJECT IDENTIFIER 1.2.840.113549.1.1.1
----NULL
--BIT STRING(1 elem)
----SEQUENCE(2 elem)
------INTEGER(1024 bit) 1324925806459412787721713702712958489781723…
------INTEGER 65537