public VerifyWithSHA1 ( byte data, byte expected ) : void | ||
data | byte | |
expected | byte | |
Résultat | void |
public void VerifyWithSHA1(byte[] data, byte[] expected)
{
BigInteger result = VerifyBI(data);
byte[] finaldata = RSAUtil.StripPKCS1Pad(result, 1).GetBytes();
if (finaldata.Length != PKIUtil.SHA1_ASN_ID.Length + expected.Length)
throw new VerifyException("result is too short");
else {
byte[] r = new byte[finaldata.Length];
Array.Copy(PKIUtil.SHA1_ASN_ID, 0, r, 0, PKIUtil.SHA1_ASN_ID.Length);
Array.Copy(expected, 0, r, PKIUtil.SHA1_ASN_ID.Length, expected.Length);
if (!SSHUtil.ByteArrayEqual(r, finaldata)) {
throw new VerifyException("failed to verify");
}
}
}
private void VerifyHostKeyByRSA(SSH2DataReader pubkey, byte[] sigbody, byte[] hash) { BigInteger exp = pubkey.ReadMPInt(); BigInteger mod = pubkey.ReadMPInt(); Debug.Assert(pubkey.Rest==0); //Debug.WriteLine(exp.ToHexString()); //Debug.WriteLine(mod.ToHexString()); RSAPublicKey pk = new RSAPublicKey(exp, mod); pk.VerifyWithSHA1(sigbody, new SHA1CryptoServiceProvider().ComputeHash(hash)); _cInfo._hostkey = pk; }