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
- StorageAssociationTypeMapping.cs
- AnnotationComponentChooser.cs
- Privilege.cs
- PersistChildrenAttribute.cs
- SafeHGlobalHandleCritical.cs
- GridViewItemAutomationPeer.cs
- RequestDescription.cs
- TreeNodeCollection.cs
- HttpModule.cs
- NetworkInformationPermission.cs
- XmlTextReaderImplHelpers.cs
- AQNBuilder.cs
- CssTextWriter.cs
- TCPClient.cs
- XhtmlBasicPageAdapter.cs
- List.cs
- ArgumentOutOfRangeException.cs
- ZeroOpNode.cs
- IisTraceWebEventProvider.cs
- Sequence.cs
- BindingMAnagerBase.cs
- DataGridRow.cs
- ContentElementAutomationPeer.cs
- SqlDataSourceQuery.cs
- SamlSecurityTokenAuthenticator.cs
- ISCIIEncoding.cs
- MenuItem.cs
- UrlAuthFailedErrorFormatter.cs
- Site.cs
- BamlWriter.cs
- SoapFormatter.cs
- RsaElement.cs
- ExecutedRoutedEventArgs.cs
- NodeLabelEditEvent.cs
- DataGridViewCell.cs
- SqlFacetAttribute.cs
- StorageMappingFragment.cs
- DataGridViewCellLinkedList.cs
- Preprocessor.cs
- NodeInfo.cs
- EnlistmentTraceIdentifier.cs
- AnimationClockResource.cs
- LoadRetryConstantStrategy.cs
- SoundPlayerAction.cs
- SQLBinaryStorage.cs
- TextFormatterHost.cs
- InteropBitmapSource.cs
- Overlapped.cs
- SamlConditions.cs
- MultipartContentParser.cs
- HttpHandlerActionCollection.cs
- __Error.cs
- CompositeFontParser.cs
- Rect3DValueSerializer.cs
- DbModificationClause.cs
- Transform.cs
- HashMembershipCondition.cs
- Tokenizer.cs
- ProcessModelInfo.cs
- DependencyObject.cs
- MachinePropertyVariants.cs
- ReversePositionQuery.cs
- ApplicationActivator.cs
- SettingsProviderCollection.cs
- DragEventArgs.cs
- SmtpDateTime.cs
- bidPrivateBase.cs
- IssuedTokenClientBehaviorsElementCollection.cs
- PrivateFontCollection.cs
- MultilineStringConverter.cs
- BaseDataListDesigner.cs
- VideoDrawing.cs
- ValidateNames.cs
- Pen.cs
- PathFigureCollection.cs
- Configuration.cs
- EventToken.cs
- StoryFragments.cs
- Tuple.cs
- AsyncContentLoadedEventArgs.cs
- TextBoxBase.cs
- UTF7Encoding.cs
- WebSysDefaultValueAttribute.cs
- SafeNativeMethodsOther.cs
- SystemUdpStatistics.cs
- LongTypeConverter.cs
- XamlTreeBuilder.cs
- XmlSchemaInfo.cs
- NotifyInputEventArgs.cs
- CacheSection.cs
- UpdateProgress.cs
- ClientRuntimeConfig.cs
- XmlTypeMapping.cs
- ContainerParagraph.cs
- QilXmlWriter.cs
- TextRangeSerialization.cs
- RelationshipFixer.cs
- TrailingSpaceComparer.cs
- QueryExtender.cs
- MDIClient.cs