Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / 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); } } } } // 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
- PerformanceCounterPermissionAttribute.cs
- IxmlLineInfo.cs
- RequestCacheManager.cs
- FormViewDeleteEventArgs.cs
- InheritedPropertyChangedEventArgs.cs
- CopyNamespacesAction.cs
- Ipv6Element.cs
- Queue.cs
- RealProxy.cs
- ListViewItemSelectionChangedEvent.cs
- ProxyFragment.cs
- FormatConvertedBitmap.cs
- Vector3DIndependentAnimationStorage.cs
- StringDictionaryWithComparer.cs
- SQLBytesStorage.cs
- EntityDataSourceDataSelection.cs
- TemplateControlBuildProvider.cs
- AppDomain.cs
- GridViewColumnCollection.cs
- CriticalHandle.cs
- TextEffect.cs
- cookie.cs
- LoginCancelEventArgs.cs
- Comparer.cs
- XamlRtfConverter.cs
- StringInfo.cs
- ListBindingConverter.cs
- MediaContextNotificationWindow.cs
- DesignTimeTemplateParser.cs
- RawKeyboardInputReport.cs
- RegistryConfigurationProvider.cs
- LogLogRecord.cs
- ProcessHostFactoryHelper.cs
- ReceiveContent.cs
- PersonalizationProviderHelper.cs
- PackageStore.cs
- BoundingRectTracker.cs
- AspNetSynchronizationContext.cs
- ConstrainedGroup.cs
- PersianCalendar.cs
- SpecialNameAttribute.cs
- Attributes.cs
- ResourceDictionaryCollection.cs
- GroupStyle.cs
- CalendarBlackoutDatesCollection.cs
- TimerElapsedEvenArgs.cs
- ActivityDesignerAccessibleObject.cs
- CDSCollectionETWBCLProvider.cs
- mediaeventargs.cs
- DataGridCell.cs
- GatewayDefinition.cs
- CommentGlyph.cs
- RSAOAEPKeyExchangeFormatter.cs
- TextSelectionHighlightLayer.cs
- OracleTransaction.cs
- UnionExpr.cs
- DoubleAverageAggregationOperator.cs
- CodeObjectCreateExpression.cs
- Rect3D.cs
- MultiPartWriter.cs
- StaticTextPointer.cs
- ProxyFragment.cs
- PaperSource.cs
- AsyncPostBackTrigger.cs
- BinaryQueryOperator.cs
- RubberbandSelector.cs
- XmlSchemaComplexContentExtension.cs
- BypassElement.cs
- ClassicBorderDecorator.cs
- FlowPanelDesigner.cs
- PersistenceException.cs
- TablePattern.cs
- Debug.cs
- UriSectionData.cs
- TimeStampChecker.cs
- PrintDialogException.cs
- CodeSubDirectory.cs
- Polyline.cs
- DataTrigger.cs
- xmlformatgeneratorstatics.cs
- StopRoutingHandler.cs
- SystemThemeKey.cs
- XmlNamespaceMappingCollection.cs
- TemplateInstanceAttribute.cs
- TextContainerHelper.cs
- TiffBitmapDecoder.cs
- ProxyWebPartManager.cs
- DataGridColumnHeadersPresenter.cs
- WebPartCollection.cs
- ApplicationBuildProvider.cs
- DrawingBrush.cs
- EntityPropertyMappingAttribute.cs
- WorkflowInlining.cs
- TransactionTable.cs
- WbemException.cs
- CustomCategoryAttribute.cs
- ScrollBar.cs
- ToolStripTemplateNode.cs
- _UriTypeConverter.cs
- FontUnit.cs