Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Security / Cryptography / X509Certificates / TimestampInformation.cs / 1305376 / TimestampInformation.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== using System; using System.Diagnostics; using System.Security.Cryptography; using System.Security.Permissions; namespace System.Security.Cryptography.X509Certificates { ////// Details about the timestamp applied to a manifest's Authenticode signature /// [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] public sealed class TimestampInformation { private CapiNative.AlgorithmId m_hashAlgorithmId; private DateTime m_timestamp; private X509Chain m_timestampChain; private SignatureVerificationResult m_verificationResult; private X509Certificate2 m_timestamper; //// [System.Security.SecurityCritical] internal TimestampInformation(X509Native.AXL_AUTHENTICODE_TIMESTAMPER_INFO timestamper) { m_hashAlgorithmId = timestamper.algHash; m_verificationResult = (SignatureVerificationResult)timestamper.dwError; ulong filetime = ((ulong)((uint)timestamper.ftTimestamp.dwHighDateTime) << 32) | (ulong)((uint)timestamper.ftTimestamp.dwLowDateTime); m_timestamp = DateTime.FromFileTimeUtc((long)filetime); if (timestamper.pChainContext != IntPtr.Zero) { m_timestampChain = new X509Chain(timestamper.pChainContext); } } internal TimestampInformation(SignatureVerificationResult error) { Debug.Assert(error != SignatureVerificationResult.Valid, "error != SignatureVerificationResult.Valid"); m_verificationResult = error; } ///// /// Hash algorithm the timestamp signature was calculated with /// public string HashAlgorithm { get { return CapiNative.GetAlgorithmName(m_hashAlgorithmId); } } ////// HRESULT from verifying the timestamp /// public int HResult { get { return CapiNative.HResultForVerificationResult(m_verificationResult); } } ////// Is the signature of the timestamp valid /// public bool IsValid { get { // Timestamp signatures are valid only if they were created by a trusted chain return VerificationResult == SignatureVerificationResult.Valid || VerificationResult == SignatureVerificationResult.CertificateNotExplicitlyTrusted; } } ////// Chain of certificates used to verify the timestamp /// public X509Chain SignatureChain { [StorePermission(SecurityAction.Demand, OpenStore = true, EnumerateCertificates = true)] get { return m_timestampChain; } } ////// Certificate that signed the timestamp /// public X509Certificate2 SigningCertificate { [StorePermission(SecurityAction.Demand, OpenStore = true, EnumerateCertificates = true)] get { if (m_timestamper == null && SignatureChain != null) { m_timestamper = SignatureChain.ChainElements[0].Certificate; } return m_timestamper; } } ////// When the timestamp was applied, expressed in local time /// public DateTime Timestamp { get { return m_timestamp.ToLocalTime(); } } ////// Result of verifying the timestamp signature /// public SignatureVerificationResult VerificationResult { get { return m_verificationResult; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== using System; using System.Diagnostics; using System.Security.Cryptography; using System.Security.Permissions; namespace System.Security.Cryptography.X509Certificates { ////// Details about the timestamp applied to a manifest's Authenticode signature /// [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] public sealed class TimestampInformation { private CapiNative.AlgorithmId m_hashAlgorithmId; private DateTime m_timestamp; private X509Chain m_timestampChain; private SignatureVerificationResult m_verificationResult; private X509Certificate2 m_timestamper; //// [System.Security.SecurityCritical] internal TimestampInformation(X509Native.AXL_AUTHENTICODE_TIMESTAMPER_INFO timestamper) { m_hashAlgorithmId = timestamper.algHash; m_verificationResult = (SignatureVerificationResult)timestamper.dwError; ulong filetime = ((ulong)((uint)timestamper.ftTimestamp.dwHighDateTime) << 32) | (ulong)((uint)timestamper.ftTimestamp.dwLowDateTime); m_timestamp = DateTime.FromFileTimeUtc((long)filetime); if (timestamper.pChainContext != IntPtr.Zero) { m_timestampChain = new X509Chain(timestamper.pChainContext); } } internal TimestampInformation(SignatureVerificationResult error) { Debug.Assert(error != SignatureVerificationResult.Valid, "error != SignatureVerificationResult.Valid"); m_verificationResult = error; } ///// /// Hash algorithm the timestamp signature was calculated with /// public string HashAlgorithm { get { return CapiNative.GetAlgorithmName(m_hashAlgorithmId); } } ////// HRESULT from verifying the timestamp /// public int HResult { get { return CapiNative.HResultForVerificationResult(m_verificationResult); } } ////// Is the signature of the timestamp valid /// public bool IsValid { get { // Timestamp signatures are valid only if they were created by a trusted chain return VerificationResult == SignatureVerificationResult.Valid || VerificationResult == SignatureVerificationResult.CertificateNotExplicitlyTrusted; } } ////// Chain of certificates used to verify the timestamp /// public X509Chain SignatureChain { [StorePermission(SecurityAction.Demand, OpenStore = true, EnumerateCertificates = true)] get { return m_timestampChain; } } ////// Certificate that signed the timestamp /// public X509Certificate2 SigningCertificate { [StorePermission(SecurityAction.Demand, OpenStore = true, EnumerateCertificates = true)] get { if (m_timestamper == null && SignatureChain != null) { m_timestamper = SignatureChain.ChainElements[0].Certificate; } return m_timestamper; } } ////// When the timestamp was applied, expressed in local time /// public DateTime Timestamp { get { return m_timestamp.ToLocalTime(); } } ////// Result of verifying the timestamp signature /// public SignatureVerificationResult VerificationResult { get { return m_verificationResult; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlDesignerDataSourceView.cs
- GeneralTransform2DTo3D.cs
- AccessibleObject.cs
- StructuralCache.cs
- Calendar.cs
- GroupBox.cs
- DBParameter.cs
- TextShapeableCharacters.cs
- HashRepartitionEnumerator.cs
- LinkedResource.cs
- TextServicesContext.cs
- Queue.cs
- DataGridSortCommandEventArgs.cs
- WsdlInspector.cs
- DataSourceProvider.cs
- ObjectStateManager.cs
- MethodRental.cs
- MetadataItem_Static.cs
- SemanticResultKey.cs
- BasicDesignerLoader.cs
- mediapermission.cs
- FixedSOMTable.cs
- HtmlTableCellCollection.cs
- AnimatedTypeHelpers.cs
- ArrangedElement.cs
- ExpressionBindingCollection.cs
- ContainerControl.cs
- Panel.cs
- FrameworkName.cs
- CoTaskMemHandle.cs
- SafeUserTokenHandle.cs
- HwndSource.cs
- HwndHostAutomationPeer.cs
- ListViewDesigner.cs
- CaseInsensitiveComparer.cs
- WindowInteropHelper.cs
- LocalBuilder.cs
- Sql8ExpressionRewriter.cs
- RotateTransform3D.cs
- XmlUtil.cs
- DesigntimeLicenseContextSerializer.cs
- XmlNodeChangedEventArgs.cs
- SerialErrors.cs
- ListBoxItemWrapperAutomationPeer.cs
- EventSourceCreationData.cs
- TakeQueryOptionExpression.cs
- ControlCollection.cs
- XmlQualifiedName.cs
- GPStream.cs
- SelectionUIHandler.cs
- RegionInfo.cs
- PathFigure.cs
- PointCollection.cs
- FixedSOMGroup.cs
- Button.cs
- Base64Encoding.cs
- LocalBuilder.cs
- GPStream.cs
- WpfXamlLoader.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- XpsResource.cs
- System.Data_BID.cs
- LogicalCallContext.cs
- NameGenerator.cs
- TextSelectionProcessor.cs
- WebSysDescriptionAttribute.cs
- TablePattern.cs
- RegistryConfigurationProvider.cs
- HijriCalendar.cs
- WSSecurityXXX2005.cs
- SqlCrossApplyToCrossJoin.cs
- CharEnumerator.cs
- BamlTreeNode.cs
- ACL.cs
- SqlCrossApplyToCrossJoin.cs
- SqlBuilder.cs
- UIElement3D.cs
- LowerCaseStringConverter.cs
- COM2PictureConverter.cs
- Scheduler.cs
- XmlObjectSerializerReadContextComplexJson.cs
- GraphicsPathIterator.cs
- PaintEvent.cs
- ADMembershipProvider.cs
- UICuesEvent.cs
- SizeValueSerializer.cs
- Environment.cs
- SmiGettersStream.cs
- ToolStripDropDownClosedEventArgs.cs
- ClientOptions.cs
- ReadOnlyObservableCollection.cs
- AsymmetricKeyExchangeDeformatter.cs
- Assert.cs
- ContainerSelectorActiveEvent.cs
- Attributes.cs
- SortedList.cs
- Int32AnimationUsingKeyFrames.cs
- GenericEnumerator.cs
- ZipIOExtraField.cs
- PerformanceCounterLib.cs