mirrored from https://www.bouncycastle.org/repositories/bc-csharp
-
Notifications
You must be signed in to change notification settings - Fork 602
Expand file tree
/
Copy pathTimeStampTokenInfo.cs
More file actions
74 lines (54 loc) · 2.11 KB
/
Copy pathTimeStampTokenInfo.cs
File metadata and controls
74 lines (54 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Tsp;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Tsp
{
public class TimeStampTokenInfo
{
private static TstInfo ParseTstInfo(byte[] tstInfoEncoding)
{
try
{
return TstInfo.GetInstance(tstInfoEncoding);
}
catch (Exception e)
{
throw new TspException("unable to parse TstInfo encoding: " + e.Message);
}
}
private readonly TstInfo m_tstInfo;
private readonly DateTime m_genTime;
public TimeStampTokenInfo(byte[] tstInfoEncoding)
: this(ParseTstInfo(tstInfoEncoding))
{
}
public TimeStampTokenInfo(TstInfo tstInfo)
{
m_tstInfo = tstInfo;
try
{
m_genTime = tstInfo.GenTime.ToDateTime();
}
catch (Exception e)
{
throw new TspException("unable to parse genTime field: " + e.Message);
}
}
public bool IsOrdered => m_tstInfo.Ordering.IsTrue;
public Accuracy Accuracy => m_tstInfo.Accuracy;
public DateTime GenTime => m_genTime;
public GenTimeAccuracy GenTimeAccuracy => Accuracy == null ? null : new GenTimeAccuracy(Accuracy);
public string Policy => m_tstInfo.Policy.GetID();
public BigInteger SerialNumber => m_tstInfo.SerialNumber.Value;
public GeneralName Tsa => m_tstInfo.Tsa;
public BigInteger Nonce => m_tstInfo.Nonce?.Value;
public AlgorithmIdentifier HashAlgorithm => m_tstInfo.MessageImprint.HashAlgorithm;
public string MessageImprintAlgOid => m_tstInfo.MessageImprint.HashAlgorithm.Algorithm.GetID();
public Asn1OctetString MessageImprintDigest => m_tstInfo.MessageImprint.HashedMessage;
public byte[] GetMessageImprintDigest() => m_tstInfo.MessageImprint.GetHashedMessage();
public byte[] GetEncoded() => m_tstInfo.GetEncoded();
public TstInfo TstInfo => m_tstInfo;
}
}