Code:
/ 4.0 / 4.0 / 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. 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
- StructuredType.cs
- ObjectQueryState.cs
- TrustManager.cs
- IFlowDocumentViewer.cs
- SubstitutionList.cs
- HMACMD5.cs
- Speller.cs
- Tuple.cs
- ControlValuePropertyAttribute.cs
- Thumb.cs
- Section.cs
- SHA256Managed.cs
- StyleSheetComponentEditor.cs
- SmiMetaData.cs
- ElementNotEnabledException.cs
- RichTextBox.cs
- RequiredFieldValidator.cs
- SecurityUtils.cs
- CompiledIdentityConstraint.cs
- X509Chain.cs
- MarginsConverter.cs
- ScriptResourceAttribute.cs
- ToolStripSettings.cs
- Triplet.cs
- _ChunkParse.cs
- FixedPageProcessor.cs
- SiteMapDataSourceView.cs
- NameObjectCollectionBase.cs
- Quaternion.cs
- SpellCheck.cs
- ContentType.cs
- SqlDataReader.cs
- SiteMapDataSourceView.cs
- ConnectAlgorithms.cs
- HttpApplication.cs
- GeometryModel3D.cs
- WmpBitmapDecoder.cs
- DataGridViewComboBoxColumn.cs
- DataServiceExpressionVisitor.cs
- BinHexDecoder.cs
- MouseOverProperty.cs
- VariableElement.cs
- SharedUtils.cs
- ParserContext.cs
- EntityDataReader.cs
- DeploymentSectionCache.cs
- InputBinding.cs
- ManagementOperationWatcher.cs
- SmtpNetworkElement.cs
- XXXInfos.cs
- SelectorItemAutomationPeer.cs
- ExpressionServices.cs
- TextUtf8RawTextWriter.cs
- Context.cs
- ManagementEventWatcher.cs
- namescope.cs
- BoolExpressionVisitors.cs
- CallContext.cs
- VersionPair.cs
- HiddenField.cs
- Encoder.cs
- GroupDescription.cs
- ActivitySurrogate.cs
- RemoteWebConfigurationHost.cs
- PointF.cs
- SqlDataReader.cs
- MetafileHeader.cs
- RelationshipManager.cs
- ProgressBarRenderer.cs
- ProxyGenerator.cs
- LongValidatorAttribute.cs
- TemplateBamlRecordReader.cs
- PageParserFilter.cs
- columnmapfactory.cs
- JsonDeserializer.cs
- BooleanFunctions.cs
- Size.cs
- Geometry3D.cs
- Cursors.cs
- AddingNewEventArgs.cs
- XsdValidatingReader.cs
- SqlProviderServices.cs
- ProfilePropertySettingsCollection.cs
- HtmlInputSubmit.cs
- ThreadStaticAttribute.cs
- DictionaryItemsCollection.cs
- TableItemStyle.cs
- Attribute.cs
- ColumnMapVisitor.cs
- util.cs
- infer.cs
- ClientSession.cs
- NumberEdit.cs
- InputLanguage.cs
- DataServiceRequest.cs
- PropertyBuilder.cs
- XmlSchemaExporter.cs
- EntityTypeEmitter.cs
- Column.cs
- XmlSchemaAnnotation.cs