Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Security / Cryptography / RSAOAEPKeyExchangeDeformatter.cs / 1305376 / RSAOAEPKeyExchangeDeformatter.cs
using System.Diagnostics.Contracts;
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// [....]
//
namespace System.Security.Cryptography {
[System.Runtime.InteropServices.ComVisible(true)]
public class RSAOAEPKeyExchangeDeformatter : AsymmetricKeyExchangeDeformatter {
private RSA _rsaKey; // RSA Key value to do decrypt operation
//
// public constructors
//
public RSAOAEPKeyExchangeDeformatter() {}
public RSAOAEPKeyExchangeDeformatter(AsymmetricAlgorithm key) {
if (key == null)
throw new ArgumentNullException("key");
Contract.EndContractBlock();
_rsaKey = (RSA) key;
}
//
// public properties
//
public override String Parameters {
get { return null; }
set { ; }
}
//
// public methods
//
[System.Security.SecuritySafeCritical] // auto-generated
public override byte[] DecryptKeyExchange(byte[] rgbData) {
if (_rsaKey == null)
throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_MissingKey"));
if (_rsaKey is RSACryptoServiceProvider) {
return ((RSACryptoServiceProvider) _rsaKey).Decrypt(rgbData, true);
} else {
return Utils.RsaOaepDecrypt(_rsaKey, SHA1.Create(), new PKCS1MaskGenerationMethod(), rgbData);
}
}
public override void SetKey(AsymmetricAlgorithm key) {
if (key == null)
throw new ArgumentNullException("key");
Contract.EndContractBlock();
_rsaKey = (RSA) key;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System.Diagnostics.Contracts;
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// [....]
//
namespace System.Security.Cryptography {
[System.Runtime.InteropServices.ComVisible(true)]
public class RSAOAEPKeyExchangeDeformatter : AsymmetricKeyExchangeDeformatter {
private RSA _rsaKey; // RSA Key value to do decrypt operation
//
// public constructors
//
public RSAOAEPKeyExchangeDeformatter() {}
public RSAOAEPKeyExchangeDeformatter(AsymmetricAlgorithm key) {
if (key == null)
throw new ArgumentNullException("key");
Contract.EndContractBlock();
_rsaKey = (RSA) key;
}
//
// public properties
//
public override String Parameters {
get { return null; }
set { ; }
}
//
// public methods
//
[System.Security.SecuritySafeCritical] // auto-generated
public override byte[] DecryptKeyExchange(byte[] rgbData) {
if (_rsaKey == null)
throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_MissingKey"));
if (_rsaKey is RSACryptoServiceProvider) {
return ((RSACryptoServiceProvider) _rsaKey).Decrypt(rgbData, true);
} else {
return Utils.RsaOaepDecrypt(_rsaKey, SHA1.Create(), new PKCS1MaskGenerationMethod(), rgbData);
}
}
public override void SetKey(AsymmetricAlgorithm key) {
if (key == null)
throw new ArgumentNullException("key");
Contract.EndContractBlock();
_rsaKey = (RSA) key;
}
}
}
// 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
- UntypedNullExpression.cs
- ValidationResult.cs
- HttpRequest.cs
- CallbackValidator.cs
- BevelBitmapEffect.cs
- FormClosingEvent.cs
- Keyboard.cs
- CodeEntryPointMethod.cs
- NameValueSectionHandler.cs
- CheckBox.cs
- MethodCallConverter.cs
- ExtractorMetadata.cs
- CompareValidator.cs
- Formatter.cs
- mactripleDES.cs
- TogglePatternIdentifiers.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- OleDbParameterCollection.cs
- Content.cs
- TextEditorSpelling.cs
- DefaultTextStoreTextComposition.cs
- CaretElement.cs
- BitmapScalingModeValidation.cs
- OptimizerPatterns.cs
- StorageInfo.cs
- RectangleHotSpot.cs
- ImageEditor.cs
- _ListenerResponseStream.cs
- TextFormattingConverter.cs
- COAUTHIDENTITY.cs
- DesignerInterfaces.cs
- NameHandler.cs
- DesignerDataConnection.cs
- HttpResponseHeader.cs
- DateTimePicker.cs
- TypefaceMetricsCache.cs
- AnnotationResourceChangedEventArgs.cs
- BuiltInExpr.cs
- PrimitiveDataContract.cs
- BitmapCodecInfoInternal.cs
- SuppressMergeCheckAttribute.cs
- OleDbParameter.cs
- IpcClientManager.cs
- RepeaterItemEventArgs.cs
- Polyline.cs
- XamlBrushSerializer.cs
- TypedDataSetSchemaImporterExtensionFx35.cs
- FlatButtonAppearance.cs
- PenContext.cs
- CompilerCollection.cs
- ButtonPopupAdapter.cs
- ReflectionTypeLoadException.cs
- AuthenticationModuleElementCollection.cs
- ConfigurationValue.cs
- XmlArrayItemAttribute.cs
- DataGridViewCheckBoxCell.cs
- DefaultBinder.cs
- IOThreadScheduler.cs
- DiagnosticsConfigurationHandler.cs
- RectangleGeometry.cs
- TextDpi.cs
- UnionCodeGroup.cs
- DocumentGridContextMenu.cs
- NotImplementedException.cs
- HtmlProps.cs
- TimeStampChecker.cs
- XamlStyleSerializer.cs
- WorkflowQueueInfo.cs
- MappingModelBuildProvider.cs
- securitycriticaldata.cs
- FusionWrap.cs
- Misc.cs
- GraphicsContext.cs
- WebService.cs
- TrackingStringDictionary.cs
- SHA256Cng.cs
- CloudCollection.cs
- WindowsNonControl.cs
- PersonalizationEntry.cs
- FillErrorEventArgs.cs
- DataTableClearEvent.cs
- IsolatedStorageFileStream.cs
- VolatileEnlistmentState.cs
- ThrowHelper.cs
- DataStreams.cs
- LiteralLink.cs
- DataBindingHandlerAttribute.cs
- ResourceProviderFactory.cs
- Variable.cs
- ComponentConverter.cs
- KeySpline.cs
- StringAnimationBase.cs
- PropertyToken.cs
- TypefaceCollection.cs
- KeyGesture.cs
- RecognitionResult.cs
- Int16Animation.cs
- WindowsRebar.cs
- XmlNullResolver.cs
- DetailsViewUpdateEventArgs.cs