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
- ToolStripItemRenderEventArgs.cs
- AnimationClock.cs
- BufferModesCollection.cs
- TransactionManager.cs
- PhonemeConverter.cs
- PathGradientBrush.cs
- EditorPart.cs
- HtmlTableCell.cs
- InvokePatternIdentifiers.cs
- DateTimeOffset.cs
- DateTimeConstantAttribute.cs
- TitleStyle.cs
- InlineObject.cs
- Options.cs
- XsltException.cs
- MergeFailedEvent.cs
- AbstractExpressions.cs
- NumericExpr.cs
- EndpointDiscoveryMetadata11.cs
- MyContact.cs
- ConnectionProviderAttribute.cs
- InputScope.cs
- SubqueryRules.cs
- ConstraintConverter.cs
- XmlDictionaryWriter.cs
- DbParameterCollectionHelper.cs
- BuildManagerHost.cs
- LinearKeyFrames.cs
- OdbcPermission.cs
- DesignerMetadata.cs
- SystemKeyConverter.cs
- DynamicResourceExtension.cs
- XmlSchema.cs
- LinkConverter.cs
- SqlDataSourceCommandParser.cs
- DocumentOutline.cs
- RegexRunner.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- Regex.cs
- CodeArgumentReferenceExpression.cs
- SqlOuterApplyReducer.cs
- ParameterBuilder.cs
- WindowsGraphics2.cs
- ErrorInfoXmlDocument.cs
- Point4D.cs
- FlowDocumentScrollViewer.cs
- NativeMethods.cs
- DrawingContextDrawingContextWalker.cs
- XmlWhitespace.cs
- ParserOptions.cs
- Boolean.cs
- ScrollableControl.cs
- EventsTab.cs
- ThicknessConverter.cs
- ExecutedRoutedEventArgs.cs
- StylusPointPropertyInfo.cs
- ErrorHandler.cs
- FormsAuthenticationModule.cs
- TrackingWorkflowEventArgs.cs
- PropertyItem.cs
- MobileFormsAuthentication.cs
- BasicExpandProvider.cs
- HTTPRemotingHandler.cs
- ZipFileInfo.cs
- ConfigurationPropertyAttribute.cs
- XmlMapping.cs
- UpdateProgress.cs
- SEHException.cs
- Set.cs
- OleDbError.cs
- ScaleTransform.cs
- XmlStringTable.cs
- SynchronizedMessageSource.cs
- HttpSessionStateBase.cs
- XmlObjectSerializerWriteContextComplexJson.cs
- NominalTypeEliminator.cs
- XmlTypeAttribute.cs
- BooleanStorage.cs
- ServiceHostFactory.cs
- ReachSerializableProperties.cs
- ExpressionPrinter.cs
- EventHandlerService.cs
- figurelength.cs
- SQLGuidStorage.cs
- ExpressionBuilderCollection.cs
- SmiGettersStream.cs
- FeatureSupport.cs
- ListViewDataItem.cs
- FontStyleConverter.cs
- Attributes.cs
- ControlCachePolicy.cs
- _NetRes.cs
- ListViewUpdateEventArgs.cs
- GeometryDrawing.cs
- _LoggingObject.cs
- CroppedBitmap.cs
- HtmlSelect.cs
- DataGridDetailsPresenter.cs
- FieldMetadata.cs
- CAGDesigner.cs