Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Security / Cryptography / RSAOAEPKeyExchangeFormatter.cs / 1305376 / RSAOAEPKeyExchangeFormatter.cs
using System.Diagnostics.Contracts; // ==++== // // 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"); Contract.EndContractBlock(); _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"); Contract.EndContractBlock(); _rsaKey = (RSA) key; } [System.Security.SecuritySafeCritical] // auto-generated 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- GeneralTransform3D.cs
- WithParamAction.cs
- ComplexType.cs
- DtcInterfaces.cs
- Pair.cs
- PrintControllerWithStatusDialog.cs
- StateRuntime.cs
- ValidatorCompatibilityHelper.cs
- Privilege.cs
- RawTextInputReport.cs
- ListViewCancelEventArgs.cs
- DataGridRow.cs
- PropertyCondition.cs
- IImplicitResourceProvider.cs
- FontNamesConverter.cs
- DataKeyCollection.cs
- PeerResolver.cs
- FontDialog.cs
- TraceXPathNavigator.cs
- NetworkCredential.cs
- LiteralLink.cs
- DataGridColumn.cs
- CommandValueSerializer.cs
- SourceExpressionException.cs
- DataGridViewCellStyle.cs
- SerialPort.cs
- WebPartMinimizeVerb.cs
- TaskFileService.cs
- WebPartsPersonalization.cs
- iisPickupDirectory.cs
- StrokeCollectionDefaultValueFactory.cs
- WebPartConnectionsConnectVerb.cs
- Console.cs
- XmlReaderSettings.cs
- EmptyEnumerable.cs
- StorageModelBuildProvider.cs
- Journaling.cs
- MouseCaptureWithinProperty.cs
- Vector3DAnimationBase.cs
- WeakEventTable.cs
- IResourceProvider.cs
- DataGridViewBand.cs
- DataGridViewCheckBoxCell.cs
- UrlPath.cs
- DefaultTraceListener.cs
- HTMLTextWriter.cs
- TextRangeEditLists.cs
- DefaultWorkflowLoaderService.cs
- EnumBuilder.cs
- CursorInteropHelper.cs
- TranslateTransform3D.cs
- Part.cs
- UpdateRecord.cs
- FileIOPermission.cs
- DescendantOverDescendantQuery.cs
- AutomationTextAttribute.cs
- GroupBox.cs
- SqlMethodTransformer.cs
- FontFaceLayoutInfo.cs
- CreateUserWizard.cs
- SafeSecurityHandles.cs
- Win32KeyboardDevice.cs
- _NativeSSPI.cs
- EditorPartChrome.cs
- EmptyReadOnlyDictionaryInternal.cs
- ExcCanonicalXml.cs
- XmlCodeExporter.cs
- DateTimeStorage.cs
- HebrewNumber.cs
- WebPartVerb.cs
- MTConfigUtil.cs
- ListViewAutomationPeer.cs
- SQLString.cs
- SqlInternalConnectionTds.cs
- MetadataItemCollectionFactory.cs
- TextRunCacheImp.cs
- FastPropertyAccessor.cs
- CalendarSelectionChangedEventArgs.cs
- NullableConverter.cs
- QuerySettings.cs
- JsonStringDataContract.cs
- OverlappedAsyncResult.cs
- CfgRule.cs
- LambdaReference.cs
- SecurityCriticalDataForSet.cs
- DrawingImage.cs
- FunctionDescription.cs
- WorkflowInstanceProvider.cs
- OleStrCAMarshaler.cs
- TextRangeEdit.cs
- ErrorStyle.cs
- WpfWebRequestHelper.cs
- RequestContextBase.cs
- EntityStoreSchemaFilterEntry.cs
- WebBrowserProgressChangedEventHandler.cs
- validationstate.cs
- FormsAuthenticationUserCollection.cs
- ToolStripSystemRenderer.cs
- MetaTableHelper.cs
- ExpressionWriter.cs