using System.Security;
using System.Security.Cryptography;
public class RSAPKCS1SHA256SignatureDescription : SignatureDescription
{
public RSAPKCS1SHA256SignatureDescription()
{
KeyAlgorithm = typeof(RSACryptoServiceProvider).FullName;
DigestAlgorithm = typeof(SHA256CryptoServiceProvider).FullName;
FormatterAlgorithm = typeof(RSAPKCS1SignatureFormatter).FullName;
DeformatterAlgorithm = typeof(RSAPKCS1SignatureDeformatter).FullName;
}
public override AsymmetricSignatureDeformatter CreateDeformatter(AsymmetricAlgorithm key)
{
if (key == null)
{
throw new ArgumentNullException("key");
}
RSAPKCS1SignatureDeformatter deformatter = new RSAPKCS1SignatureDeformatter(key);
deformatter.SetHashAlgorithm("SHA256");
return deformatter;
}
public override AsymmetricSignatureFormatter CreateFormatter(AsymmetricAlgorithm key)
{
if (key == null)
{
throw new ArgumentNullException("key");
}
RSAPKCS1SignatureFormatter formatter = new RSAPKCS1SignatureFormatter(key);
formatter.SetHashAlgorithm("SHA256");
return formatter;
}
}
if (CryptoConfig.CreateFromName("
http://www.w3.org/2001/04/xmldsig-more#rsa-sha256") == null)
{
CryptoConfig.AddAlgorithm(typeof(RSAPKCS1SHA256SignatureDescription),
"
http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");}
if (CryptoConfig.CreateFromName("
http://www.w3.org/2001/04/xmlenc#sha256") == null)
{
CryptoConfig.AddAlgorithm(typeof(SHA256CryptoServiceProvider), "
http://www.w3.org/2001/04/xmlenc#sha256");}