Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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);
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TextFragmentEngine.cs
- DefaultBinder.cs
- MessageBox.cs
- JsonReader.cs
- TimeSpanSecondsConverter.cs
- ObjectDataSourceChooseTypePanel.cs
- FileDataSourceCache.cs
- PropertyGridView.cs
- RegistryKey.cs
- OracleParameterCollection.cs
- SpecialNameAttribute.cs
- Lasso.cs
- Rfc2898DeriveBytes.cs
- EFAssociationProvider.cs
- SettingsPropertyIsReadOnlyException.cs
- ZipPackage.cs
- DesignTimeType.cs
- QilCloneVisitor.cs
- Evidence.cs
- ConfigXmlCDataSection.cs
- ChannelServices.cs
- LayoutSettings.cs
- EventMappingSettingsCollection.cs
- ArraySet.cs
- ScrollEvent.cs
- SqlDataSourceTableQuery.cs
- ISCIIEncoding.cs
- OutputWindow.cs
- Point4D.cs
- OleDbDataAdapter.cs
- Html32TextWriter.cs
- RowUpdatingEventArgs.cs
- DoubleIndependentAnimationStorage.cs
- MethodBuilder.cs
- GiveFeedbackEventArgs.cs
- BindingObserver.cs
- BinaryUtilClasses.cs
- ConfigXmlAttribute.cs
- WebAdminConfigurationHelper.cs
- AdapterDictionary.cs
- Hyperlink.cs
- xmlsaver.cs
- ActiveXHelper.cs
- DataServiceRequestException.cs
- Utils.cs
- Calendar.cs
- SerializationAttributes.cs
- CompositeClientFormatter.cs
- AspCompat.cs
- HierarchicalDataTemplate.cs
- HScrollProperties.cs
- BrowserCapabilitiesCompiler.cs
- ProcessHostFactoryHelper.cs
- BulletChrome.cs
- HelpKeywordAttribute.cs
- StylusPointCollection.cs
- ExtractCollection.cs
- CodeSubDirectory.cs
- SafeFindHandle.cs
- StrokeCollection.cs
- ServiceThrottlingElement.cs
- ExtensionSurface.cs
- PublishLicense.cs
- ConstraintStruct.cs
- SHA384Cng.cs
- mediaeventargs.cs
- DictionaryEntry.cs
- DataTransferEventArgs.cs
- DefaultAsyncDataDispatcher.cs
- SimpleHandlerFactory.cs
- SqlDependencyUtils.cs
- login.cs
- CatalogPartCollection.cs
- ToggleProviderWrapper.cs
- UrlAuthFailureHandler.cs
- Module.cs
- XsltConvert.cs
- OperatingSystem.cs
- oledbmetadatacollectionnames.cs
- QueryInterceptorAttribute.cs
- CellTreeNode.cs
- TextServicesPropertyRanges.cs
- UniqueIdentifierService.cs
- PingOptions.cs
- SystemIcmpV4Statistics.cs
- TemplateField.cs
- CodeNamespaceImport.cs
- CompiledQueryCacheKey.cs
- AutomationPatternInfo.cs
- WebPartCatalogAddVerb.cs
- MinimizableAttributeTypeConverter.cs
- COM2Properties.cs
- IdentityValidationException.cs
- GenericAuthenticationEventArgs.cs
- HtmlWindow.cs
- ObjectDataSourceMethodEventArgs.cs
- SystemInfo.cs
- DragSelectionMessageFilter.cs
- RtfControls.cs
- Ticks.cs