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
- DataGridViewColumnHeaderCell.cs
- RoleManagerEventArgs.cs
- Bits.cs
- ErrorFormatter.cs
- UnsafeNativeMethods.cs
- BooleanConverter.cs
- CallId.cs
- ObjectQuery_EntitySqlExtensions.cs
- XmlElementList.cs
- NumberFunctions.cs
- DateTimeValueSerializerContext.cs
- TypeConverterHelper.cs
- LogLogRecord.cs
- HttpPostProtocolImporter.cs
- CompiledXpathExpr.cs
- ConvertersCollection.cs
- PointCollection.cs
- DbExpressionRules.cs
- MatrixCamera.cs
- TemplateColumn.cs
- DataIdProcessor.cs
- TemplatePropertyEntry.cs
- SqlInternalConnectionTds.cs
- ColorTranslator.cs
- SoapTypeAttribute.cs
- mactripleDES.cs
- StyleTypedPropertyAttribute.cs
- PartialCachingControl.cs
- CallbackHandler.cs
- filewebresponse.cs
- Permission.cs
- WindowsListViewScroll.cs
- Events.cs
- AsyncPostBackTrigger.cs
- CollectionChangeEventArgs.cs
- RewritingValidator.cs
- ContentPropertyAttribute.cs
- ProviderBase.cs
- PassportIdentity.cs
- XmlAttributeOverrides.cs
- ContextMenuAutomationPeer.cs
- AuthenticatedStream.cs
- StrongNameIdentityPermission.cs
- HttpPostedFile.cs
- ShutDownListener.cs
- SafeEventLogReadHandle.cs
- MenuTracker.cs
- SizeFConverter.cs
- LambdaSerializationException.cs
- SearchForVirtualItemEventArgs.cs
- DataGridState.cs
- SubpageParagraph.cs
- Literal.cs
- AggregateNode.cs
- AnnotationResourceChangedEventArgs.cs
- DataGridViewCellValueEventArgs.cs
- Win32MouseDevice.cs
- ChoiceConverter.cs
- ConfigXmlAttribute.cs
- ImmComposition.cs
- PrintPageEvent.cs
- NamespaceInfo.cs
- WebServiceHost.cs
- contentDescriptor.cs
- ListViewEditEventArgs.cs
- HttpListenerResponse.cs
- TypeValidationEventArgs.cs
- ExchangeUtilities.cs
- DataGridViewControlCollection.cs
- DataServiceConfiguration.cs
- DataGridViewComboBoxCell.cs
- DelayedRegex.cs
- NamespaceEmitter.cs
- WindowsProgressbar.cs
- BitmapEffect.cs
- GregorianCalendar.cs
- isolationinterop.cs
- TimeEnumHelper.cs
- Vector3DIndependentAnimationStorage.cs
- PageThemeParser.cs
- MailMessage.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- DefaultPrintController.cs
- SystemIPv6InterfaceProperties.cs
- EntityDataSourceView.cs
- ImageSource.cs
- StorageFunctionMapping.cs
- RotateTransform.cs
- RowUpdatedEventArgs.cs
- Literal.cs
- tooltip.cs
- ChangePasswordAutoFormat.cs
- Symbol.cs
- CacheVirtualItemsEvent.cs
- MetadataItemEmitter.cs
- DesignerVerbCollection.cs
- SecurityUniqueId.cs
- PropertyDescriptorComparer.cs
- DateRangeEvent.cs
- ClientEventManager.cs