本文整理汇总了C#中System.Security.Cryptography.X509Certificates.X509Certificate2.GetKey方法的典型用法代码示例。如果您正苦于以下问题:C# X509Certificate2.GetKey方法的具体用法?C# X509Certificate2.GetKey怎么用?C# X509Certificate2.GetKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Cryptography.X509Certificates.X509Certificate2
的用法示例。
在下文中一共展示了X509Certificate2.GetKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: sign
public byte[] sign(byte[] data, String algorithm, X509Certificate2 keyEntry)
{
if (algorithm == null)
{
throw new ArgumentNullException("El algoritmo de huella digital no puede ser nulo");
}
switch (algorithm)
{
/**
* ALGORITMOS COMPUESTOS
*/
/** Algoritmo de firma SHA1withRSA. */
case AOSignConstants.SIGN_ALGORITHM_SHA1WITHRSA:
{
ISigner signer = SignerUtilities.GetSigner("SHA-1withRSA");
signer.Init(true, keyEntry.GetKey());
signer.BlockUpdate(data, 0, data.Length);
return signer.GenerateSignature();
}
/** Algoritmo de firma MD5withRSA. */
case AOSignConstants.SIGN_ALGORITHM_MD5WITHRSA:
{
ISigner signer = SignerUtilities.GetSigner("MD5withRSA");
signer.Init(true, keyEntry.GetKey());
signer.BlockUpdate(data, 0, data.Length);
return signer.GenerateSignature();
}
/** Algoritmo de firma MD2withRSA. */
case AOSignConstants.SIGN_ALGORITHM_MD2WITHRSA:
{
ISigner signer = SignerUtilities.GetSigner("MD2withRSA");
signer.Init(true, keyEntry.GetKey());
signer.BlockUpdate(data, 0, data.Length);
return signer.GenerateSignature();
}
/** Algoritmo de firma SHA256withRSA. */
case AOSignConstants.SIGN_ALGORITHM_SHA256WITHRSA:
{
ISigner signer = SignerUtilities.GetSigner("SHA-256withRSA");
signer.Init(true, keyEntry.GetKey());
signer.BlockUpdate(data, 0, data.Length);
return signer.GenerateSignature();
}
/** Algoritmo de firma SHA384withRSA. */
case AOSignConstants.SIGN_ALGORITHM_SHA384WITHRSA:
{
ISigner signer = SignerUtilities.GetSigner("SHA-384withRSA");
signer.Init(true, keyEntry.GetKey());
signer.BlockUpdate(data, 0, data.Length);
return signer.GenerateSignature();
}
/** Algoritmo de firma SHA512withRSA. */
case AOSignConstants.SIGN_ALGORITHM_SHA512WITHRSA:
{
ISigner signer = SignerUtilities.GetSigner("SHA-512withRSA");
signer.Init(true, keyEntry.GetKey());
signer.BlockUpdate(data, 0, data.Length);
return signer.GenerateSignature();
}
/** Algoritmo de firma RSA que no incluye la generación de la huella
* digital (NONEwithRSA). */
case AOSignConstants.SIGN_ALGORITHM_NONEWITHRSA:
{
throw new ArgumentNullException("El algoritmo SIGN_ALGORITHM_NONEWITHRSA no esta soportado");
}
/** Algoritmo de firma SHA1withDSA. */
case AOSignConstants.SIGN_ALGORITHM_SHA1WITHDSA:
{
ISigner signer = SignerUtilities.GetSigner("SHA-1withDSA");
signer.Init(true, keyEntry.GetKey());
signer.BlockUpdate(data, 0, data.Length);
return signer.GenerateSignature();
}
/** Algoritmo de firma SHA1withECDSA. */
case AOSignConstants.SIGN_ALGORITHM_SHA1WITHECDSA:
{
ISigner signer = SignerUtilities.GetSigner("SHA-1withECDSA");
signer.Init(true, keyEntry.GetKey());
signer.BlockUpdate(data, 0, data.Length);
return signer.GenerateSignature();
}
/** Algoritmo de firma ECDSA que no incluye la generación de la huella
* digital (NONEwithEDSSA). */
case AOSignConstants.SIGN_ALGORITHM_NONEWITHECDSA:
{
ISigner signer = SignerUtilities.GetSigner("NONEwithECDSA");
signer.Init(true, keyEntry.GetKey());
signer.BlockUpdate(data, 0, data.Length);
return signer.GenerateSignature();
}
//.........这里部分代码省略.........