小编Tur*_*çer的帖子

SHA256签名

我有一张智能卡,我需要用这个来签名.这是我在stackover中看到的一个大问题.

我不能使用RSACryptoServiceProvider,bkz它不支持RSA-SHA256 alogrithm.

在First,我使用CAPICOM.dll,如下面的代码,

SignedData sed = new SignedData();
sed.Content = "a"; // data to sign
Signer ser = new Signer();
ser.Certificate = cc;
string singnn = sed.Sign(ser, false, CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BASE64);
Run Code Online (Sandbox Code Playgroud)

但是没有公钥来验证我的签名值,我无法从capicom.dll获取验证密钥.

之后 ,

我使用X509Certificate2和RSACryptoServiceProvider,如下面的代码,

        X509Certificate2 certificate = new X509Certificate2();
        // Access Personal (MY) certificate store of current user
        X509Store my = new X509Store(StoreName.My, StoreLocation.CurrentUser);
        my.Open(OpenFlags.ReadOnly);

        // Find the certificate we'll use to sign            
        RSACryptoServiceProvider csp = null;
        foreach (X509Certificate2 cert in my.Certificates)
        {
            if (cert.Subject.Contains(certSubject))
            {
                // We found it. …
Run Code Online (Sandbox Code Playgroud)

sha1 rsa rsacryptoserviceprovider signature sha256

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

rsa ×1

rsacryptoserviceprovider ×1

sha1 ×1

sha256 ×1

signature ×1