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
- HMACMD5.cs
- _ConnectOverlappedAsyncResult.cs
- Codec.cs
- CompositionDesigner.cs
- NotifyIcon.cs
- CodeVariableDeclarationStatement.cs
- DataServiceClientException.cs
- CodeObject.cs
- DropDownButton.cs
- WorkflowTimerService.cs
- Point.cs
- DoubleAnimationClockResource.cs
- SignedXml.cs
- ReadOnlyCollectionBase.cs
- InvalidOperationException.cs
- ObjectListCommand.cs
- SQLByte.cs
- SQLGuidStorage.cs
- List.cs
- RedirectionProxy.cs
- GeneralTransformCollection.cs
- SystemWebSectionGroup.cs
- RightsManagementUser.cs
- CursorConverter.cs
- DescendantBaseQuery.cs
- DataService.cs
- UserInitiatedNavigationPermission.cs
- EventPropertyMap.cs
- MenuCommands.cs
- BeginEvent.cs
- TextSpan.cs
- PropertyIDSet.cs
- ListMarkerLine.cs
- MetabaseReader.cs
- SubstitutionDesigner.cs
- ClientApiGenerator.cs
- CodeObject.cs
- Resources.Designer.cs
- ObjectDataSourceChooseTypePanel.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- GlobalItem.cs
- PrinterUnitConvert.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- OutOfProcStateClientManager.cs
- Point3DAnimationBase.cs
- GridProviderWrapper.cs
- basemetadatamappingvisitor.cs
- BindingContext.cs
- ResXResourceWriter.cs
- CodeGenerationManager.cs
- RelatedCurrencyManager.cs
- HMACSHA1.cs
- PipeStream.cs
- DbReferenceCollection.cs
- TypeGenericEnumerableViewSchema.cs
- BezierSegment.cs
- FixedPageStructure.cs
- PreparingEnlistment.cs
- Preprocessor.cs
- DynamicPropertyHolder.cs
- Query.cs
- DictionarySectionHandler.cs
- UnicastIPAddressInformationCollection.cs
- regiisutil.cs
- WebControlParameterProxy.cs
- FlowDocumentFormatter.cs
- InvokeMethodActivityDesigner.cs
- Console.cs
- View.cs
- WebPart.cs
- ZipIOModeEnforcingStream.cs
- XmlSchemaObjectCollection.cs
- SchemeSettingElementCollection.cs
- AutomationIdentifier.cs
- DetailsViewActionList.cs
- DataContract.cs
- ComponentEditorPage.cs
- Comparer.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- CacheDependency.cs
- SingleAnimationBase.cs
- RecordBuilder.cs
- AtomPub10CategoriesDocumentFormatter.cs
- ConfigXmlText.cs
- DataException.cs
- Clause.cs
- GenericTextProperties.cs
- DataGridViewCellParsingEventArgs.cs
- ComplexTypeEmitter.cs
- _SslStream.cs
- PagePropertiesChangingEventArgs.cs
- LabelEditEvent.cs
- GradientStopCollection.cs
- NonBatchDirectoryCompiler.cs
- ClassicBorderDecorator.cs
- SkewTransform.cs
- Group.cs
- UnsafeMethods.cs
- CalendarDesigner.cs