Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- HttpDigestClientElement.cs
- RecommendedAsConfigurableAttribute.cs
- AssemblyNameProxy.cs
- SwitchElementsCollection.cs
- XmlSchemaComplexContentRestriction.cs
- Form.cs
- jithelpers.cs
- MessageBox.cs
- SystemUdpStatistics.cs
- CompilerResults.cs
- TextEncodedRawTextWriter.cs
- CodeBlockBuilder.cs
- ICollection.cs
- SqlFunctions.cs
- SqlFunctionAttribute.cs
- XslUrlEditor.cs
- Int32Rect.cs
- Transactions.cs
- TypeConverterValueSerializer.cs
- SapiRecognizer.cs
- ListViewInsertEventArgs.cs
- ChildrenQuery.cs
- MultiSelector.cs
- ProfessionalColorTable.cs
- BinHexEncoding.cs
- BaseDataBoundControl.cs
- CheckedListBox.cs
- DoubleLinkList.cs
- PaintEvent.cs
- PointAnimationClockResource.cs
- AnimationClockResource.cs
- InfoCardRSAOAEPKeyExchangeFormatter.cs
- EasingKeyFrames.cs
- ActivityMetadata.cs
- RoleGroup.cs
- QueryCreatedEventArgs.cs
- ObjectDataSourceEventArgs.cs
- SpellerHighlightLayer.cs
- BulletChrome.cs
- ClientConfigPaths.cs
- QueryStringParameter.cs
- VisualStyleElement.cs
- CheckStoreFileValidityRequest.cs
- BitmapSourceSafeMILHandle.cs
- GlobalizationSection.cs
- HttpResponseHeader.cs
- KnownIds.cs
- HierarchicalDataTemplate.cs
- SqlXmlStorage.cs
- ValidationEventArgs.cs
- x509store.cs
- SchemaConstraints.cs
- ConfigurationErrorsException.cs
- ClientRuntimeConfig.cs
- PaintValueEventArgs.cs
- InternalConfirm.cs
- XpsFilter.cs
- MultilineStringConverter.cs
- mactripleDES.cs
- URL.cs
- HttpConfigurationContext.cs
- EventProviderWriter.cs
- CodeTypeParameter.cs
- ConsoleCancelEventArgs.cs
- SharedUtils.cs
- ConstructorExpr.cs
- XamlClipboardData.cs
- SoapFault.cs
- SHA512.cs
- PageEventArgs.cs
- CompilerWrapper.cs
- DbExpressionRules.cs
- SQLBytes.cs
- EntityStoreSchemaGenerator.cs
- WeakReadOnlyCollection.cs
- XmlUtil.cs
- TreeView.cs
- DataBoundLiteralControl.cs
- XmlSchemaProviderAttribute.cs
- JournalEntryStack.cs
- TdsParserSessionPool.cs
- Literal.cs
- EventSourceCreationData.cs
- TabItemWrapperAutomationPeer.cs
- MediaSystem.cs
- XmlUtilWriter.cs
- PageClientProxyGenerator.cs
- PropertySegmentSerializer.cs
- QueryReaderSettings.cs
- TreeNodeClickEventArgs.cs
- WebPartRestoreVerb.cs
- Section.cs
- FontSourceCollection.cs
- DependencyObjectPropertyDescriptor.cs
- _StreamFramer.cs
- CorePropertiesFilter.cs
- ErrorActivity.cs
- XmlILCommand.cs
- Permission.cs
- GatewayDefinition.cs