Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- ConstructorArgumentAttribute.cs
- Freezable.cs
- WebRequestModulesSection.cs
- XmlCompatibilityReader.cs
- SqlMethodTransformer.cs
- ReflectionUtil.cs
- ColorAnimationBase.cs
- CodeAccessPermission.cs
- MetafileHeader.cs
- MimeMapping.cs
- AssociatedControlConverter.cs
- SqlDataReader.cs
- FacetChecker.cs
- Stack.cs
- Validator.cs
- WorkflowRuntimeServicesBehavior.cs
- Expressions.cs
- IIS7UserPrincipal.cs
- RectConverter.cs
- InertiaTranslationBehavior.cs
- TableLayoutPanel.cs
- TagPrefixAttribute.cs
- CurrencyManager.cs
- BamlRecordWriter.cs
- XmlReaderDelegator.cs
- TypeLoadException.cs
- TableLayoutColumnStyleCollection.cs
- Regex.cs
- ExpressionEvaluator.cs
- VersionedStreamOwner.cs
- SyndicationContent.cs
- CurrencyWrapper.cs
- DecimalConverter.cs
- WebServiceMethodData.cs
- PackWebResponse.cs
- InputMethodStateChangeEventArgs.cs
- SqlFacetAttribute.cs
- DataView.cs
- XamlSerializerUtil.cs
- DiagnosticsConfigurationHandler.cs
- EntityAdapter.cs
- GlyphsSerializer.cs
- DocumentPageTextView.cs
- Grammar.cs
- LoginView.cs
- UniformGrid.cs
- ColorAnimationBase.cs
- LoadWorkflowByInstanceKeyCommand.cs
- OpenTypeLayout.cs
- RewritingPass.cs
- FormDesigner.cs
- UIHelper.cs
- ByteAnimationBase.cs
- PhysicalFontFamily.cs
- VideoDrawing.cs
- DllNotFoundException.cs
- WebPartZoneBase.cs
- TraceSection.cs
- DataGridPagerStyle.cs
- ConnectionConsumerAttribute.cs
- KeysConverter.cs
- GB18030Encoding.cs
- DataGridViewCellFormattingEventArgs.cs
- PropertyHelper.cs
- WebConfigurationFileMap.cs
- ConfigurationFileMap.cs
- StateMachine.cs
- X509ChainElement.cs
- XmlTextReaderImplHelpers.cs
- FrameworkTextComposition.cs
- ElapsedEventArgs.cs
- DesignOnlyAttribute.cs
- DetailsViewUpdatedEventArgs.cs
- BoundingRectTracker.cs
- IndexExpression.cs
- Int16Storage.cs
- PingOptions.cs
- TextEditorCharacters.cs
- Profiler.cs
- LinkDescriptor.cs
- ConcurrentStack.cs
- ChangeBlockUndoRecord.cs
- TypedReference.cs
- DEREncoding.cs
- FacetChecker.cs
- ToolTipAutomationPeer.cs
- SqlFlattener.cs
- ClipboardData.cs
- SubqueryRules.cs
- BooleanFunctions.cs
- NativeMethods.cs
- GeometryValueSerializer.cs
- Figure.cs
- GridViewRowEventArgs.cs
- FormView.cs
- DecryptedHeader.cs
- SqlExpander.cs
- ObjectDataProvider.cs
- DataQuery.cs
- OperatingSystem.cs