相关疑难解决方法(0)

BouncyCastle 时间戳协议 | 如何从 TimeStampToken 获取原始哈希?

我从散列数据创建了一个TimeStampRequest并将其发送到 tsa。

TSA 以 Granted 响应作为响应,我得到了带有时间戳的字节数组。

如何获取原始散列数据,以便验证 TSA 发送的时间戳是我声称拥有的时间戳?

提前致谢。

要求

TimeStampRequestGenerator reqGen = new TimeStampRequestGenerator();
SHA1 sha1 = SHA1CryptoServiceProvider.Create();

ValidateInput(data);
reqGen.SetCertReq(true);

Hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(data));

TimeStampRequest request = reqGen.Generate(
                 TspAlgorithms.Sha1, Hash, BigInteger.ValueOf(100));

byte[] reqData = request.GetEncoded();

record.DtRequest = DateTime.Now;

HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(stampURI);
httpReq.Method = "POST";
httpReq.ContentType = "application/timestamp-query";
httpReq.ContentLength = reqData.Length;

// Write the request content
Stream reqStream = httpReq.GetRequestStream();
reqStream.Write(reqData, 0, reqData.Length);
reqStream.Close();

HttpWebResponse httpResp = (HttpWebResponse)httpReq.GetResponse();

// Read the response
Stream respStream = new BufferedStream(httpResp.GetResponseStream()); …
Run Code Online (Sandbox Code Playgroud)

c# timestamp bouncycastle

3
推荐指数
1
解决办法
879
查看次数

标签 统计

bouncycastle ×1

c# ×1

timestamp ×1