mscorlib(4.0.0.0) API with additions
TimestampInformation.cs
2 
4 {
6  [HostProtection(SecurityAction.LinkDemand, MayLeakOnAbort = true)]
7  public sealed class TimestampInformation
8  {
9  private System.Security.Cryptography.CapiNative.AlgorithmId m_hashAlgorithmId;
10 
11  private DateTime m_timestamp;
12 
13  private X509Chain m_timestampChain;
14 
15  private SignatureVerificationResult m_verificationResult;
16 
17  private X509Certificate2 m_timestamper;
18 
21  public string HashAlgorithm => System.Security.Cryptography.CapiNative.GetAlgorithmName(m_hashAlgorithmId);
22 
25  public int HResult => System.Security.Cryptography.CapiNative.HResultForVerificationResult(m_verificationResult);
26 
30  public bool IsValid
31  {
32  get
33  {
34  if (VerificationResult != 0)
35  {
36  return VerificationResult == SignatureVerificationResult.CertificateNotExplicitlyTrusted;
37  }
38  return true;
39  }
40  }
41 
45  {
46  [SecuritySafeCritical]
48  get
49  {
50  return m_timestampChain;
51  }
52  }
53 
57  {
58  [SecuritySafeCritical]
60  get
61  {
62  if (m_timestamper == null && SignatureChain != null)
63  {
64  m_timestamper = SignatureChain.ChainElements[0].Certificate;
65  }
66  return m_timestamper;
67  }
68  }
69 
72  public DateTime Timestamp => m_timestamp.ToLocalTime();
73 
76  public SignatureVerificationResult VerificationResult => m_verificationResult;
77 
78  [SecurityCritical]
79  internal TimestampInformation(X509Native.AXL_AUTHENTICODE_TIMESTAMPER_INFO timestamper)
80  {
81  m_hashAlgorithmId = timestamper.algHash;
82  m_verificationResult = (SignatureVerificationResult)timestamper.dwError;
83  ulong fileTime = ((ulong)(uint)timestamper.ftTimestamp.dwHighDateTime << 32) | (uint)timestamper.ftTimestamp.dwLowDateTime;
84  m_timestamp = DateTime.FromFileTimeUtc((long)fileTime);
85  if (timestamper.pChainContext != IntPtr.Zero)
86  {
87  m_timestampChain = new X509Chain(timestamper.pChainContext);
88  }
89  }
90 
92  {
93  m_verificationResult = error;
94  }
95  }
96 }
SignatureVerificationResult
Specifies most of the result codes for signature verification.
Provides details about the time stamp that was applied to an Authenticode signature for a manifest.
Definition: __Canon.cs:3
X509Certificate2 SigningCertificate
Gets the certificate that signed the time stamp.
Represents an instant in time, typically expressed as a date and time of day. To browse the ....
Definition: DateTime.cs:13
X509Chain SignatureChain
Gets the chain of certificates used to verify the time stamp of the signature.
int HResult
Gets the HRESULT value that results from verifying the signature.
static DateTime FromFileTimeUtc(long fileTime)
Converts the specified Windows file time to an equivalent UTC time.
Definition: DateTime.cs:1103
DateTime ToLocalTime()
Converts the value of the current T:System.DateTime object to local time.
Definition: DateTime.cs:1460
SecurityAction
Specifies the security actions that can be performed using declarative security.
DateTime Timestamp
Gets the time stamp that was applied to the signature.
Controls access to stores containing X.509 certificates. This class cannot be inherited.
A platform-specific type that is used to represent a pointer or a handle.
Definition: IntPtr.cs:14
SignatureVerificationResult VerificationResult
Gets the result of verifying the time stamp signature.
bool IsValid
Gets a value indicating whether the time stamp of the signature is valid.
Represents the base class from which all implementations of cryptographic hash algorithms must derive...
Definition: HashAlgorithm.cs:8
Represents a chain-building engine for T:System.Security.Cryptography.X509Certificates....
Definition: X509Chain.cs:10
The ability to enumerate the certificates in a store.
static readonly IntPtr Zero
A read-only field that represents a pointer or handle that has been initialized to zero.
Definition: IntPtr.cs:20
X509ChainElementCollection ChainElements
Gets a collection of T:System.Security.Cryptography.X509Certificates.X509ChainElement objects.
Definition: X509Chain.cs:141