Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- XPathNode.cs
- AttachedAnnotationChangedEventArgs.cs
- SignalGate.cs
- Lasso.cs
- RijndaelManagedTransform.cs
- ZipFileInfo.cs
- BitmapScalingModeValidation.cs
- EntityDataSourceQueryBuilder.cs
- RelationshipEnd.cs
- LongMinMaxAggregationOperator.cs
- ProtocolsConfigurationEntry.cs
- XmlCustomFormatter.cs
- DummyDataSource.cs
- DataListCommandEventArgs.cs
- Decimal.cs
- ISCIIEncoding.cs
- ServiceProviders.cs
- DependencyPropertyKey.cs
- ConvertEvent.cs
- SocketPermission.cs
- EditorBrowsableAttribute.cs
- AlignmentXValidation.cs
- BamlResourceSerializer.cs
- EventManager.cs
- StringFunctions.cs
- ScriptReferenceEventArgs.cs
- XmlElementAttributes.cs
- DelayedRegex.cs
- Point4DConverter.cs
- SignatureDescription.cs
- CachedPathData.cs
- ProgressBar.cs
- CultureTable.cs
- StringInfo.cs
- XmlDomTextWriter.cs
- PointCollectionValueSerializer.cs
- TypedTableBase.cs
- OdbcCommandBuilder.cs
- InternalConfigConfigurationFactory.cs
- PersistenceTypeAttribute.cs
- DateTimeEditor.cs
- UnsafeNativeMethods.cs
- BufferedReadStream.cs
- WaitHandleCannotBeOpenedException.cs
- String.cs
- PaperSource.cs
- UniformGrid.cs
- SelectingProviderEventArgs.cs
- WebPartConnectionsCancelEventArgs.cs
- LayoutSettings.cs
- InvokePattern.cs
- LogicalExpr.cs
- BrowsableAttribute.cs
- _TimerThread.cs
- ToolStripRendererSwitcher.cs
- ToolBarButtonDesigner.cs
- RemotingSurrogateSelector.cs
- DynamicEntity.cs
- DoubleLinkListEnumerator.cs
- OwnerDrawPropertyBag.cs
- GridViewDeletedEventArgs.cs
- MenuItem.cs
- X509ThumbprintKeyIdentifierClause.cs
- RawStylusInputCustomData.cs
- Missing.cs
- ExtensionFile.cs
- LateBoundChannelParameterCollection.cs
- RelationshipDetailsRow.cs
- ScrollChangedEventArgs.cs
- AsyncOperationContext.cs
- ChangePasswordAutoFormat.cs
- MessageQueuePermissionEntry.cs
- Select.cs
- XNodeNavigator.cs
- MsmqInputMessagePool.cs
- RegexGroup.cs
- WebPartCancelEventArgs.cs
- MethodToken.cs
- InputScopeConverter.cs
- ADMembershipProvider.cs
- ReadOnlyDataSourceView.cs
- COM2TypeInfoProcessor.cs
- TextAdaptor.cs
- Point4D.cs
- LineServicesCallbacks.cs
- X509Certificate2.cs
- PrimitiveOperationFormatter.cs
- AxImporter.cs
- NullableBoolConverter.cs
- DbParameterHelper.cs
- DataGridGeneralPage.cs
- UnsafeNativeMethods.cs
- FormatterServices.cs
- CodeAttributeDeclarationCollection.cs
- Visual3DCollection.cs
- SamlSerializer.cs
- PublishLicense.cs
- ObjRef.cs
- TargetException.cs
- SqlUnionizer.cs