namespace com.hitrust.Security.Signature
|
|
{
|
|
using com.hitrust.Security.Certificates;
|
|
using System;
|
|
using System.Security.Cryptography;
|
|
|
|
internal class Sender
|
|
{
|
|
private Certificate iCertificate;
|
|
|
|
public Sender(Certificate aCertificate)
|
|
{
|
|
this.iCertificate = aCertificate;
|
|
}
|
|
|
|
public byte[] EncryptData(byte[] toEncrypt)
|
|
{
|
|
return this.iCertificate.PublicKey.Encrypt(toEncrypt, false);
|
|
}
|
|
|
|
public byte[] HashAndSign(byte[] encrypted)
|
|
{
|
|
byte[] hashedData = new SHA1Managed().ComputeHash(encrypted);
|
|
return this.iCertificate.PrivateKey.SignHash(hashedData, CryptoConfig.MapNameToOID("SHA1"));
|
|
}
|
|
}
|
|
}
|
|
|