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
- ConstantProjectedSlot.cs
- PackagePart.cs
- ContainerTracking.cs
- DrawingState.cs
- CompilerError.cs
- SystemDropShadowChrome.cs
- WorkflowPrinting.cs
- PropertyMap.cs
- PreservationFileWriter.cs
- RegexCaptureCollection.cs
- StructuralCache.cs
- CroppedBitmap.cs
- JsonDataContract.cs
- IntranetCredentialPolicy.cs
- VersionUtil.cs
- CustomAttributeFormatException.cs
- HtmlElementCollection.cs
- Function.cs
- SizeConverter.cs
- CryptoApi.cs
- ModifierKeysValueSerializer.cs
- ImageFormat.cs
- HttpConfigurationContext.cs
- SqlProcedureAttribute.cs
- UserControlCodeDomTreeGenerator.cs
- TextServicesHost.cs
- VoiceChangeEventArgs.cs
- DbProviderManifest.cs
- DecimalAnimationUsingKeyFrames.cs
- DataServiceStreamResponse.cs
- RequestCachePolicyConverter.cs
- ButtonField.cs
- PersianCalendar.cs
- ResourceReader.cs
- TextRangeEdit.cs
- EventHandlersStore.cs
- DataIdProcessor.cs
- VerificationAttribute.cs
- SmtpFailedRecipientsException.cs
- WindowsUpDown.cs
- UnsafeNativeMethodsMilCoreApi.cs
- CapabilitiesState.cs
- ProfileGroupSettingsCollection.cs
- CompiledRegexRunner.cs
- _ChunkParse.cs
- DataGridViewTopLeftHeaderCell.cs
- LinkedResourceCollection.cs
- FontUnitConverter.cs
- NetTcpSecurityElement.cs
- SafeCertificateContext.cs
- Int64AnimationUsingKeyFrames.cs
- BinaryObjectReader.cs
- LabelAutomationPeer.cs
- ReadOnlyCollection.cs
- StructuralType.cs
- IdentityNotMappedException.cs
- MenuItemStyle.cs
- XmlComment.cs
- PersonalizationProviderHelper.cs
- Random.cs
- SiteMapSection.cs
- DataPagerFieldCollection.cs
- SecurityTokenReferenceStyle.cs
- HttpCacheParams.cs
- UriParserTemplates.cs
- DesignTimeParseData.cs
- SplitterCancelEvent.cs
- GlyphingCache.cs
- ArraySegment.cs
- SimpleWebHandlerParser.cs
- GridItemPattern.cs
- ValueType.cs
- CookieParameter.cs
- TableColumnCollectionInternal.cs
- PeerNameRecordCollection.cs
- VisualProxy.cs
- DesignerActionVerbList.cs
- UIPermission.cs
- DoubleAnimationUsingKeyFrames.cs
- XPathPatternBuilder.cs
- SocketElement.cs
- ArrayWithOffset.cs
- CodeCompileUnit.cs
- safesecurityhelperavalon.cs
- Registry.cs
- UnicastIPAddressInformationCollection.cs
- SafeLibraryHandle.cs
- NullNotAllowedCollection.cs
- ProviderCommandInfoUtils.cs
- ImportContext.cs
- GroupBoxDesigner.cs
- XmlWriterTraceListener.cs
- ColorPalette.cs
- DataViewSetting.cs
- UserControlAutomationPeer.cs
- URLIdentityPermission.cs
- OdbcException.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- TextSelectionProcessor.cs
- RemotingClientProxy.cs