从SHA1到SHA256的数字标牌 [英] Digital sign From SHA1 to SHA256

查看:131
本文介绍了从SHA1到SHA256的数字标牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试更新执行数字签名的功能,我想从SHA1切换到SHA256,这是当前功能:

Hello, I'm trying to update a function that performs a digital signature, I want to switch from SHA1 to SHA256 this is the current function:

private byte[] zSignData(Byte[] msg, X509Certificate2 signerCert)
{
ContentInfo contentInfo = new ContentInfo(msg);
SignedCms signedCms = new SignedCms(contentInfo, false);
CmsSigner cmsSigner = new CmsSigner(signerCert);

cmsSigner
.DigestAlgorithm = new Oid("1.3.14.3.2.26"); //SHA1

signedCms
.ComputeSignature(cmsSigner, false);

return signedCms.Encode();
}

此功能运行良好

要更改为SHA256,我更改了

To update to SHA256, I changed

cmsSigner.DigestAlgorithm =新的Oid("1.3.14.3.2.26"); //SHA1

cmsSigner.DigestAlgorithm = new Oid("1.3.14.3.2.26"); //SHA1

使用

cmsSigner.DigestAlgorithm =新的Oid("2.16.840.1.101.3.4.2.1");//SHA256

cmsSigner.DigestAlgorithm = new Oid("2.16.840.1.101.3.4.2.1");//SHA256

但在

signedCms.ComputeSignature(cmsSigner,false);

signedCms.ComputeSignature(cmsSigner, false);

我收到以下异常System.Security.Cryptography.CryptographicException Message =存在内部错误.

I get the following exception System.Security.Cryptography.CryptographicException Message=There was an internal error.

(InnerException为null,eventviewer中没有消息)

(InnerException is null and no message in eventviewer)

有人有建议吗?

我使用VS2010 Professional 64和Win7 Professional 64以及我安装了智能卡随附的加密服务提供商CSP.

I work with VS2010 Professional 64 and win7 professional 64 and  I installed the crypto service provider CSP provided with the smart card.

非常感谢

推荐答案

谢谢您的提问.

Thank you for your question. 

我正在尝试让熟悉此主题的人进一步研究这个问题.可能会有一些时间延迟.感谢您的耐心.

I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

感谢您的理解和支持.

Thank you for your understanding and support.


这篇关于从SHA1到SHA256的数字标牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆