namespace com.hitrust.Security.Signature
|
|
{
|
|
using com.hitrust.Security.Certificates;
|
|
using System;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
internal class Receiver
|
|
{
|
|
private Certificate iCertificate;
|
|
|
|
public Receiver(Certificate aCertificate)
|
|
{
|
|
this.iCertificate = aCertificate;
|
|
}
|
|
|
|
public void DecryptData(byte[] encrypted)
|
|
{
|
|
ASCIIEncoding myAscii = new ASCIIEncoding();
|
|
byte[] fromEncrypt = this.iCertificate.PrivateKey.Decrypt(encrypted, false);
|
|
string roundTrip = myAscii.GetString(fromEncrypt);
|
|
Console.WriteLine("RoundTrip: {0}", roundTrip);
|
|
}
|
|
|
|
public bool VerifyHash(byte[] signedData, byte[] signature)
|
|
{
|
|
byte[] hashedData = new SHA1Managed().ComputeHash(signedData);
|
|
return this.iCertificate.PublicKey.VerifyHash(hashedData, CryptoConfig.MapNameToOID("SHA1"), signature);
|
|
}
|
|
}
|
|
}
|
|
|