Code:
/ 4.0 / 4.0 / 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. 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
- InvalidPrinterException.cs
- PartialCachingControl.cs
- BitmapInitialize.cs
- XPathArrayIterator.cs
- SqlColumnizer.cs
- OleDbParameter.cs
- TypeSemantics.cs
- XmlSchemaAttributeGroupRef.cs
- RowToFieldTransformer.cs
- RewritingPass.cs
- AnnotationComponentChooser.cs
- DecoderReplacementFallback.cs
- DataServiceContext.cs
- SoapBinding.cs
- CqlLexerHelpers.cs
- UpdateTranslator.cs
- ServiceOperationUIEditor.cs
- ValidationHelper.cs
- DataObjectEventArgs.cs
- ParenthesizePropertyNameAttribute.cs
- FreezableCollection.cs
- DSASignatureDeformatter.cs
- IndicCharClassifier.cs
- filewebrequest.cs
- CapabilitiesSection.cs
- MatrixConverter.cs
- ButtonBase.cs
- OutputCacheSection.cs
- DesigntimeLicenseContextSerializer.cs
- SamlSubject.cs
- Double.cs
- Stacktrace.cs
- Attributes.cs
- SimpleRecyclingCache.cs
- SqlXml.cs
- CopyAction.cs
- MouseActionValueSerializer.cs
- Behavior.cs
- MemoryFailPoint.cs
- TransformPatternIdentifiers.cs
- MultiTrigger.cs
- StatusBar.cs
- EntityCommandExecutionException.cs
- Evidence.cs
- RepeatButton.cs
- PLINQETWProvider.cs
- BitmapImage.cs
- AdditionalEntityFunctions.cs
- invalidudtexception.cs
- HttpListenerRequest.cs
- StylusEditingBehavior.cs
- localization.cs
- CustomErrorsSection.cs
- XPathNodePointer.cs
- ExtendedProperty.cs
- InvokeHandlers.cs
- Mapping.cs
- ArgumentOutOfRangeException.cs
- EntityCommandExecutionException.cs
- AQNBuilder.cs
- ScrollProviderWrapper.cs
- XmlnsDefinitionAttribute.cs
- Constraint.cs
- DetailsViewPageEventArgs.cs
- X509Certificate.cs
- COM2Enum.cs
- LocatorPart.cs
- FramingEncoders.cs
- WebBrowsableAttribute.cs
- KnownBoxes.cs
- DataControlImageButton.cs
- BehaviorService.cs
- XPathNavigatorReader.cs
- BidPrivateBase.cs
- CodeStatement.cs
- TableChangeProcessor.cs
- _CommandStream.cs
- CacheChildrenQuery.cs
- ContextActivityUtils.cs
- infer.cs
- MapPathBasedVirtualPathProvider.cs
- ExtentKey.cs
- ScrollableControl.cs
- Int16.cs
- CreateUserErrorEventArgs.cs
- VectorValueSerializer.cs
- Char.cs
- UIElement.cs
- Debug.cs
- UnmanagedMarshal.cs
- XmlDictionary.cs
- ToolStripDropDown.cs
- MimeObjectFactory.cs
- BufferModesCollection.cs
- StreamReader.cs
- WorkflowShape.cs
- Types.cs
- TrustManagerMoreInformation.cs
- CriticalExceptions.cs
- SafeArrayTypeMismatchException.cs