Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- SubpageParaClient.cs
- BitmapEffectInput.cs
- HtmlTableRowCollection.cs
- CachedBitmap.cs
- ConvertTextFrag.cs
- WindowsFont.cs
- safesecurityhelperavalon.cs
- FileUtil.cs
- DynamicObjectAccessor.cs
- RequestCachePolicy.cs
- BrowserCapabilitiesFactoryBase.cs
- HttpStreamXmlDictionaryWriter.cs
- DbConnectionHelper.cs
- IsolatedStorageFilePermission.cs
- DbConnectionPoolIdentity.cs
- AnnotationResource.cs
- SymbolMethod.cs
- AxImporter.cs
- DocumentGrid.cs
- HTTPRemotingHandler.cs
- SafeMarshalContext.cs
- ScrollPattern.cs
- PropertyValueUIItem.cs
- CacheChildrenQuery.cs
- StorageEntitySetMapping.cs
- BinaryUtilClasses.cs
- EpmTargetPathSegment.cs
- ToolStripSplitButton.cs
- BindingCollection.cs
- ItemCollection.cs
- DelegateSerializationHolder.cs
- SecurityVersion.cs
- WinFormsComponentEditor.cs
- HttpCapabilitiesEvaluator.cs
- Operator.cs
- AttributeAction.cs
- DescendantQuery.cs
- DataBoundControlAdapter.cs
- TableRowsCollectionEditor.cs
- XPathException.cs
- XmlIgnoreAttribute.cs
- MutableAssemblyCacheEntry.cs
- SourceElementsCollection.cs
- X509SecurityToken.cs
- AuthenticationModulesSection.cs
- CodeExporter.cs
- EntityContainerEmitter.cs
- ContractNamespaceAttribute.cs
- PatternMatcher.cs
- BaseCollection.cs
- TabRenderer.cs
- DependencyPropertyChangedEventArgs.cs
- WindowsNonControl.cs
- GeneralTransform3DGroup.cs
- NGCSerializer.cs
- Splitter.cs
- HtmlInputPassword.cs
- Hash.cs
- ListViewContainer.cs
- Positioning.cs
- RepeaterItem.cs
- FrameworkContentElement.cs
- ContentDisposition.cs
- DesignTimeParseData.cs
- Psha1DerivedKeyGeneratorHelper.cs
- SoapHttpTransportImporter.cs
- MaterialGroup.cs
- TypeReference.cs
- Soap12ProtocolReflector.cs
- Duration.cs
- SourceLineInfo.cs
- ListViewDataItem.cs
- CompositeDispatchFormatter.cs
- ExtendedProperty.cs
- _ChunkParse.cs
- SoapIncludeAttribute.cs
- ListViewGroupConverter.cs
- GACMembershipCondition.cs
- EventItfInfo.cs
- WindowsPen.cs
- ServicePointManager.cs
- FragmentQueryProcessor.cs
- SimpleColumnProvider.cs
- TraceLog.cs
- BufferedGraphicsContext.cs
- PropertyValue.cs
- LinqDataSourceHelper.cs
- TableParaClient.cs
- CodeConditionStatement.cs
- GridItemPattern.cs
- MetadataItem.cs
- SafeRegistryKey.cs
- AppSecurityManager.cs
- SurrogateEncoder.cs
- ResumeStoryboard.cs
- SqlExpander.cs
- LocatorBase.cs
- XmlSchemaAny.cs
- XmlAttributeCollection.cs
- CursorInteropHelper.cs