Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Security / Cryptography / DSASignatureFormatter.cs / 1305376 / DSASignatureFormatter.cs
using System.Diagnostics.Contracts; // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== //[....] // // // DSASignatureFormatter.cs // namespace System.Security.Cryptography { [System.Runtime.InteropServices.ComVisible(true)] public class DSASignatureFormatter : AsymmetricSignatureFormatter { DSA _dsaKey; String _oid; // // public constructors // public DSASignatureFormatter() { // The hash algorithm is always SHA1 _oid = CryptoConfig.MapNameToOID("SHA1"); } public DSASignatureFormatter(AsymmetricAlgorithm key) : this() { if (key == null) throw new ArgumentNullException("key"); Contract.EndContractBlock(); _dsaKey = (DSA) key; } // // public methods // public override void SetKey(AsymmetricAlgorithm key) { if (key == null) throw new ArgumentNullException("key"); Contract.EndContractBlock(); _dsaKey = (DSA) key; } public override void SetHashAlgorithm(String strName) { if (CryptoConfig.MapNameToOID(strName) != _oid) throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_InvalidOperation")); } public override byte[] CreateSignature(byte[] rgbHash) { if (rgbHash == null) throw new ArgumentNullException("rgbHash"); Contract.EndContractBlock(); if (_oid == null) throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_MissingOID")); if (_dsaKey == null) throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_MissingKey")); return _dsaKey.CreateSignature(rgbHash); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System.Diagnostics.Contracts; // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== //[....] // // // DSASignatureFormatter.cs // namespace System.Security.Cryptography { [System.Runtime.InteropServices.ComVisible(true)] public class DSASignatureFormatter : AsymmetricSignatureFormatter { DSA _dsaKey; String _oid; // // public constructors // public DSASignatureFormatter() { // The hash algorithm is always SHA1 _oid = CryptoConfig.MapNameToOID("SHA1"); } public DSASignatureFormatter(AsymmetricAlgorithm key) : this() { if (key == null) throw new ArgumentNullException("key"); Contract.EndContractBlock(); _dsaKey = (DSA) key; } // // public methods // public override void SetKey(AsymmetricAlgorithm key) { if (key == null) throw new ArgumentNullException("key"); Contract.EndContractBlock(); _dsaKey = (DSA) key; } public override void SetHashAlgorithm(String strName) { if (CryptoConfig.MapNameToOID(strName) != _oid) throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_InvalidOperation")); } public override byte[] CreateSignature(byte[] rgbHash) { if (rgbHash == null) throw new ArgumentNullException("rgbHash"); Contract.EndContractBlock(); if (_oid == null) throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_MissingOID")); if (_dsaKey == null) throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_MissingKey")); return _dsaKey.CreateSignature(rgbHash); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Font.cs
- DbSetClause.cs
- RequestQueryParser.cs
- InternalRelationshipCollection.cs
- ZipFileInfoCollection.cs
- XPathDocumentIterator.cs
- ValidatingPropertiesEventArgs.cs
- ExcCanonicalXml.cs
- DesignerActionService.cs
- DnsPermission.cs
- TextEmbeddedObject.cs
- SimpleApplicationHost.cs
- Int32Converter.cs
- QuaternionRotation3D.cs
- InfoCardBaseException.cs
- CompilerInfo.cs
- EntityKey.cs
- DesignSurfaceCollection.cs
- TraceListeners.cs
- ParameterModifier.cs
- ExportException.cs
- ContentType.cs
- ComAdminInterfaces.cs
- ProviderIncompatibleException.cs
- WebGetAttribute.cs
- unitconverter.cs
- SemanticResolver.cs
- EncoderParameter.cs
- KeyInterop.cs
- DbMetaDataColumnNames.cs
- FileClassifier.cs
- AsyncPostBackTrigger.cs
- SettingsPropertyValueCollection.cs
- RuleConditionDialog.Designer.cs
- SqlDataSourceSelectingEventArgs.cs
- SoapSchemaExporter.cs
- DefaultAssemblyResolver.cs
- FixedSOMLineRanges.cs
- WorkflowServiceOperationListItem.cs
- OfTypeExpression.cs
- BackStopAuthenticationModule.cs
- MemberHolder.cs
- SessionStateContainer.cs
- EndpointConfigContainer.cs
- Win32KeyboardDevice.cs
- XmlDocumentFragment.cs
- SaveFileDialogDesigner.cs
- XPathSingletonIterator.cs
- ListInitExpression.cs
- HashLookup.cs
- TextDecorationCollection.cs
- ReferenceConverter.cs
- FlowDocumentFormatter.cs
- XmlSchemaGroup.cs
- ExceptionUtil.cs
- Propagator.cs
- DropTarget.cs
- HostedElements.cs
- XslTransform.cs
- EnumUnknown.cs
- TransformGroup.cs
- DataGridColumnCollection.cs
- MatrixIndependentAnimationStorage.cs
- MenuItem.cs
- IgnoreFlushAndCloseStream.cs
- XmlSchemaFacet.cs
- ImplicitInputBrush.cs
- COM2ComponentEditor.cs
- TransformPatternIdentifiers.cs
- ToolStripSettings.cs
- DPTypeDescriptorContext.cs
- _SSPISessionCache.cs
- AsyncOperationManager.cs
- Registry.cs
- CodeMemberEvent.cs
- StringHelper.cs
- RealProxy.cs
- WebBrowserUriTypeConverter.cs
- FragmentNavigationEventArgs.cs
- HtmlFormWrapper.cs
- TreeViewDataItemAutomationPeer.cs
- UrlPropertyAttribute.cs
- DirectoryNotFoundException.cs
- Tile.cs
- DataGridTableCollection.cs
- cryptoapiTransform.cs
- TitleStyle.cs
- TypeInitializationException.cs
- SimpleWebHandlerParser.cs
- SoapEnvelopeProcessingElement.cs
- FileRecordSequenceHelper.cs
- ReadOnlyDataSourceView.cs
- IOException.cs
- HashCodeCombiner.cs
- ConfigXmlCDataSection.cs
- SimpleHandlerFactory.cs
- SQLInt16.cs
- SharedDp.cs
- AutoResetEvent.cs
- SoapSchemaExporter.cs