Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / clr / src / BCL / System / Security / Cryptography / RSAOAEPKeyExchangeFormatter.cs / 1 / RSAOAEPKeyExchangeFormatter.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== namespace System.Security.Cryptography { [System.Runtime.InteropServices.ComVisible(true)] public class RSAOAEPKeyExchangeFormatter : AsymmetricKeyExchangeFormatter { private byte[] ParameterValue; private RSA _rsaKey; private RandomNumberGenerator RngValue; // // public constructors // public RSAOAEPKeyExchangeFormatter() {} public RSAOAEPKeyExchangeFormatter(AsymmetricAlgorithm key) { if (key == null) throw new ArgumentNullException("key"); _rsaKey = (RSA) key; } // // public properties // ///public byte[] Parameter { get { if (ParameterValue != null) return (byte[]) ParameterValue.Clone(); return null; } set { if (value != null) ParameterValue = (byte[]) value.Clone(); else ParameterValue = null; } } /// public override String Parameters { get { return null; } } public RandomNumberGenerator Rng { get { return RngValue; } set { RngValue = value; } } // // public methods // public override void SetKey(AsymmetricAlgorithm key) { if (key == null) throw new ArgumentNullException("key"); _rsaKey = (RSA) key; } public override byte[] CreateKeyExchange(byte[] rgbData) { if (_rsaKey == null) throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_MissingKey")); if (_rsaKey is RSACryptoServiceProvider) { return ((RSACryptoServiceProvider) _rsaKey).Encrypt(rgbData, true); } else { return Utils.RsaOaepEncrypt(_rsaKey, SHA1.Create(), new PKCS1MaskGenerationMethod(), RandomNumberGenerator.Create(), rgbData); } } public override byte[] CreateKeyExchange(byte[] rgbData, Type symAlgType) { return CreateKeyExchange(rgbData); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== namespace System.Security.Cryptography { [System.Runtime.InteropServices.ComVisible(true)] public class RSAOAEPKeyExchangeFormatter : AsymmetricKeyExchangeFormatter { private byte[] ParameterValue; private RSA _rsaKey; private RandomNumberGenerator RngValue; // // public constructors // public RSAOAEPKeyExchangeFormatter() {} public RSAOAEPKeyExchangeFormatter(AsymmetricAlgorithm key) { if (key == null) throw new ArgumentNullException("key"); _rsaKey = (RSA) key; } // // public properties // /// public byte[] Parameter { get { if (ParameterValue != null) return (byte[]) ParameterValue.Clone(); return null; } set { if (value != null) ParameterValue = (byte[]) value.Clone(); else ParameterValue = null; } } /// public override String Parameters { get { return null; } } public RandomNumberGenerator Rng { get { return RngValue; } set { RngValue = value; } } // // public methods // public override void SetKey(AsymmetricAlgorithm key) { if (key == null) throw new ArgumentNullException("key"); _rsaKey = (RSA) key; } public override byte[] CreateKeyExchange(byte[] rgbData) { if (_rsaKey == null) throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_MissingKey")); if (_rsaKey is RSACryptoServiceProvider) { return ((RSACryptoServiceProvider) _rsaKey).Encrypt(rgbData, true); } else { return Utils.RsaOaepEncrypt(_rsaKey, SHA1.Create(), new PKCS1MaskGenerationMethod(), RandomNumberGenerator.Create(), rgbData); } } public override byte[] CreateKeyExchange(byte[] rgbData, Type symAlgType) { return CreateKeyExchange(rgbData); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SynchronousReceiveElement.cs
- ReadOnlyKeyedCollection.cs
- GridItemCollection.cs
- AsyncContentLoadedEventArgs.cs
- ComboBox.cs
- Separator.cs
- SrgsSemanticInterpretationTag.cs
- EncryptedType.cs
- Filter.cs
- SchemaLookupTable.cs
- Calendar.cs
- UnlockCardRequest.cs
- CqlParser.cs
- CompressEmulationStream.cs
- QueryReaderSettings.cs
- ExtractorMetadata.cs
- ScriptResourceDefinition.cs
- CryptoApi.cs
- AutomationPatternInfo.cs
- ConnectionPointGlyph.cs
- PackageDigitalSignature.cs
- List.cs
- unitconverter.cs
- TemplatePropertyEntry.cs
- DataGridRelationshipRow.cs
- ConfigDefinitionUpdates.cs
- Activator.cs
- VirtualizingPanel.cs
- LocationFactory.cs
- InkPresenterAutomationPeer.cs
- WmpBitmapEncoder.cs
- TransformerTypeCollection.cs
- DiscoveryReferences.cs
- TemplateInstanceAttribute.cs
- ComponentResourceKey.cs
- SiteMapPath.cs
- XmlException.cs
- FixUp.cs
- LockRecursionException.cs
- AuthorizationSection.cs
- TransformCollection.cs
- mansign.cs
- MsmqOutputChannel.cs
- HtmlInputPassword.cs
- AsyncWaitHandle.cs
- SecurityTokenValidationException.cs
- StyleTypedPropertyAttribute.cs
- CursorEditor.cs
- Query.cs
- SolidColorBrush.cs
- FormViewRow.cs
- MultiplexingDispatchMessageFormatter.cs
- Behavior.cs
- EmissiveMaterial.cs
- UDPClient.cs
- MemberPathMap.cs
- HwndSourceParameters.cs
- ObjectListCommandEventArgs.cs
- SchemaInfo.cs
- TabletDevice.cs
- ToolStripControlHost.cs
- SmiRequestExecutor.cs
- DescendentsWalker.cs
- XmlCompatibilityReader.cs
- ProfileGroupSettings.cs
- QuaternionValueSerializer.cs
- ScriptIgnoreAttribute.cs
- AmbiguousMatchException.cs
- PropertyCondition.cs
- DelegateSerializationHolder.cs
- TextModifier.cs
- XPathSingletonIterator.cs
- Timer.cs
- ServiceModelTimeSpanValidator.cs
- ParseHttpDate.cs
- VarInfo.cs
- FlowPosition.cs
- LoginDesigner.cs
- ResXFileRef.cs
- DesignerVerb.cs
- Monitor.cs
- UserInitiatedRoutedEventPermissionAttribute.cs
- IPHostEntry.cs
- ButtonBaseAutomationPeer.cs
- RSAPKCS1SignatureDeformatter.cs
- ImageMapEventArgs.cs
- ControlBuilder.cs
- LocationSectionRecord.cs
- ViewStateException.cs
- WindowCollection.cs
- ForeignKeyFactory.cs
- XPathMultyIterator.cs
- messageonlyhwndwrapper.cs
- AttachedPropertyBrowsableAttribute.cs
- OleDbDataAdapter.cs
- MouseActionValueSerializer.cs
- GridViewRowEventArgs.cs
- FixedSOMSemanticBox.cs
- DatePickerAutomationPeer.cs
- SapiRecoContext.cs