Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XhtmlBasicTextBoxAdapter.cs
- SyndicationDeserializer.cs
- RolePrincipal.cs
- EventLogPermissionAttribute.cs
- RemotingConfigParser.cs
- SmiMetaDataProperty.cs
- WindowsSecurityToken.cs
- CommonGetThemePartSize.cs
- SoapAttributeAttribute.cs
- HttpProxyCredentialType.cs
- AppDomainShutdownMonitor.cs
- ServiceRouteHandler.cs
- Rect.cs
- ReaderContextStackData.cs
- DataGridViewElement.cs
- SmiTypedGetterSetter.cs
- MultiViewDesigner.cs
- ObjectRef.cs
- TripleDES.cs
- WindowsPen.cs
- PlanCompiler.cs
- UriTemplateDispatchFormatter.cs
- ValidatingReaderNodeData.cs
- Matrix.cs
- WebServiceParameterData.cs
- DesignTimeParseData.cs
- _NegotiateClient.cs
- As.cs
- ConnectorRouter.cs
- XPathArrayIterator.cs
- CollectionsUtil.cs
- NameSpaceEvent.cs
- EditorZone.cs
- ContentTypeSettingDispatchMessageFormatter.cs
- TraceListener.cs
- PropertyDescriptorComparer.cs
- SuppressMessageAttribute.cs
- CompiledRegexRunner.cs
- QilGeneratorEnv.cs
- SHA512.cs
- TextDecorationUnitValidation.cs
- ToolStripPanel.cs
- CryptoApi.cs
- IndicShape.cs
- StringDictionary.cs
- WindowsScroll.cs
- ScriptReferenceBase.cs
- InternalPermissions.cs
- SoapCommonClasses.cs
- TripleDES.cs
- EntryIndex.cs
- StrokeCollection2.cs
- NamedPipeTransportElement.cs
- HashMembershipCondition.cs
- DesignerAttribute.cs
- DBConcurrencyException.cs
- VectorCollectionConverter.cs
- SchemaObjectWriter.cs
- TemplateBuilder.cs
- NavigatorInput.cs
- InsufficientExecutionStackException.cs
- TcpConnectionPool.cs
- CustomErrorCollection.cs
- CodeBlockBuilder.cs
- InternalConfigSettingsFactory.cs
- GenerateScriptTypeAttribute.cs
- ColorConvertedBitmap.cs
- DataSpaceManager.cs
- PolicyLevel.cs
- SqlDataSourceCommandParser.cs
- RectConverter.cs
- Paragraph.cs
- ProcessModelInfo.cs
- Version.cs
- RemoteWebConfigurationHost.cs
- GridViewSelectEventArgs.cs
- PathFigure.cs
- SingleStorage.cs
- ButtonStandardAdapter.cs
- TextSyndicationContent.cs
- SchemaHelper.cs
- DesignerAttributeInfo.cs
- EdmScalarPropertyAttribute.cs
- HtmlElement.cs
- EncryptedPackageFilter.cs
- MouseEvent.cs
- _NtlmClient.cs
- CustomError.cs
- Thickness.cs
- MasterPage.cs
- IgnoreFileBuildProvider.cs
- SettingsContext.cs
- DelegatingConfigHost.cs
- Operators.cs
- DataServiceQueryProvider.cs
- DataIdProcessor.cs
- HttpResponseHeader.cs
- Point4D.cs
- PopOutPanel.cs
- OleAutBinder.cs