Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Security / Cryptography / RSAPKCS1KeyExchangeDeformatter.cs / 1 / RSAPKCS1KeyExchangeDeformatter.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== namespace System.Security.Cryptography { [System.Runtime.InteropServices.ComVisible(true)] public class RSAPKCS1KeyExchangeDeformatter : AsymmetricKeyExchangeDeformatter { RSA _rsaKey; RandomNumberGenerator RngValue; // Constructors public RSAPKCS1KeyExchangeDeformatter() {} public RSAPKCS1KeyExchangeDeformatter(AsymmetricAlgorithm key) { if (key == null) throw new ArgumentNullException("key"); _rsaKey = (RSA) key; } // // public properties // public RandomNumberGenerator RNG { get { return RngValue; } set { RngValue = value; } } public override String Parameters { get { return null; } set { ;} } // // public methods // public override byte[] DecryptKeyExchange(byte[] rgbIn) { if (_rsaKey == null) throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_MissingKey")); byte[] rgbOut; if (_rsaKey is RSACryptoServiceProvider) { rgbOut = ((RSACryptoServiceProvider) _rsaKey).Decrypt(rgbIn, false); } else { int i; byte[] rgb; rgb = _rsaKey.DecryptValue(rgbIn); // // Expected format is: // 00 || 02 || PS || 00 || D // where PS does not contain any zeros. // for (i = 2; i= rgb.Length) throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_PKCS1Decoding")); i++; // Skip over the zero rgbOut = new byte[rgb.Length - i]; Buffer.InternalBlockCopy(rgb, i, rgbOut, 0, rgbOut.Length); } return rgbOut; } public override void SetKey(AsymmetricAlgorithm key) { if (key == null) throw new ArgumentNullException("key"); _rsaKey = (RSA) key; } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WindowsListViewGroupHelper.cs
- StickyNoteContentControl.cs
- ProxyManager.cs
- MailMessage.cs
- DropShadowBitmapEffect.cs
- _ServiceNameStore.cs
- WpfSharedXamlSchemaContext.cs
- SharedPersonalizationStateInfo.cs
- LongPath.cs
- SpecularMaterial.cs
- EventLogHandle.cs
- SqlBulkCopyColumnMapping.cs
- FileDialogCustomPlacesCollection.cs
- InputScopeConverter.cs
- VsPropertyGrid.cs
- Wildcard.cs
- autovalidator.cs
- WebPageTraceListener.cs
- BindStream.cs
- Accessible.cs
- OleDbConnection.cs
- DetailsViewDeleteEventArgs.cs
- X509Utils.cs
- CLRBindingWorker.cs
- ExpressionNode.cs
- TraceInternal.cs
- StrokeNodeOperations2.cs
- DependencyPropertyDescriptor.cs
- SystemColors.cs
- WebBrowserPermission.cs
- ComPlusInstanceProvider.cs
- WebWorkflowRole.cs
- ChangeDirector.cs
- Int32RectValueSerializer.cs
- DeclaredTypeValidatorAttribute.cs
- Transform.cs
- Vector3DKeyFrameCollection.cs
- ContentDisposition.cs
- DefaultTextStoreTextComposition.cs
- WebPartRestoreVerb.cs
- DataListItem.cs
- MasterPage.cs
- SmiTypedGetterSetter.cs
- ThreadExceptionDialog.cs
- LogEntryUtils.cs
- SaveFileDialog.cs
- PeerCollaborationPermission.cs
- CurrentChangingEventManager.cs
- NativeMethods.cs
- ReleaseInstanceMode.cs
- ServiceRoute.cs
- ReferenceCountedObject.cs
- TextBounds.cs
- TableLayoutStyle.cs
- ThreadInterruptedException.cs
- MediaElement.cs
- SchemaMerger.cs
- BasePattern.cs
- WindowsStreamSecurityUpgradeProvider.cs
- StrokeNodeData.cs
- PackUriHelper.cs
- XDeferredAxisSource.cs
- GPStream.cs
- SettingsPropertyValueCollection.cs
- Freezable.cs
- FileCodeGroup.cs
- QilTernary.cs
- MailMessageEventArgs.cs
- PictureBox.cs
- LinearQuaternionKeyFrame.cs
- AsyncOperation.cs
- FieldAccessException.cs
- ProcessHostFactoryHelper.cs
- SafeFindHandle.cs
- TableStyle.cs
- ContentPropertyAttribute.cs
- MemberDescriptor.cs
- TreeNodeCollection.cs
- InProcStateClientManager.cs
- XmlSchemaSequence.cs
- HelpKeywordAttribute.cs
- ControlEvent.cs
- SendMessageRecord.cs
- DocumentViewerBase.cs
- Enum.cs
- Scripts.cs
- Message.cs
- ValidationRuleCollection.cs
- ModelItemCollection.cs
- TemplateNameScope.cs
- PathStreamGeometryContext.cs
- ListControl.cs
- PreviewPrintController.cs
- ListSourceHelper.cs
- XmlImplementation.cs
- VisualProxy.cs
- XdrBuilder.cs
- ProvidersHelper.cs
- Clause.cs
- HostedElements.cs