[英]Add TimeStamp to digital signature
我有一个代码可以在C#中成功使用A1证书对字符串进行签名。 我需要为该签名添加一个时间戳。 时间戳需求来自诸如http://www.cryptopro.ru/tsp/tsp.srf之类的时间戳服务器,我无法弄清楚如何将时间戳添加到签名中。 它不是PDF符号,而是字符串符号。 有人可以帮我吗?
用于签名的代码:
private byte[] Sign(string text)
{
// Find the certificate we’ll use to sign
X509Certificate2 cert = new X509Certificate2(@"C:\Users\1000084016.pfx", "Password");
RSACryptoServiceProvider csp = null;
// Get its associated CSP and private key
csp = (RSACryptoServiceProvider)cert.PrivateKey;
// Hash the data
SHA1Managed sha1 = new SHA1Managed();
UnicodeEncoding encoding = new UnicodeEncoding();
byte[] data;
data = encoding.GetBytes(text);
byte[] hash = sha1.ComputeHash(data);
// Sign the hash
return csp.SignHash(hash, CryptoConfig.MapNameToOID("SHA1"));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.