Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Security / Cryptography / RSAOAEPKeyExchangeFormatter.cs / 1305376 / RSAOAEPKeyExchangeFormatter.cs
using System.Diagnostics.Contracts; // ==++== // // 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"); Contract.EndContractBlock(); _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"); Contract.EndContractBlock(); _rsaKey = (RSA) key; } [System.Security.SecuritySafeCritical] // auto-generated 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. using System.Diagnostics.Contracts; // ==++== // // 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"); Contract.EndContractBlock(); _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"); Contract.EndContractBlock(); _rsaKey = (RSA) key; } [System.Security.SecuritySafeCritical] // auto-generated 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ProfileInfo.cs
- Avt.cs
- StyleHelper.cs
- CodeMemberProperty.cs
- SessionStateModule.cs
- GridView.cs
- ImageIndexConverter.cs
- LinkedResource.cs
- Form.cs
- TrackingMemoryStreamFactory.cs
- ExpressionNode.cs
- ScriptManagerProxy.cs
- ModifierKeysConverter.cs
- SectionInformation.cs
- RetrieveVirtualItemEventArgs.cs
- SqlTriggerContext.cs
- MouseActionConverter.cs
- WebConfigurationFileMap.cs
- InvokeHandlers.cs
- COAUTHINFO.cs
- TextRunTypographyProperties.cs
- XmlBufferReader.cs
- MethodInfo.cs
- BamlResourceContent.cs
- XmlSchemaImport.cs
- MD5CryptoServiceProvider.cs
- ControlValuePropertyAttribute.cs
- HashAlgorithm.cs
- CompoundFileStreamReference.cs
- Walker.cs
- XmlDocumentType.cs
- InfiniteIntConverter.cs
- SecurityDescriptor.cs
- XmlDictionaryReaderQuotas.cs
- Attribute.cs
- DoubleLinkList.cs
- cryptoapiTransform.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- ReliabilityContractAttribute.cs
- baseaxisquery.cs
- DockPattern.cs
- DataGridViewIntLinkedList.cs
- HtmlSelectionListAdapter.cs
- ModuleBuilderData.cs
- CustomValidator.cs
- AppSecurityManager.cs
- CollectionEditor.cs
- SessionPageStatePersister.cs
- DbProviderFactory.cs
- DefaultProxySection.cs
- CollectionContainer.cs
- SelectionProcessor.cs
- DataDocumentXPathNavigator.cs
- OutOfMemoryException.cs
- DataStreamFromComStream.cs
- DataBoundControl.cs
- BasicCommandTreeVisitor.cs
- HtmlInputImage.cs
- Util.cs
- InternalsVisibleToAttribute.cs
- Funcletizer.cs
- SocketElement.cs
- NestedContainer.cs
- MD5.cs
- ContainerParaClient.cs
- WpfKnownTypeInvoker.cs
- VirtualPathUtility.cs
- EventProviderWriter.cs
- HttpCapabilitiesEvaluator.cs
- ToolStripArrowRenderEventArgs.cs
- MultiplexingFormatMapping.cs
- GetCryptoTransformRequest.cs
- MethodInfo.cs
- Type.cs
- ToolStripSeparatorRenderEventArgs.cs
- EqualityComparer.cs
- COMException.cs
- FileLevelControlBuilderAttribute.cs
- XmlDsigSep2000.cs
- ResourceExpressionBuilder.cs
- ModuleConfigurationInfo.cs
- SafeNativeMethods.cs
- HostingEnvironment.cs
- MenuBase.cs
- BinHexEncoder.cs
- ProcessModuleCollection.cs
- TemplateInstanceAttribute.cs
- WebBrowserUriTypeConverter.cs
- BulletDecorator.cs
- TransformerInfoCollection.cs
- Parsers.cs
- QilName.cs
- NullableDoubleSumAggregationOperator.cs
- TTSEvent.cs
- UnhandledExceptionEventArgs.cs
- control.ime.cs
- RunInstallerAttribute.cs
- Vector3DConverter.cs
- ScriptBehaviorDescriptor.cs
- SqlGenericUtil.cs