Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Security / Cryptography / RSAOAEPKeyExchangeFormatter.cs / 1305376 / RSAOAEPKeyExchangeFormatter.cs
using System.Diagnostics.Contracts; // ==++== // // 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"); Contract.EndContractBlock(); _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"); Contract.EndContractBlock(); _rsaKey = (RSA) key; } [System.Security.SecuritySafeCritical] // auto-generated 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ObjectStateEntry.cs
- CacheOutputQuery.cs
- EventMappingSettings.cs
- ListViewGroup.cs
- LocalizationCodeDomSerializer.cs
- OpCodes.cs
- StorageInfo.cs
- UserNamePasswordValidator.cs
- PackWebResponse.cs
- ShutDownListener.cs
- LocalizableResourceBuilder.cs
- Opcode.cs
- AlternateView.cs
- ListSortDescriptionCollection.cs
- FlowDocumentPage.cs
- SymDocumentType.cs
- PieceDirectory.cs
- PassportAuthenticationModule.cs
- HierarchicalDataBoundControl.cs
- HttpFileCollectionBase.cs
- DictionaryTraceRecord.cs
- ExtendedProperty.cs
- RuleRef.cs
- Memoizer.cs
- EntitySqlQueryCacheKey.cs
- ToolBarButtonClickEvent.cs
- UniqueConstraint.cs
- BasicViewGenerator.cs
- BeginEvent.cs
- UpdatePanel.cs
- BCryptHashAlgorithm.cs
- XPathBuilder.cs
- AppDomainProtocolHandler.cs
- WeakReferenceList.cs
- CollaborationHelperFunctions.cs
- JournalEntryListConverter.cs
- DesignerUtility.cs
- NativeMethodsCLR.cs
- VerticalAlignConverter.cs
- RegisteredDisposeScript.cs
- HostProtectionException.cs
- NumberAction.cs
- SqlException.cs
- DataSourceCache.cs
- MarshalDirectiveException.cs
- Base64Decoder.cs
- CryptoStream.cs
- CalendarTable.cs
- OutputCacheProfile.cs
- translator.cs
- NativeActivityTransactionContext.cs
- RootNamespaceAttribute.cs
- WindowsListView.cs
- DataGridViewRow.cs
- ActivityCollectionMarkupSerializer.cs
- OneOf.cs
- AssemblyBuilderData.cs
- WebRequestModuleElement.cs
- MetadataArtifactLoaderComposite.cs
- Matrix.cs
- CodeGen.cs
- EntryPointNotFoundException.cs
- SelectionPatternIdentifiers.cs
- CultureTableRecord.cs
- AuthenticationService.cs
- Convert.cs
- DesignerVerbCollection.cs
- DataSourceGroupCollection.cs
- ConstNode.cs
- CheckedPointers.cs
- Symbol.cs
- Style.cs
- GuidelineCollection.cs
- AttributeCollection.cs
- WebHttpSecurityElement.cs
- Hashtable.cs
- SqlCacheDependencySection.cs
- RotateTransform.cs
- MulticastOption.cs
- RegionInfo.cs
- DataBoundControlHelper.cs
- MessageHeaderInfoTraceRecord.cs
- DataPagerFieldCollection.cs
- BufferModesCollection.cs
- Trustee.cs
- DataStreamFromComStream.cs
- BuildTopDownAttribute.cs
- externdll.cs
- httpapplicationstate.cs
- AnnotationComponentChooser.cs
- ParseNumbers.cs
- BitVector32.cs
- Scanner.cs
- TextView.cs
- XmlBaseReader.cs
- ElementMarkupObject.cs
- TextReturnReader.cs
- BaseDataList.cs
- ThreadStartException.cs
- ElementsClipboardData.cs