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
- Authorization.cs
- SqlMultiplexer.cs
- Emitter.cs
- WhitespaceReader.cs
- InstanceLockException.cs
- DetailsViewUpdateEventArgs.cs
- HwndAppCommandInputProvider.cs
- XmlAtomicValue.cs
- DataViewManagerListItemTypeDescriptor.cs
- HTMLTagNameToTypeMapper.cs
- OdbcEnvironmentHandle.cs
- Processor.cs
- RuntimeConfig.cs
- XmlSchemaAttributeGroupRef.cs
- TransportContext.cs
- MessageSmuggler.cs
- BinaryReader.cs
- UnsignedPublishLicense.cs
- WebPartChrome.cs
- RoleExceptions.cs
- UrlRoutingModule.cs
- RuleInfoComparer.cs
- ExpressionList.cs
- WebPartDisplayModeCollection.cs
- PlacementWorkspace.cs
- CryptoApi.cs
- FixedNode.cs
- TdsParserHelperClasses.cs
- CngAlgorithm.cs
- XmlElementAttributes.cs
- Errors.cs
- TemplatePagerField.cs
- TextDecorationCollection.cs
- ColorAnimation.cs
- FixedHyperLink.cs
- FaultContractInfo.cs
- PageStatePersister.cs
- TextRunCache.cs
- BulletDecorator.cs
- XmlSerializerAssemblyAttribute.cs
- BrowserDefinitionCollection.cs
- RadioButton.cs
- OracleString.cs
- VisualBasicSettingsConverter.cs
- SqlStream.cs
- FacetValueContainer.cs
- InvalidPropValue.cs
- ISCIIEncoding.cs
- NotCondition.cs
- Transactions.cs
- SystemGatewayIPAddressInformation.cs
- HtmlInputRadioButton.cs
- TypeSchema.cs
- UTF8Encoding.cs
- MdiWindowListStrip.cs
- MaterializeFromAtom.cs
- ReaderOutput.cs
- Rotation3DKeyFrameCollection.cs
- ListView.cs
- ObjectComplexPropertyMapping.cs
- FixedPageStructure.cs
- SqlGenericUtil.cs
- GeometryCollection.cs
- RowTypeElement.cs
- ScrollableControl.cs
- ASCIIEncoding.cs
- AnonymousIdentificationModule.cs
- ScriptReferenceEventArgs.cs
- CheckBoxStandardAdapter.cs
- shaper.cs
- HttpWebResponse.cs
- UnlockInstanceAsyncResult.cs
- EditingCommands.cs
- Size.cs
- SqlDataSourceAdvancedOptionsForm.cs
- Subtree.cs
- UpdateInfo.cs
- PerformanceCounterPermissionEntryCollection.cs
- NumericUpDown.cs
- BindingOperations.cs
- MimeImporter.cs
- XmlTextReaderImpl.cs
- KerberosSecurityTokenParameters.cs
- SHA1Cng.cs
- AxImporter.cs
- Shape.cs
- ValidationVisibilityAttribute.cs
- XmlSerializableReader.cs
- SafeSecurityHelper.cs
- NavigationProperty.cs
- DataServiceRequestException.cs
- DeviceFiltersSection.cs
- FontFamily.cs
- IteratorFilter.cs
- AddInActivator.cs
- SafeIUnknown.cs
- XPathNavigator.cs
- XmlSchemaParticle.cs
- DesigntimeLicenseContextSerializer.cs
- ConfigurationStrings.cs