Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- FormViewPageEventArgs.cs
- TemplatedWizardStep.cs
- XamlBuildTaskServices.cs
- HtmlLink.cs
- HttpCookieCollection.cs
- AccessorTable.cs
- SelectedPathEditor.cs
- EdmRelationshipRoleAttribute.cs
- SqlDataSource.cs
- NavigationProperty.cs
- VisualStateManager.cs
- MetadataCache.cs
- CallbackCorrelationInitializer.cs
- BitmapCodecInfoInternal.cs
- BaseEntityWrapper.cs
- HostingEnvironmentWrapper.cs
- IconEditor.cs
- RoutedEventValueSerializer.cs
- TextAutomationPeer.cs
- SQLBytes.cs
- SafeRegistryHandle.cs
- GridViewCancelEditEventArgs.cs
- FilterInvalidBodyAccessException.cs
- SQLDoubleStorage.cs
- SequentialWorkflowHeaderFooter.cs
- WindowHideOrCloseTracker.cs
- MultiPageTextView.cs
- ColumnBinding.cs
- AdornerHitTestResult.cs
- AssemblyCollection.cs
- XmlSecureResolver.cs
- TextRenderer.cs
- UIElement.cs
- TextEmbeddedObject.cs
- ModuleElement.cs
- EncryptedXml.cs
- VectorConverter.cs
- _SSPIWrapper.cs
- CodeEventReferenceExpression.cs
- OdbcCommand.cs
- XamlBrushSerializer.cs
- DataControlImageButton.cs
- StoreContentChangedEventArgs.cs
- PointAnimationUsingKeyFrames.cs
- CommentEmitter.cs
- EncodingInfo.cs
- ClockGroup.cs
- DateTimeValueSerializer.cs
- SiteMapPath.cs
- ReferenceEqualityComparer.cs
- DesignerDataParameter.cs
- ComboBoxAutomationPeer.cs
- SerializationStore.cs
- Polyline.cs
- MetaData.cs
- ExtensionFile.cs
- XmlReflectionMember.cs
- CacheAxisQuery.cs
- SqlProfileProvider.cs
- CatalogPart.cs
- ManagedIStream.cs
- GroupDescription.cs
- PointAnimationUsingPath.cs
- AdministrationHelpers.cs
- GuidTagList.cs
- ToolStripItemTextRenderEventArgs.cs
- MonthCalendar.cs
- Stack.cs
- RuntimeHandles.cs
- PageAdapter.cs
- RelationshipManager.cs
- DataKeyCollection.cs
- SqlBooleanMismatchVisitor.cs
- Int64AnimationUsingKeyFrames.cs
- SqlMethodTransformer.cs
- TaiwanCalendar.cs
- OdbcConnectionString.cs
- TextEditorSpelling.cs
- SourceFileBuildProvider.cs
- VisualState.cs
- ChtmlMobileTextWriter.cs
- PolicyImporterElementCollection.cs
- SmtpSection.cs
- QueryContinueDragEventArgs.cs
- Model3D.cs
- FixedElement.cs
- ZipFileInfoCollection.cs
- InteropBitmapSource.cs
- DataGridViewRowEventArgs.cs
- regiisutil.cs
- ValueQuery.cs
- InArgumentConverter.cs
- OdbcConnectionOpen.cs
- InstanceDescriptor.cs
- DefaultPrintController.cs
- ValueUnavailableException.cs
- GraphicsPath.cs
- CombinedGeometry.cs
- ReadOnlyMetadataCollection.cs
- FloatUtil.cs