Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- StringValidator.cs
- JsonReaderDelegator.cs
- RequiredAttributeAttribute.cs
- Stream.cs
- Monitor.cs
- ZoomingMessageFilter.cs
- AudioBase.cs
- BitmapMetadataBlob.cs
- BrowserInteropHelper.cs
- ComboBoxAutomationPeer.cs
- DirectionalLight.cs
- Point3DCollection.cs
- MetabaseSettingsIis7.cs
- HttpCacheParams.cs
- RectangleGeometry.cs
- ActivationArguments.cs
- FrameworkElement.cs
- ModelUIElement3D.cs
- EmbeddedMailObjectsCollection.cs
- XPathEmptyIterator.cs
- BamlTreeNode.cs
- TypeUtil.cs
- BoundColumn.cs
- BitmapData.cs
- HostingEnvironment.cs
- SamlDoNotCacheCondition.cs
- RectangleGeometry.cs
- MasterPageBuildProvider.cs
- Subtree.cs
- ConfigXmlDocument.cs
- BamlRecords.cs
- DbConnectionStringCommon.cs
- _Semaphore.cs
- TreeNode.cs
- CompositeActivityValidator.cs
- IntermediatePolicyValidator.cs
- SqlDataAdapter.cs
- AnnotationHighlightLayer.cs
- DeploymentSection.cs
- DataSourceHelper.cs
- WS2007FederationHttpBinding.cs
- HighContrastHelper.cs
- DataServiceKeyAttribute.cs
- ConnectionManagementElementCollection.cs
- QuaternionRotation3D.cs
- FormsAuthenticationUserCollection.cs
- ScrollChrome.cs
- DataQuery.cs
- PartialTrustVisibleAssembly.cs
- FixedSOMElement.cs
- AdapterDictionary.cs
- ComProxy.cs
- COMException.cs
- CodeObjectCreateExpression.cs
- ClientTargetCollection.cs
- Expr.cs
- documentsequencetextpointer.cs
- MaterialGroup.cs
- TextRunCacheImp.cs
- ThousandthOfEmRealPoints.cs
- CodeTypeParameter.cs
- PeerApplicationLaunchInfo.cs
- Schema.cs
- ColumnTypeConverter.cs
- ContentFilePart.cs
- DbDataRecord.cs
- CodeFieldReferenceExpression.cs
- TypeForwardedFromAttribute.cs
- ColumnMapTranslator.cs
- DoubleAnimation.cs
- WebServiceEnumData.cs
- MessageEncoder.cs
- ListBoxItemAutomationPeer.cs
- _ShellExpression.cs
- DebugHandleTracker.cs
- SqlNodeAnnotations.cs
- XmlDocumentType.cs
- VideoDrawing.cs
- TransactionManagerProxy.cs
- BitmapMetadataEnumerator.cs
- SpecularMaterial.cs
- VerificationAttribute.cs
- SiteMapNodeItemEventArgs.cs
- Tracer.cs
- ImageSourceValueSerializer.cs
- QuaternionValueSerializer.cs
- AuthenticationModulesSection.cs
- MemberInfoSerializationHolder.cs
- ModifierKeysValueSerializer.cs
- TreeNodeMouseHoverEvent.cs
- CodePageUtils.cs
- StateMachineExecutionState.cs
- DataListItem.cs
- MarkupProperty.cs
- SerializationStore.cs
- FormatException.cs
- AttributeParameterInfo.cs
- CapabilitiesUse.cs
- PathData.cs
- SQLCharsStorage.cs