Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Security / Cryptography / RSAPKCS1SignatureFormatter.cs / 1 / RSAPKCS1SignatureFormatter.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // // RSAPKCS1SignatureFormatter.cs // namespace System.Security.Cryptography { [System.Runtime.InteropServices.ComVisible(true)] public class RSAPKCS1SignatureFormatter : AsymmetricSignatureFormatter { private RSA _rsaKey; private String _strOID; // // public constructors // public RSAPKCS1SignatureFormatter() {} public RSAPKCS1SignatureFormatter(AsymmetricAlgorithm key) { if (key == null) throw new ArgumentNullException("key"); _rsaKey = (RSA) key; } // // public methods // public override void SetKey(AsymmetricAlgorithm key) { if (key == null) throw new ArgumentNullException("key"); _rsaKey = (RSA) key; } public override void SetHashAlgorithm(String strName) { _strOID = CryptoConfig.MapNameToOID(strName); } public override byte[] CreateSignature(byte[] rgbHash) { if (_strOID == null) throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_MissingOID")); if (_rsaKey == null) throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_MissingKey")); if (rgbHash == null) throw new ArgumentNullException("rgbHash"); // Two cases here -- if we are talking to the CSP version or if we are talking to some other RSA provider. if (_rsaKey is RSACryptoServiceProvider) { return ((RSACryptoServiceProvider) _rsaKey).SignHash(rgbHash, _strOID); } else { byte[] pad = Utils.RsaPkcs1Padding(_rsaKey, CryptoConfig.EncodeOID(_strOID), rgbHash); // Create the signature by applying the private key to the padded buffer we just created. return _rsaKey.DecryptValue(pad); } } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Divide.cs
- RootProfilePropertySettingsCollection.cs
- XhtmlConformanceSection.cs
- NodeCounter.cs
- DeflateEmulationStream.cs
- Material.cs
- GenericArgumentsUpdater.cs
- HttpFileCollection.cs
- dsa.cs
- XamlSerializerUtil.cs
- FormViewPageEventArgs.cs
- ImageMapEventArgs.cs
- MessageBox.cs
- CodeBlockBuilder.cs
- XmlSerializerVersionAttribute.cs
- URL.cs
- ControlLocalizer.cs
- hresults.cs
- XmlSchemaInclude.cs
- StrongNamePublicKeyBlob.cs
- remotingproxy.cs
- HTMLTagNameToTypeMapper.cs
- ToolStripRendererSwitcher.cs
- Stream.cs
- ConstructorNeedsTagAttribute.cs
- Quaternion.cs
- AttributeUsageAttribute.cs
- Simplifier.cs
- InvalidComObjectException.cs
- QueryException.cs
- Send.cs
- RichTextBox.cs
- LicFileLicenseProvider.cs
- TextServicesDisplayAttributePropertyRanges.cs
- CharacterMetricsDictionary.cs
- URLMembershipCondition.cs
- GraphicsContext.cs
- Baml6Assembly.cs
- BaseHashHelper.cs
- XPathNode.cs
- InspectionWorker.cs
- Fx.cs
- DiscoveryServerProtocol.cs
- WebPartVerbCollection.cs
- ObjectItemAttributeAssemblyLoader.cs
- HebrewCalendar.cs
- RewritingValidator.cs
- XmlQueryContext.cs
- DiscriminatorMap.cs
- TypeDelegator.cs
- Style.cs
- HyperLinkStyle.cs
- Baml2006KnownTypes.cs
- IdentityNotMappedException.cs
- HttpListenerContext.cs
- CaretElement.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- DesignerTransactionCloseEvent.cs
- FormatConvertedBitmap.cs
- WebPartConnectionsCancelEventArgs.cs
- _LocalDataStore.cs
- PrivateFontCollection.cs
- Comparer.cs
- MarginCollapsingState.cs
- HandlerMappingMemo.cs
- TcpSocketManager.cs
- TargetConverter.cs
- ArrangedElementCollection.cs
- SystemException.cs
- SevenBitStream.cs
- Control.cs
- AttributeXamlType.cs
- MessageEventSubscriptionService.cs
- RecordManager.cs
- Listbox.cs
- MatrixAnimationUsingPath.cs
- PathGeometry.cs
- CompilerTypeWithParams.cs
- SecurityUtils.cs
- TextSelectionProcessor.cs
- XmlSchemaAttribute.cs
- assertwrapper.cs
- GeneralTransform3DGroup.cs
- DataGridCellEditEndingEventArgs.cs
- PlatformCulture.cs
- CustomAttribute.cs
- RegexTree.cs
- LogManagementAsyncResult.cs
- ProfileGroupSettingsCollection.cs
- HtmlElementErrorEventArgs.cs
- SqlError.cs
- COM2ExtendedTypeConverter.cs
- ArcSegment.cs
- Viewport3DAutomationPeer.cs
- SemanticResolver.cs
- COM2ExtendedUITypeEditor.cs
- ControlBuilder.cs
- Vertex.cs
- SpecularMaterial.cs
- SaveWorkflowAsyncResult.cs