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
- CodeTypeDeclaration.cs
- Subtree.cs
- RIPEMD160.cs
- CreateUserErrorEventArgs.cs
- TypeLoadException.cs
- ElementsClipboardData.cs
- DataControlField.cs
- BindingContext.cs
- JavaScriptObjectDeserializer.cs
- HostUtils.cs
- VisualStateChangedEventArgs.cs
- WebPartConnectionsConnectVerb.cs
- ProfileProvider.cs
- SizeValueSerializer.cs
- WebBrowsableAttribute.cs
- KnownBoxes.cs
- TimeoutConverter.cs
- InteropAutomationProvider.cs
- KeyboardEventArgs.cs
- InputReport.cs
- RemotingSurrogateSelector.cs
- WebCodeGenerator.cs
- WebPartTransformer.cs
- ToolStripDropDownItem.cs
- StylusPointPropertyUnit.cs
- Convert.cs
- PropertyChangingEventArgs.cs
- WebBrowserHelper.cs
- MailDefinition.cs
- WebHttpSecurityModeHelper.cs
- SmtpFailedRecipientsException.cs
- RowParagraph.cs
- ImageList.cs
- ObjectListSelectEventArgs.cs
- ToolBarButton.cs
- SiteMapSection.cs
- IpcClientManager.cs
- Tracer.cs
- DataGridPagerStyle.cs
- InputLangChangeRequestEvent.cs
- HttpRuntime.cs
- GroupStyle.cs
- SapiRecognizer.cs
- Panel.cs
- TileBrush.cs
- KerberosTokenFactoryCredential.cs
- BinaryExpressionHelper.cs
- ProcessProtocolHandler.cs
- AssertSection.cs
- CreateUserErrorEventArgs.cs
- XsdBuilder.cs
- XmlUtil.cs
- EmptyQuery.cs
- ModelVisual3D.cs
- Sorting.cs
- ISAPIWorkerRequest.cs
- embossbitmapeffect.cs
- CounterSampleCalculator.cs
- TemplateColumn.cs
- ProfileService.cs
- URIFormatException.cs
- StringInfo.cs
- URLIdentityPermission.cs
- SoapAttributeAttribute.cs
- util.cs
- OleDbDataAdapter.cs
- TextElementAutomationPeer.cs
- DataGridViewCellConverter.cs
- TreeNode.cs
- CorrelationExtension.cs
- XmlTextReaderImplHelpers.cs
- AddInToken.cs
- AnimationClockResource.cs
- PhonemeConverter.cs
- WinFormsSecurity.cs
- SrgsElement.cs
- nulltextnavigator.cs
- Propagator.cs
- HttpHeaderCollection.cs
- DisableDpiAwarenessAttribute.cs
- IChannel.cs
- shaperfactoryquerycacheentry.cs
- ColorBlend.cs
- WebMessageFormatHelper.cs
- PolicyLevel.cs
- BinaryFormatter.cs
- CustomAttributeFormatException.cs
- InputLangChangeEvent.cs
- SecureConversationVersion.cs
- OrthographicCamera.cs
- DBCommandBuilder.cs
- DataServiceRequestOfT.cs
- ScriptBehaviorDescriptor.cs
- XmlArrayAttribute.cs
- FacetValues.cs
- CachedTypeface.cs
- EntityModelBuildProvider.cs
- GroupBoxAutomationPeer.cs
- DragDropHelper.cs
- ScrollProviderWrapper.cs