Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- ProviderMetadata.cs
- StagingAreaInputItem.cs
- CodeArgumentReferenceExpression.cs
- RuntimeConfigurationRecord.cs
- HtmlInputPassword.cs
- WorkflowInstance.cs
- DesignerDataTable.cs
- EntityWithChangeTrackerStrategy.cs
- MemberExpression.cs
- BinHexEncoder.cs
- TypeGeneratedEventArgs.cs
- HtmlToClrEventProxy.cs
- ErrorFormatterPage.cs
- PersonalizationAdministration.cs
- ClientBuildManagerCallback.cs
- ButtonChrome.cs
- XmlC14NWriter.cs
- ColorContextHelper.cs
- FrameworkElement.cs
- JsonByteArrayDataContract.cs
- Transform3DCollection.cs
- httpapplicationstate.cs
- SmtpNtlmAuthenticationModule.cs
- ClientScriptManagerWrapper.cs
- BamlLocalizabilityResolver.cs
- ParseChildrenAsPropertiesAttribute.cs
- MenuItem.cs
- XLinq.cs
- CellTreeNode.cs
- HtmlTableCellCollection.cs
- FigureParagraph.cs
- EventSetter.cs
- xdrvalidator.cs
- ExternalException.cs
- ParserHooks.cs
- CodeMemberField.cs
- StatusBarAutomationPeer.cs
- BaseTemplateParser.cs
- GeometryModel3D.cs
- XmlCustomFormatter.cs
- DataSetMappper.cs
- GroupLabel.cs
- WebMessageFormatHelper.cs
- HtmlInputPassword.cs
- _SingleItemRequestCache.cs
- MouseGestureConverter.cs
- TemplatedMailWebEventProvider.cs
- SqlBulkCopy.cs
- StyleBamlRecordReader.cs
- SafeRightsManagementQueryHandle.cs
- Timeline.cs
- UTF32Encoding.cs
- ThumbButtonInfoCollection.cs
- BufferedGraphics.cs
- DrawingDrawingContext.cs
- ProcessHost.cs
- RegexStringValidator.cs
- ConnectionManagementElementCollection.cs
- Html32TextWriter.cs
- AutomationPatternInfo.cs
- EdmRelationshipRoleAttribute.cs
- DataRowExtensions.cs
- MbpInfo.cs
- Helpers.cs
- FontNamesConverter.cs
- ListBase.cs
- TimeManager.cs
- ErrorEventArgs.cs
- CompilerScope.cs
- SqlXml.cs
- TempEnvironment.cs
- EncodingDataItem.cs
- TextProperties.cs
- DocumentScope.cs
- wmiprovider.cs
- PagedDataSource.cs
- AssemblyCollection.cs
- MergablePropertyAttribute.cs
- Timer.cs
- CharUnicodeInfo.cs
- SqlHelper.cs
- RectangleF.cs
- ServiceOperationListItemList.cs
- TraceHandler.cs
- DataPagerField.cs
- HttpCookie.cs
- Unit.cs
- httpserverutility.cs
- SQLInt32Storage.cs
- GridPatternIdentifiers.cs
- DetailsView.cs
- Baml2006KnownTypes.cs
- MessageEnumerator.cs
- XmlnsDefinitionAttribute.cs
- BindingContext.cs
- FileDialog.cs
- SqlRetyper.cs
- CompressedStack.cs
- StreamResourceInfo.cs
- SqlMethodCallConverter.cs