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
- HtmlButton.cs
- Helper.cs
- EditorAttributeInfo.cs
- EventWaitHandleSecurity.cs
- DataContractJsonSerializer.cs
- ProxyElement.cs
- Schema.cs
- TransformValueSerializer.cs
- PrintDialogDesigner.cs
- ConnectionManagementElementCollection.cs
- ClickablePoint.cs
- DataGridSortCommandEventArgs.cs
- WhitespaceRuleLookup.cs
- SetStateDesigner.cs
- ProtocolsConfigurationHandler.cs
- DataTableExtensions.cs
- TemplateBindingExtensionConverter.cs
- UriTemplateDispatchFormatter.cs
- DataGridGeneralPage.cs
- AnnotationDocumentPaginator.cs
- Figure.cs
- MailAddress.cs
- BuildTopDownAttribute.cs
- _ServiceNameStore.cs
- TagPrefixAttribute.cs
- WebContext.cs
- SmtpFailedRecipientsException.cs
- SocketInformation.cs
- FormClosedEvent.cs
- DataControlLinkButton.cs
- PropertyEntry.cs
- Font.cs
- IisTraceListener.cs
- PropertyEntry.cs
- Cloud.cs
- DispatcherOperation.cs
- invalidudtexception.cs
- XMLSchema.cs
- TableDetailsCollection.cs
- LogFlushAsyncResult.cs
- XmlSchemaSimpleType.cs
- EntityDataSourceContextDisposingEventArgs.cs
- SectionInput.cs
- RenderOptions.cs
- SQLStringStorage.cs
- OdbcEnvironmentHandle.cs
- EntityRecordInfo.cs
- BooleanExpr.cs
- SocketAddress.cs
- DataServiceQuery.cs
- AxisAngleRotation3D.cs
- HtmlHead.cs
- RelationshipConverter.cs
- ObjectItemCollection.cs
- HttpChannelBindingToken.cs
- StructuralType.cs
- SystemWebCachingSectionGroup.cs
- SqlExpander.cs
- CodeTypeMember.cs
- ButtonBaseAutomationPeer.cs
- EntityContainerRelationshipSet.cs
- ScriptServiceAttribute.cs
- LinkDescriptor.cs
- RbTree.cs
- ReflectionUtil.cs
- PageCodeDomTreeGenerator.cs
- SchemaElementLookUpTable.cs
- PerformanceCounterPermissionEntryCollection.cs
- Part.cs
- Double.cs
- RepeatBehaviorConverter.cs
- DataGridColumnStyleMappingNameEditor.cs
- RadioButtonFlatAdapter.cs
- RtfFormatStack.cs
- SemanticValue.cs
- SchemaElementDecl.cs
- DateTimeOffsetAdapter.cs
- CheckPair.cs
- PageCatalogPart.cs
- EditorOptionAttribute.cs
- FigureParaClient.cs
- ChineseLunisolarCalendar.cs
- TemplateInstanceAttribute.cs
- SQLRoleProvider.cs
- Point3DAnimationUsingKeyFrames.cs
- PropertyDescriptor.cs
- HttpCookiesSection.cs
- CallbackHandler.cs
- CustomValidator.cs
- CustomErrorsSection.cs
- EntityClassGenerator.cs
- Axis.cs
- XmlnsCache.cs
- MappingException.cs
- CodeDomSerializationProvider.cs
- DiscoveryClientDuplexChannel.cs
- DesignerCatalogPartChrome.cs
- MenuEventArgs.cs
- EntityClientCacheEntry.cs
- TreeViewDesigner.cs