mscorlib(4.0.0.0) API with additions
AuthenticodeSignatureInformation.cs
3 
5 {
7  [HostProtection(SecurityAction.LinkDemand, MayLeakOnAbort = true)]
8  public sealed class AuthenticodeSignatureInformation
9  {
10  private string m_description;
11 
12  private Uri m_descriptionUrl;
13 
14  private System.Security.Cryptography.CapiNative.AlgorithmId m_hashAlgorithmId;
15 
16  private X509Chain m_signatureChain;
17 
18  private TimestampInformation m_timestamp;
19 
20  private SignatureVerificationResult m_verificationResult;
21 
22  private X509Certificate2 m_signingCertificate;
23 
26  public string Description => m_description;
27 
30  public Uri DescriptionUrl => m_descriptionUrl;
31 
34  public string HashAlgorithm => System.Security.Cryptography.CapiNative.GetAlgorithmName(m_hashAlgorithmId);
35 
38  public int HResult => System.Security.Cryptography.CapiNative.HResultForVerificationResult(m_verificationResult);
39 
43  {
44  [SecuritySafeCritical]
46  get
47  {
48  return m_signatureChain;
49  }
50  }
51 
55  {
56  [SecuritySafeCritical]
58  get
59  {
60  if (m_signingCertificate == null && SignatureChain != null)
61  {
62  m_signingCertificate = SignatureChain.ChainElements[0].Certificate;
63  }
64  return m_signingCertificate;
65  }
66  }
67 
70  public TimestampInformation Timestamp => m_timestamp;
71 
75  {
76  get
77  {
78  switch (VerificationResult)
79  {
80  case SignatureVerificationResult.Valid:
81  return TrustStatus.Trusted;
82  case SignatureVerificationResult.CertificateNotExplicitlyTrusted:
83  return TrustStatus.KnownIdentity;
84  case SignatureVerificationResult.CertificateExplicitlyDistrusted:
85  return TrustStatus.Untrusted;
86  default:
87  return TrustStatus.UnknownIdentity;
88  }
89  }
90  }
91 
94  public SignatureVerificationResult VerificationResult => m_verificationResult;
95 
96  [SecurityCritical]
97  internal AuthenticodeSignatureInformation(X509Native.AXL_AUTHENTICODE_SIGNER_INFO signer, X509Chain signatureChain, TimestampInformation timestamp)
98  {
99  m_verificationResult = (SignatureVerificationResult)signer.dwError;
100  m_hashAlgorithmId = signer.algHash;
101  if (signer.pwszDescription != IntPtr.Zero)
102  {
103  m_description = Marshal.PtrToStringUni(signer.pwszDescription);
104  }
105  if (signer.pwszDescriptionUrl != IntPtr.Zero)
106  {
107  string uriString = Marshal.PtrToStringUni(signer.pwszDescriptionUrl);
108  Uri.TryCreate(uriString, UriKind.RelativeOrAbsolute, out m_descriptionUrl);
109  }
110  m_signatureChain = signatureChain;
111  if (timestamp != null && timestamp.VerificationResult != SignatureVerificationResult.MissingSignature)
112  {
113  if (timestamp.IsValid)
114  {
115  m_timestamp = timestamp;
116  }
117  else
118  {
119  m_verificationResult = SignatureVerificationResult.InvalidTimestamp;
120  }
121  }
122  else
123  {
124  m_timestamp = null;
125  }
126  }
127 
129  {
130  m_verificationResult = error;
131  }
132  }
133 }
UriKind
Defines the kinds of T:System.Uris for the M:System.Uri.IsWellFormedUriString(System....
Definition: UriKind.cs:5
X509Certificate2 SigningCertificate
Gets the certificate that signed the manifest.
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.
Might cause a resource leak on termination, if not protected by a safe handle or some other means of ...
Definition: __Canon.cs:3
static bool TryCreate(string uriString, UriKind uriKind, out Uri result)
Creates a new T:System.Uri using the specified T:System.String instance and a T:System....
Definition: Uri.cs:4782
SignatureVerificationResult VerificationResult
Gets the result of verifying the Authenticode signature.
SecurityAction
Specifies the security actions that can be performed using declarative security.
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.
TrustStatus
Identifies the level of trustworthiness that is assigned to the signature for a manifest.
Definition: TrustStatus.cs:4
bool IsValid
Gets a value indicating whether the time stamp of the signature is valid.
Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks,...
Definition: Marshal.cs:15
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
X509Chain SignatureChain
Gets the chain of certificates used to verify the Authenticode signature.
The ability to enumerate the certificates in a store.
Provides information about an Authenticode signature for a manifest.
static unsafe string PtrToStringUni(IntPtr ptr, int len)
Allocates a managed T:System.String and copies a specified number of characters from an unmanaged Uni...
Definition: Marshal.cs:103
static readonly IntPtr Zero
A read-only field that represents a pointer or handle that has been initialized to zero.
Definition: IntPtr.cs:20
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts...
Definition: Uri.cs:19
X509ChainElementCollection ChainElements
Gets a collection of T:System.Security.Cryptography.X509Certificates.X509ChainElement objects.
Definition: X509Chain.cs:141
TimestampInformation Timestamp
Gets the time stamp that was applied to the Authenticode signature.