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
- DesignBindingConverter.cs
- EventLog.cs
- DocumentViewerHelper.cs
- __FastResourceComparer.cs
- BitmapDownload.cs
- ParentUndoUnit.cs
- WinFormsSpinner.cs
- DesignColumnCollection.cs
- WebPartVerbsEventArgs.cs
- SqlParameterCollection.cs
- DispatcherOperation.cs
- StringSource.cs
- SuppressIldasmAttribute.cs
- InstanceDataCollection.cs
- VectorCollection.cs
- AuthenticationModuleElement.cs
- DiscoveryClientProtocol.cs
- StateMachineWorkflowInstance.cs
- WindowHideOrCloseTracker.cs
- HttpContext.cs
- ApplicationId.cs
- ResourceDescriptionAttribute.cs
- FrameworkReadOnlyPropertyMetadata.cs
- SqlTypesSchemaImporter.cs
- LogSwitch.cs
- ConfigurationElementProperty.cs
- CryptoApi.cs
- Scripts.cs
- ExcCanonicalXml.cs
- SqlMultiplexer.cs
- EditorReuseAttribute.cs
- RestClientProxyHandler.cs
- JsonReaderWriterFactory.cs
- AutomationPropertyInfo.cs
- CheckBoxList.cs
- ResXDataNode.cs
- SimpleType.cs
- SafeHandle.cs
- KerberosSecurityTokenAuthenticator.cs
- Comparer.cs
- HandlerFactoryCache.cs
- SoapHeaderException.cs
- EventLogHandle.cs
- CombinedGeometry.cs
- SqlDataSourceCommandEventArgs.cs
- Utils.cs
- RenderData.cs
- GrammarBuilderWildcard.cs
- AttributeParameterInfo.cs
- HttpCookiesSection.cs
- Renderer.cs
- HelpInfo.cs
- hresults.cs
- OpenTypeLayoutCache.cs
- DataSourceView.cs
- SelectionItemProviderWrapper.cs
- InfoCardArgumentException.cs
- SmiGettersStream.cs
- ReadOnlyHierarchicalDataSource.cs
- MatrixIndependentAnimationStorage.cs
- DbDeleteCommandTree.cs
- DefinitionUpdate.cs
- Events.cs
- DrawingAttributesDefaultValueFactory.cs
- TextSelectionHighlightLayer.cs
- FtpRequestCacheValidator.cs
- FileController.cs
- OdbcCommand.cs
- PropertyGridView.cs
- CmsInterop.cs
- HtmlTableRowCollection.cs
- QilReference.cs
- SafeReadContext.cs
- BitmapEffectCollection.cs
- TdsParameterSetter.cs
- LabelInfo.cs
- ModifiableIteratorCollection.cs
- PageRequestManager.cs
- PathData.cs
- ProviderUtil.cs
- ReservationNotFoundException.cs
- WindowsGraphicsCacheManager.cs
- AssemblyNameProxy.cs
- OleStrCAMarshaler.cs
- RenderDataDrawingContext.cs
- XmlReader.cs
- WindowsStartMenu.cs
- IResourceProvider.cs
- DataBinder.cs
- EntityWithKeyStrategy.cs
- ParallelQuery.cs
- ThicknessKeyFrameCollection.cs
- DetailsViewUpdateEventArgs.cs
- Utils.cs
- CodeDomConfigurationHandler.cs
- ObjectDataSourceChooseMethodsPanel.cs
- NativeMethods.cs
- SubclassTypeValidatorAttribute.cs
- XmlMemberMapping.cs
- AssociationSetMetadata.cs