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
- X509SecurityTokenAuthenticator.cs
- ConfigXmlWhitespace.cs
- PreviewPrintController.cs
- MSG.cs
- TabControlCancelEvent.cs
- TimeStampChecker.cs
- NetworkInterface.cs
- TimeEnumHelper.cs
- MappingMetadataHelper.cs
- LinkUtilities.cs
- DataObjectPastingEventArgs.cs
- AsyncPostBackErrorEventArgs.cs
- OleDbTransaction.cs
- XPathBuilder.cs
- FormViewDeletedEventArgs.cs
- IdentifierCollection.cs
- ObfuscationAttribute.cs
- Triangle.cs
- SmtpDigestAuthenticationModule.cs
- AccessedThroughPropertyAttribute.cs
- FloaterParaClient.cs
- ForeignKeyConstraint.cs
- ErrorWrapper.cs
- EntityDataSourceWizardForm.cs
- MissingFieldException.cs
- EntityTypeEmitter.cs
- MediaTimeline.cs
- InternalRelationshipCollection.cs
- TextEditorContextMenu.cs
- AdapterSwitches.cs
- PathSegmentCollection.cs
- StylusPoint.cs
- BindStream.cs
- QueryFunctions.cs
- CursorEditor.cs
- SignedInfo.cs
- connectionpool.cs
- FormattedText.cs
- HtmlInputText.cs
- ModelVisual3D.cs
- LeftCellWrapper.cs
- SoapMessage.cs
- Page.cs
- LineGeometry.cs
- JournalEntryListConverter.cs
- WebPartCloseVerb.cs
- Rules.cs
- ConfigurationProperty.cs
- Process.cs
- AutoGeneratedField.cs
- WebPartDisplayMode.cs
- SQLBoolean.cs
- Accessible.cs
- WebPartDisplayModeCancelEventArgs.cs
- XmlAttributeAttribute.cs
- TailCallAnalyzer.cs
- Image.cs
- DataGridViewTextBoxEditingControl.cs
- DataKey.cs
- ApplicationHost.cs
- ScalarOps.cs
- BuildResultCache.cs
- HierarchicalDataTemplate.cs
- ExpressionList.cs
- JournalEntryListConverter.cs
- PersonalizationAdministration.cs
- ToolStripSplitButton.cs
- DateTime.cs
- NamespaceInfo.cs
- LockedActivityGlyph.cs
- Matrix3DValueSerializer.cs
- AssociationTypeEmitter.cs
- FrameworkElement.cs
- RSACryptoServiceProvider.cs
- OutputCacheProfile.cs
- KeyGestureValueSerializer.cs
- DispatcherOperation.cs
- EntityProxyTypeInfo.cs
- PropertyInfoSet.cs
- ContentOperations.cs
- DataGridViewSelectedColumnCollection.cs
- ReservationNotFoundException.cs
- LeafCellTreeNode.cs
- DependencyObjectProvider.cs
- MailWebEventProvider.cs
- SignedXmlDebugLog.cs
- DuplicateDetector.cs
- AsnEncodedData.cs
- DataColumnCollection.cs
- RegisteredArrayDeclaration.cs
- AndCondition.cs
- ByteAnimationBase.cs
- BaseCollection.cs
- StickyNote.cs
- SimpleLine.cs
- FontDifferentiator.cs
- SubqueryRules.cs
- Comparer.cs
- VirtualizedItemProviderWrapper.cs
- hwndwrapper.cs