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
- SmtpDigestAuthenticationModule.cs
- ChtmlPageAdapter.cs
- SafeNativeMemoryHandle.cs
- EventLogPermissionHolder.cs
- CodeTypeConstructor.cs
- ProjectedWrapper.cs
- DirtyTextRange.cs
- ByteStack.cs
- ReversePositionQuery.cs
- ActiveXContainer.cs
- XmlIgnoreAttribute.cs
- CommandField.cs
- GenericTypeParameterConverter.cs
- Dynamic.cs
- SimpleTypeResolver.cs
- Point3D.cs
- DataGridViewSortCompareEventArgs.cs
- TextChange.cs
- coordinatorscratchpad.cs
- HtmlElementEventArgs.cs
- ChangePasswordDesigner.cs
- ClientSponsor.cs
- EvidenceBase.cs
- MembershipPasswordException.cs
- SimpleMailWebEventProvider.cs
- ContextStaticAttribute.cs
- DataGridrowEditEndingEventArgs.cs
- ByteRangeDownloader.cs
- BuildManager.cs
- TraceSource.cs
- CharEnumerator.cs
- XmlSerializerNamespaces.cs
- HttpResponseBase.cs
- SplashScreenNativeMethods.cs
- Parameter.cs
- FocusManager.cs
- NamespaceCollection.cs
- PointCollection.cs
- ResourceType.cs
- DetailsViewUpdateEventArgs.cs
- ControlCollection.cs
- FragmentQueryKB.cs
- RijndaelManagedTransform.cs
- DbConnectionOptions.cs
- ClientUrlResolverWrapper.cs
- ListBox.cs
- GridViewCellAutomationPeer.cs
- WebPartAuthorizationEventArgs.cs
- Tile.cs
- PagedDataSource.cs
- NavigatorOutput.cs
- ApplicationFileCodeDomTreeGenerator.cs
- NamespaceCollection.cs
- UrlAuthorizationModule.cs
- TemplateBamlTreeBuilder.cs
- DefaultWorkflowTransactionService.cs
- ExtensionDataObject.cs
- BinaryExpression.cs
- SiteMapNodeItem.cs
- PeerChannelFactory.cs
- ActiveXHelper.cs
- LocalClientSecuritySettingsElement.cs
- Cursors.cs
- MappingModelBuildProvider.cs
- SharedPersonalizationStateInfo.cs
- FlowNode.cs
- PrePostDescendentsWalker.cs
- PostBackTrigger.cs
- NonSerializedAttribute.cs
- Convert.cs
- SRGSCompiler.cs
- ADMembershipUser.cs
- MediaPlayerState.cs
- SrgsOneOf.cs
- HwndAppCommandInputProvider.cs
- HtmlInputText.cs
- TextTreeRootNode.cs
- CharacterBufferReference.cs
- DescendentsWalker.cs
- TransactionProxy.cs
- GridView.cs
- XmlEncoding.cs
- DesignerAttribute.cs
- LocatorBase.cs
- ButtonBaseAdapter.cs
- MetadataFile.cs
- ScrollPatternIdentifiers.cs
- SimpleType.cs
- CheckBoxFlatAdapter.cs
- PKCS1MaskGenerationMethod.cs
- AuthorizationSection.cs
- HtmlTernaryTree.cs
- SafeSecurityHandles.cs
- CatalogZoneBase.cs
- IdnElement.cs
- DataGridViewCellLinkedList.cs
- MachineKeyValidationConverter.cs
- WmlCalendarAdapter.cs
- EntityModelBuildProvider.cs
- PropertyItemInternal.cs