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
- WebControl.cs
- DataTableCollection.cs
- NativeRightsManagementAPIsStructures.cs
- IChannel.cs
- DefaultProxySection.cs
- SqlTriggerAttribute.cs
- DiagnosticTraceSource.cs
- TreeNodeStyleCollection.cs
- ModulesEntry.cs
- SqlAliasesReferenced.cs
- DataServiceStreamResponse.cs
- AnimationLayer.cs
- FormViewInsertEventArgs.cs
- Button.cs
- SystemIcmpV6Statistics.cs
- HttpGetProtocolReflector.cs
- PackagePart.cs
- ViewEventArgs.cs
- UnsafeNativeMethods.cs
- filewebrequest.cs
- SelectionHighlightInfo.cs
- NativeMethods.cs
- Hashtable.cs
- WebPartDisplayModeEventArgs.cs
- ViewStateException.cs
- CatalogPartCollection.cs
- DesignerTransactionCloseEvent.cs
- OrderedDictionary.cs
- X509CertificateValidator.cs
- ObjectAnimationUsingKeyFrames.cs
- Enum.cs
- GeometryGroup.cs
- AbstractExpressions.cs
- URL.cs
- CodeCatchClauseCollection.cs
- IBuiltInEvidence.cs
- ByteStorage.cs
- ColumnClickEvent.cs
- Graphics.cs
- EventSetter.cs
- TableRowCollection.cs
- TreeViewCancelEvent.cs
- VectorCollectionValueSerializer.cs
- SpecularMaterial.cs
- ICspAsymmetricAlgorithm.cs
- TableLayoutStyle.cs
- WebPartsSection.cs
- XmlDownloadManager.cs
- FileController.cs
- SqlServices.cs
- ChangeTracker.cs
- MetadataUtilsSmi.cs
- VariableQuery.cs
- RegexEditorDialog.cs
- Permission.cs
- FixedStringLookup.cs
- CharacterMetrics.cs
- BreakRecordTable.cs
- DBAsyncResult.cs
- StackOverflowException.cs
- GlobalizationSection.cs
- PersonalizationStateInfo.cs
- SoapFormatExtensions.cs
- TreeViewHitTestInfo.cs
- SQLDateTime.cs
- ImportContext.cs
- MeasureData.cs
- SoapIncludeAttribute.cs
- Bezier.cs
- ApplicationDirectoryMembershipCondition.cs
- _FtpDataStream.cs
- XPathDocument.cs
- _BaseOverlappedAsyncResult.cs
- RTLAwareMessageBox.cs
- WebBrowserNavigatedEventHandler.cs
- WpfXamlMember.cs
- SendMessageChannelCache.cs
- HebrewNumber.cs
- ProxyDataContractResolver.cs
- NativeMethods.cs
- ObjectToIdCache.cs
- ReferentialConstraint.cs
- GetPageNumberCompletedEventArgs.cs
- OdbcHandle.cs
- RelationshipConverter.cs
- CredentialCache.cs
- CollectionBase.cs
- AstNode.cs
- XmlSchemaComplexContent.cs
- HandlerBase.cs
- XmlAttributeProperties.cs
- RectConverter.cs
- TabletCollection.cs
- Delegate.cs
- ObjectQueryProvider.cs
- HtmlInputImage.cs
- CheckBox.cs
- CommandLibraryHelper.cs
- InputBuffer.cs
- ReadOnlyHierarchicalDataSource.cs