Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / ManagedLibraries / Security / System / Security / Cryptography / Pkcs / Pkcs7Signer.cs / 1305376 / Pkcs7Signer.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // // Pkcs7Signer.cs // namespace System.Security.Cryptography.Pkcs { using System.Globalization; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] public sealed class CmsSigner { private SubjectIdentifierType m_signerIdentifierType; private X509Certificate2 m_certificate; private Oid m_digestAlgorithm; private CryptographicAttributeObjectCollection m_signedAttributes; private CryptographicAttributeObjectCollection m_unsignedAttributes; private X509Certificate2Collection m_certificates; private X509IncludeOption m_includeOption; private bool m_dummyCert; // // Constructors. // public CmsSigner () : this(SubjectIdentifierType.IssuerAndSerialNumber, null) {} public CmsSigner (SubjectIdentifierType signerIdentifierType) : this (signerIdentifierType, null) {} public CmsSigner (X509Certificate2 certificate) : this(SubjectIdentifierType.IssuerAndSerialNumber, certificate) {} [SecuritySafeCritical] public CmsSigner (CspParameters parameters) : this(SubjectIdentifierType.SubjectKeyIdentifier, PkcsUtils.CreateDummyCertificate(parameters)) { m_dummyCert = true; this.IncludeOption = X509IncludeOption.None; } public CmsSigner (SubjectIdentifierType signerIdentifierType, X509Certificate2 certificate) { switch (signerIdentifierType) { case SubjectIdentifierType.Unknown: this.SignerIdentifierType = SubjectIdentifierType.IssuerAndSerialNumber; this.IncludeOption = X509IncludeOption.ExcludeRoot; break; case SubjectIdentifierType.IssuerAndSerialNumber: this.SignerIdentifierType = signerIdentifierType; this.IncludeOption = X509IncludeOption.ExcludeRoot; break; case SubjectIdentifierType.SubjectKeyIdentifier: this.SignerIdentifierType = signerIdentifierType; this.IncludeOption = X509IncludeOption.ExcludeRoot; break; case SubjectIdentifierType.NoSignature: this.SignerIdentifierType = signerIdentifierType; this.IncludeOption = X509IncludeOption.None; break; default: this.SignerIdentifierType = SubjectIdentifierType.IssuerAndSerialNumber; this.IncludeOption = X509IncludeOption.ExcludeRoot; break; } this.Certificate = certificate; this.DigestAlgorithm = new Oid(CAPI.szOID_OIWSEC_sha1); m_signedAttributes = new CryptographicAttributeObjectCollection(); m_unsignedAttributes = new CryptographicAttributeObjectCollection(); m_certificates = new X509Certificate2Collection(); } // // Public APIs. // public SubjectIdentifierType SignerIdentifierType { get { return m_signerIdentifierType; } set { if (value != SubjectIdentifierType.IssuerAndSerialNumber && value != SubjectIdentifierType.SubjectKeyIdentifier && value != SubjectIdentifierType.NoSignature) throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, SecurityResources.GetResourceString("Arg_EnumIllegalVal"), "value")); if (m_dummyCert && value != SubjectIdentifierType.SubjectKeyIdentifier) throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, SecurityResources.GetResourceString("Arg_EnumIllegalVal"), "value")); m_signerIdentifierType = value; } } public X509Certificate2 Certificate { get { return m_certificate; } set { m_certificate = value; } } public Oid DigestAlgorithm { get { return m_digestAlgorithm; } set { m_digestAlgorithm = value; } } public CryptographicAttributeObjectCollection SignedAttributes { get { return m_signedAttributes; } } public CryptographicAttributeObjectCollection UnsignedAttributes { get { return m_unsignedAttributes; } } public X509Certificate2Collection Certificates { get { return m_certificates; } } public X509IncludeOption IncludeOption { get { return m_includeOption; } set { if (value < X509IncludeOption.None || value > X509IncludeOption.WholeChain) throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, SecurityResources.GetResourceString("Arg_EnumIllegalVal"), "value")); m_includeOption = value; } } } } // 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
- FigureParagraph.cs
- __ComObject.cs
- PassportAuthenticationModule.cs
- MD5HashHelper.cs
- AnchorEditor.cs
- HtmlDocument.cs
- RootProfilePropertySettingsCollection.cs
- TypeDescriptionProviderAttribute.cs
- isolationinterop.cs
- CommandDevice.cs
- HMACSHA256.cs
- ReverseQueryOperator.cs
- PerspectiveCamera.cs
- CompilerScopeManager.cs
- Completion.cs
- Viewport3DAutomationPeer.cs
- storepermission.cs
- CalendarBlackoutDatesCollection.cs
- UInt16Converter.cs
- WebPartZoneBase.cs
- TileBrush.cs
- XhtmlBasicValidatorAdapter.cs
- DataGridItemCollection.cs
- PersistenceContextEnlistment.cs
- SrgsItemList.cs
- XDeferredAxisSource.cs
- SessionParameter.cs
- SqlDataRecord.cs
- HtmlValidationSummaryAdapter.cs
- GiveFeedbackEvent.cs
- NodeFunctions.cs
- IImplicitResourceProvider.cs
- AnnotationHighlightLayer.cs
- HttpListenerRequest.cs
- VBIdentifierDesigner.xaml.cs
- NativeMethods.cs
- ObfuscateAssemblyAttribute.cs
- WebColorConverter.cs
- PieceNameHelper.cs
- ScriptBehaviorDescriptor.cs
- ExpressionEditorSheet.cs
- BitmapEffectRenderDataResource.cs
- CopyNodeSetAction.cs
- safex509handles.cs
- XmlSchemas.cs
- SerializableAttribute.cs
- KnownTypes.cs
- PropertyPath.cs
- ButtonChrome.cs
- ElementMarkupObject.cs
- WorkflowInstanceUnhandledExceptionRecord.cs
- Sentence.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- PackWebResponse.cs
- TemplateControl.cs
- RuleCache.cs
- WebServicesDescriptionAttribute.cs
- PeerContact.cs
- Point4D.cs
- Int32CAMarshaler.cs
- _LocalDataStoreMgr.cs
- PerformanceCounterPermissionEntry.cs
- TimersDescriptionAttribute.cs
- ListViewCancelEventArgs.cs
- WebBaseEventKeyComparer.cs
- MultiBindingExpression.cs
- FontStyle.cs
- XamlPathDataSerializer.cs
- EpmSyndicationContentSerializer.cs
- ClientScriptItemCollection.cs
- CodeVariableReferenceExpression.cs
- Component.cs
- AcceptorSessionSymmetricMessageSecurityProtocol.cs
- TaiwanLunisolarCalendar.cs
- XmlAttributeProperties.cs
- NegationPusher.cs
- CursorConverter.cs
- TypedLocationWrapper.cs
- XmlnsPrefixAttribute.cs
- ProfileEventArgs.cs
- InvariantComparer.cs
- StyleSelector.cs
- NameSpaceExtractor.cs
- OutputScopeManager.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- Translator.cs
- InternalPolicyElement.cs
- Size.cs
- RefType.cs
- SQLDateTime.cs
- SchemaElementDecl.cs
- ConfigXmlElement.cs
- ExpressionPrefixAttribute.cs
- SynchronizedPool.cs
- AppliedDeviceFiltersDialog.cs
- SiteMapNode.cs
- TextParagraphView.cs
- UrlMapping.cs
- ClientEventManager.cs
- BufferedGraphicsContext.cs