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
- FontStyleConverter.cs
- CacheMode.cs
- InertiaExpansionBehavior.cs
- LayoutInformation.cs
- __Filters.cs
- TypeDependencyAttribute.cs
- PropertyInfo.cs
- IconHelper.cs
- WindowsUpDown.cs
- DataListItemCollection.cs
- XPathSingletonIterator.cs
- CachedPathData.cs
- ContextMenuStripGroup.cs
- FormatStringEditor.cs
- Encoder.cs
- Span.cs
- PropertyPath.cs
- Triplet.cs
- ReachDocumentPageSerializer.cs
- System.Data_BID.cs
- WindowsPen.cs
- URIFormatException.cs
- PointConverter.cs
- WebControlAdapter.cs
- HostedNamedPipeTransportManager.cs
- RecognizedWordUnit.cs
- DataBindEngine.cs
- TraceSection.cs
- DataGridViewColumnCollection.cs
- newitemfactory.cs
- AssociationSetEnd.cs
- ModuleBuilderData.cs
- SizeAnimationClockResource.cs
- XmlAutoDetectWriter.cs
- DependencyObject.cs
- SafeTokenHandle.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- VolatileEnlistmentMultiplexing.cs
- DeleteHelper.cs
- HttpResponse.cs
- TemplatedControlDesigner.cs
- VisualBrush.cs
- DataTableMapping.cs
- FixedTextPointer.cs
- UnSafeCharBuffer.cs
- BufferedWebEventProvider.cs
- AmbientValueAttribute.cs
- VisualCollection.cs
- ValidationRuleCollection.cs
- ColumnMapCopier.cs
- AndMessageFilter.cs
- UrlAuthorizationModule.cs
- GeneralTransform3D.cs
- MetadataReference.cs
- EventSinkHelperWriter.cs
- BlurBitmapEffect.cs
- LineBreak.cs
- Compilation.cs
- BrowserCapabilitiesFactory.cs
- TableLayoutCellPaintEventArgs.cs
- NonParentingControl.cs
- ControlPropertyNameConverter.cs
- UInt32.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- LocatorPart.cs
- EditorServiceContext.cs
- _NestedSingleAsyncResult.cs
- ResourceSet.cs
- IListConverters.cs
- MiniMapControl.xaml.cs
- SqlDependency.cs
- WindowsMenu.cs
- LocalBuilder.cs
- AssertFilter.cs
- SystemIPv4InterfaceProperties.cs
- DataGridParentRows.cs
- thaishape.cs
- ProcessHostMapPath.cs
- XamlDesignerSerializationManager.cs
- HebrewNumber.cs
- IDQuery.cs
- ColorMap.cs
- PointF.cs
- SafePointer.cs
- TextElementCollectionHelper.cs
- BitmapEffectGeneralTransform.cs
- Model3DGroup.cs
- Dump.cs
- GridViewRowCollection.cs
- SelectionUIHandler.cs
- Authorization.cs
- SessionStateUtil.cs
- FrameworkReadOnlyPropertyMetadata.cs
- TextEffect.cs
- SqlAliasesReferenced.cs
- COM2PropertyDescriptor.cs
- ObjectDataSourceChooseMethodsPanel.cs
- DataGridViewImageCell.cs
- ThicknessAnimation.cs
- PartManifestEntry.cs