Files
Dec2017-Script-Dump/mscorlib/System/Security/Cryptography/RSACryptoServiceProvider.cs
T
2026-06-04 11:42:34 +02:00

593 lines
27 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using Mono.Security.Cryptography;
namespace System.Security.Cryptography
{
/// <summary>Performs asymmetric encryption and decryption using the implementation of the <see cref="T:System.Security.Cryptography.RSA" /> algorithm provided by the cryptographic service provider (CSP). This class cannot be inherited.</summary>
// Token: 0x0200051C RID: 1308
[ComVisible(true)]
public sealed class RSACryptoServiceProvider : RSA, ICspAsymmetricAlgorithm
{
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Cryptography.RSACryptoServiceProvider" /> class using the default key.</summary>
/// <exception cref="T:System.Security.Cryptography.CryptographicException">The cryptographic service provider (CSP) cannot be acquired. </exception>
// Token: 0x0600300E RID: 12302 RVA: 0x0009D5D4 File Offset: 0x0009B7D4
public RSACryptoServiceProvider()
{
this.Common(1024, null);
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Cryptography.RSACryptoServiceProvider" /> class with the specified parameters.</summary>
/// <param name="parameters">The parameters to be passed to the cryptographic service provider (CSP). </param>
/// <exception cref="T:System.Security.Cryptography.CryptographicException">The CSP cannot be acquired. </exception>
// Token: 0x0600300F RID: 12303 RVA: 0x0009D5F0 File Offset: 0x0009B7F0
public RSACryptoServiceProvider(CspParameters parameters)
{
this.Common(1024, parameters);
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Cryptography.RSACryptoServiceProvider" /> class with the specified key size.</summary>
/// <param name="dwKeySize">The size of the key to use in bits. </param>
/// <exception cref="T:System.Security.Cryptography.CryptographicException">The cryptographic service provider (CSP) cannot be acquired. </exception>
// Token: 0x06003010 RID: 12304 RVA: 0x0009D60C File Offset: 0x0009B80C
public RSACryptoServiceProvider(int dwKeySize)
{
this.Common(dwKeySize, null);
}
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Cryptography.RSACryptoServiceProvider" /> class with the specified key size and parameters.</summary>
/// <param name="dwKeySize">The size of the key to use in bits. </param>
/// <param name="parameters">The parameters to be passed to the cryptographic service provider (CSP). </param>
/// <exception cref="T:System.Security.Cryptography.CryptographicException">The CSP cannot be acquired.-or- The key cannot be created. </exception>
// Token: 0x06003011 RID: 12305 RVA: 0x0009D624 File Offset: 0x0009B824
public RSACryptoServiceProvider(int dwKeySize, CspParameters parameters)
{
this.Common(dwKeySize, parameters);
}
// Token: 0x06003013 RID: 12307 RVA: 0x0009D640 File Offset: 0x0009B840
private void Common(int dwKeySize, CspParameters p)
{
this.LegalKeySizesValue = new KeySizes[1];
this.LegalKeySizesValue[0] = new KeySizes(384, 16384, 8);
base.KeySize = dwKeySize;
this.rsa = new RSAManaged(this.KeySize);
this.rsa.KeyGenerated += this.OnKeyGenerated;
this.persistKey = p != null;
if (p == null)
{
p = new CspParameters(1);
if (RSACryptoServiceProvider.useMachineKeyStore)
{
p.Flags |= CspProviderFlags.UseMachineKeyStore;
}
this.store = new KeyPairPersistence(p);
}
else
{
this.store = new KeyPairPersistence(p);
this.store.Load();
if (this.store.KeyValue != null)
{
this.persisted = true;
this.FromXmlString(this.store.KeyValue);
}
}
}
/// <summary>Gets or sets a value indicating whether the key should be persisted in the computer's key store instead of the user profile store.</summary>
/// <returns>true if the key should be persisted in the computer key store; otherwise, false.</returns>
// Token: 0x17000975 RID: 2421
// (get) Token: 0x06003014 RID: 12308 RVA: 0x0009D724 File Offset: 0x0009B924
// (set) Token: 0x06003015 RID: 12309 RVA: 0x0009D72C File Offset: 0x0009B92C
public static bool UseMachineKeyStore
{
get
{
return RSACryptoServiceProvider.useMachineKeyStore;
}
set
{
RSACryptoServiceProvider.useMachineKeyStore = value;
}
}
// Token: 0x06003016 RID: 12310 RVA: 0x0009D734 File Offset: 0x0009B934
~RSACryptoServiceProvider()
{
this.Dispose(false);
}
/// <summary>Gets the name of the key exchange algorithm available with this implementation of <see cref="T:System.Security.Cryptography.RSA" />.</summary>
/// <returns>The name of the key exchange algorithm if it exists; otherwise, null.</returns>
// Token: 0x17000976 RID: 2422
// (get) Token: 0x06003017 RID: 12311 RVA: 0x0009D770 File Offset: 0x0009B970
public override string KeyExchangeAlgorithm
{
get
{
return "RSA-PKCS1-KeyEx";
}
}
/// <summary>Gets the size of the current key.</summary>
/// <returns>The size of the key in bits.</returns>
// Token: 0x17000977 RID: 2423
// (get) Token: 0x06003018 RID: 12312 RVA: 0x0009D778 File Offset: 0x0009B978
public override int KeySize
{
get
{
if (this.rsa == null)
{
return this.KeySizeValue;
}
return this.rsa.KeySize;
}
}
/// <summary>Gets or sets a value indicating whether the key should be persisted in the cryptographic service provider (CSP).</summary>
/// <returns>true if the key should be persisted in the CSP; otherwise, false.</returns>
// Token: 0x17000978 RID: 2424
// (get) Token: 0x06003019 RID: 12313 RVA: 0x0009D798 File Offset: 0x0009B998
// (set) Token: 0x0600301A RID: 12314 RVA: 0x0009D7A0 File Offset: 0x0009B9A0
public bool PersistKeyInCsp
{
get
{
return this.persistKey;
}
set
{
this.persistKey = value;
if (this.persistKey)
{
this.OnKeyGenerated(this.rsa, null);
}
}
}
/// <summary>Gets a value that indicates whether the <see cref="T:System.Security.Cryptography.RSACryptoServiceProvider" /> object contains only a public key.</summary>
/// <returns>true if the <see cref="T:System.Security.Cryptography.RSACryptoServiceProvider" /> object contains only a public key; otherwise, false.</returns>
// Token: 0x17000979 RID: 2425
// (get) Token: 0x0600301B RID: 12315 RVA: 0x0009D7C4 File Offset: 0x0009B9C4
[ComVisible(false)]
public bool PublicOnly
{
get
{
return this.rsa.PublicOnly;
}
}
/// <summary>Gets the name of the signature algorithm available with this implementation of <see cref="T:System.Security.Cryptography.RSA" />.</summary>
/// <returns>The name of the signature algorithm.</returns>
// Token: 0x1700097A RID: 2426
// (get) Token: 0x0600301C RID: 12316 RVA: 0x0009D7D4 File Offset: 0x0009B9D4
public override string SignatureAlgorithm
{
get
{
return "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
}
}
/// <summary>Decrypts data with the <see cref="T:System.Security.Cryptography.RSA" /> algorithm.</summary>
/// <returns>The decrypted data, which is the original plain text before encryption.</returns>
/// <param name="rgb">The data to be decrypted. </param>
/// <param name="fOAEP">true to perform direct <see cref="T:System.Security.Cryptography.RSA" /> decryption using OAEP padding (only available on a computer running Microsoft Windows XP or later); otherwise, false to use PKCS#1 v1.5 padding. </param>
/// <exception cref="T:System.Security.Cryptography.CryptographicException">The cryptographic service provider (CSP) cannot be acquired.-or- The <paramref name="fOAEP" /> parameter is true and the length of the <paramref name="rgb" /> parameter is greater than <see cref="P:System.Security.Cryptography.RSACryptoServiceProvider.KeySize" />.-or- The <paramref name="fOAEP" /> parameter is true and OAEP is not supported. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="rgb " />is null.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x0600301D RID: 12317 RVA: 0x0009D7DC File Offset: 0x0009B9DC
public byte[] Decrypt(byte[] rgb, bool fOAEP)
{
if (this.m_disposed)
{
throw new ObjectDisposedException("rsa");
}
AsymmetricKeyExchangeDeformatter asymmetricKeyExchangeDeformatter;
if (fOAEP)
{
asymmetricKeyExchangeDeformatter = new RSAOAEPKeyExchangeDeformatter(this.rsa);
}
else
{
asymmetricKeyExchangeDeformatter = new RSAPKCS1KeyExchangeDeformatter(this.rsa);
}
return asymmetricKeyExchangeDeformatter.DecryptKeyExchange(rgb);
}
/// <summary>This method is not supported in the current version.</summary>
/// <returns>The decrypted data, which is the original plain text before encryption.</returns>
/// <param name="rgb">The data to be decrypted. </param>
/// <exception cref="T:System.NotSupportedException">This method is not supported in the current version. </exception>
// Token: 0x0600301E RID: 12318 RVA: 0x0009D82C File Offset: 0x0009BA2C
public override byte[] DecryptValue(byte[] rgb)
{
if (!this.rsa.IsCrtPossible)
{
throw new CryptographicException("Incomplete private key - missing CRT.");
}
return this.rsa.DecryptValue(rgb);
}
/// <summary>Encrypts data with the <see cref="T:System.Security.Cryptography.RSA" /> algorithm.</summary>
/// <returns>The encrypted data.</returns>
/// <param name="rgb">The data to be encrypted. </param>
/// <param name="fOAEP">true to perform direct <see cref="T:System.Security.Cryptography.RSA" /> encryption using Optimal Asymmetric Encryption Padding (OAEP), which is only available on a computer running Microsoft Windows XP or later; false to use PKCS#1 v1.5 padding. </param>
/// <exception cref="T:System.Security.Cryptography.CryptographicException">The cryptographic service provider (CSP) cannot be acquired.-or- The length of the <paramref name="rgb" /> parameter is greater than the maximum allowed length.-or- The <paramref name="fOAEP" /> parameter is true and OAEP padding is not supported. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="rgb " />is null.</exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x0600301F RID: 12319 RVA: 0x0009D858 File Offset: 0x0009BA58
public byte[] Encrypt(byte[] rgb, bool fOAEP)
{
AsymmetricKeyExchangeFormatter asymmetricKeyExchangeFormatter;
if (fOAEP)
{
asymmetricKeyExchangeFormatter = new RSAOAEPKeyExchangeFormatter(this.rsa);
}
else
{
asymmetricKeyExchangeFormatter = new RSAPKCS1KeyExchangeFormatter(this.rsa);
}
return asymmetricKeyExchangeFormatter.CreateKeyExchange(rgb);
}
/// <summary>This method is not supported in the current version.</summary>
/// <returns>The encrypted data.</returns>
/// <param name="rgb">The data to be encrypted. </param>
/// <exception cref="T:System.NotSupportedException">This method is not supported in the current version. </exception>
// Token: 0x06003020 RID: 12320 RVA: 0x0009D894 File Offset: 0x0009BA94
public override byte[] EncryptValue(byte[] rgb)
{
return this.rsa.EncryptValue(rgb);
}
/// <summary>Exports the <see cref="T:System.Security.Cryptography.RSAParameters" />.</summary>
/// <returns>The parameters for <see cref="T:System.Security.Cryptography.RSA" />.</returns>
/// <param name="includePrivateParameters">true to include private parameters; otherwise, false. </param>
/// <exception cref="T:System.Security.Cryptography.CryptographicException">The key cannot be exported. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06003021 RID: 12321 RVA: 0x0009D8A4 File Offset: 0x0009BAA4
public override RSAParameters ExportParameters(bool includePrivateParameters)
{
if (includePrivateParameters && !this.privateKeyExportable)
{
throw new CryptographicException("cannot export private key");
}
return this.rsa.ExportParameters(includePrivateParameters);
}
/// <summary>Imports the specified <see cref="T:System.Security.Cryptography.RSAParameters" />.</summary>
/// <param name="parameters">The parameters for <see cref="T:System.Security.Cryptography.RSA" />. </param>
/// <exception cref="T:System.Security.Cryptography.CryptographicException">The cryptographic service provider (CSP) cannot be acquired.-or- The <paramref name="parameters" /> parameter has missing fields. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06003022 RID: 12322 RVA: 0x0009D8DC File Offset: 0x0009BADC
public override void ImportParameters(RSAParameters parameters)
{
this.rsa.ImportParameters(parameters);
}
// Token: 0x06003023 RID: 12323 RVA: 0x0009D8EC File Offset: 0x0009BAEC
private HashAlgorithm GetHash(object halg)
{
if (halg == null)
{
throw new ArgumentNullException("halg");
}
HashAlgorithm hashAlgorithm;
if (halg is string)
{
hashAlgorithm = HashAlgorithm.Create((string)halg);
}
else if (halg is HashAlgorithm)
{
hashAlgorithm = (HashAlgorithm)halg;
}
else
{
if (!(halg is Type))
{
throw new ArgumentException("halg");
}
hashAlgorithm = (HashAlgorithm)Activator.CreateInstance((Type)halg);
}
return hashAlgorithm;
}
/// <summary>Computes the hash value of the specified byte array using the specified hash algorithm, and signs the resulting hash value.</summary>
/// <returns>The <see cref="T:System.Security.Cryptography.RSA" /> signature for the specified data.</returns>
/// <param name="buffer">The input data for which to compute the hash. </param>
/// <param name="halg">The hash algorithm to use to create the hash value. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="halg" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="halg" /> parameter is not a valid type. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06003024 RID: 12324 RVA: 0x0009D96C File Offset: 0x0009BB6C
public byte[] SignData(byte[] buffer, object halg)
{
if (buffer == null)
{
throw new ArgumentNullException("buffer");
}
return this.SignData(buffer, 0, buffer.Length, halg);
}
/// <summary>Computes the hash value of the specified input stream using the specified hash algorithm, and signs the resulting hash value.</summary>
/// <returns>The <see cref="T:System.Security.Cryptography.RSA" /> signature for the specified data.</returns>
/// <param name="inputStream">The input data for which to compute the hash. </param>
/// <param name="halg">The hash algorithm to use to create the hash value. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="halg" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="halg" /> parameter is not a valid type. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06003025 RID: 12325 RVA: 0x0009D98C File Offset: 0x0009BB8C
public byte[] SignData(Stream inputStream, object halg)
{
HashAlgorithm hash = this.GetHash(halg);
byte[] array = hash.ComputeHash(inputStream);
return PKCS1.Sign_v15(this, hash, array);
}
/// <summary>Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.</summary>
/// <returns>The <see cref="T:System.Security.Cryptography.RSA" /> signature for the specified data.</returns>
/// <param name="buffer">The input data for which to compute the hash. </param>
/// <param name="offset">The offset into the array from which to begin using data. </param>
/// <param name="count">The number of bytes in the array to use as data. </param>
/// <param name="halg">The hash algorithm to use to create the hash value. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="halg" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="halg" /> parameter is not a valid type. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06003026 RID: 12326 RVA: 0x0009D9B4 File Offset: 0x0009BBB4
public byte[] SignData(byte[] buffer, int offset, int count, object halg)
{
HashAlgorithm hash = this.GetHash(halg);
byte[] array = hash.ComputeHash(buffer, offset, count);
return PKCS1.Sign_v15(this, hash, array);
}
// Token: 0x06003027 RID: 12327 RVA: 0x0009D9DC File Offset: 0x0009BBDC
private string GetHashNameFromOID(string oid)
{
if (oid != null)
{
if (RSACryptoServiceProvider.<>f__switch$map29 == null)
{
RSACryptoServiceProvider.<>f__switch$map29 = new Dictionary<string, int>(2)
{
{ "1.3.14.3.2.26", 0 },
{ "1.2.840.113549.2.5", 1 }
};
}
int num;
if (RSACryptoServiceProvider.<>f__switch$map29.TryGetValue(oid, out num))
{
if (num == 0)
{
return "SHA1";
}
if (num == 1)
{
return "MD5";
}
}
}
throw new NotSupportedException(oid + " is an unsupported hash algorithm for RSA signing");
}
/// <summary>Computes the signature for the specified hash value by encrypting it with the private key.</summary>
/// <returns>The <see cref="T:System.Security.Cryptography.RSA" /> signature for the specified hash value.</returns>
/// <param name="rgbHash">The hash value of the data to be signed. </param>
/// <param name="str">The hash algorithm identifier (OID) used to create the hash value of the data. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="rgbHash" /> parameter is null. </exception>
/// <exception cref="T:System.Security.Cryptography.CryptographicException">The cryptographic service provider (CSP) cannot be acquired.-or- There is no private key. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06003028 RID: 12328 RVA: 0x0009DA60 File Offset: 0x0009BC60
public byte[] SignHash(byte[] rgbHash, string str)
{
if (rgbHash == null)
{
throw new ArgumentNullException("rgbHash");
}
string text = ((str != null) ? this.GetHashNameFromOID(str) : "SHA1");
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(text);
return PKCS1.Sign_v15(this, hashAlgorithm, rgbHash);
}
/// <summary>Verifies that a digital signature is valid by determining the hash value in the signature using the provided public key and comparing it to the hash value of the provided data.</summary>
/// <returns>true if the signature is valid; otherwise, false.</returns>
/// <param name="buffer">The data that was signed. </param>
/// <param name="halg">The name of the hash algorithm used to create the hash value of the data. </param>
/// <param name="signature">The signature data to use for verification. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="halg" /> parameter is null. </exception>
/// <exception cref="T:System.ArgumentException">The <paramref name="halg" /> parameter is not a valid type. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06003029 RID: 12329 RVA: 0x0009DAA8 File Offset: 0x0009BCA8
public bool VerifyData(byte[] buffer, object halg, byte[] signature)
{
if (buffer == null)
{
throw new ArgumentNullException("buffer");
}
if (signature == null)
{
throw new ArgumentNullException("signature");
}
HashAlgorithm hash = this.GetHash(halg);
byte[] array = hash.ComputeHash(buffer);
return PKCS1.Verify_v15(this, hash, array, signature);
}
/// <summary>Verifies that a digital signature is valid by determining the hash value in the signature using the provided public key and comparing it to the provided hash value.</summary>
/// <returns>true if the signature is valid; otherwise, false.</returns>
/// <param name="rgbHash">The hash value of the signed data. </param>
/// <param name="str">The hash algorithm identifier (OID) used to create the hash value of the data. </param>
/// <param name="rgbSignature">The signature data to use for verification. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="rgbHash" /> parameter is null.-or- The <paramref name="rgbSignature" /> parameter is null. </exception>
/// <exception cref="T:System.Security.Cryptography.CryptographicException">The cryptographic service provider (CSP) cannot be acquired.-or- The signature cannot be verified. </exception>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x0600302A RID: 12330 RVA: 0x0009DAF0 File Offset: 0x0009BCF0
public bool VerifyHash(byte[] rgbHash, string str, byte[] rgbSignature)
{
if (rgbHash == null)
{
throw new ArgumentNullException("rgbHash");
}
if (rgbSignature == null)
{
throw new ArgumentNullException("rgbSignature");
}
string text = ((str != null) ? this.GetHashNameFromOID(str) : "SHA1");
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(text);
return PKCS1.Verify_v15(this, hashAlgorithm, rgbHash, rgbSignature);
}
// Token: 0x0600302B RID: 12331 RVA: 0x0009DB48 File Offset: 0x0009BD48
protected override void Dispose(bool disposing)
{
if (!this.m_disposed)
{
if (this.persisted && !this.persistKey)
{
this.store.Remove();
}
if (this.rsa != null)
{
this.rsa.Clear();
}
this.m_disposed = true;
}
}
// Token: 0x0600302C RID: 12332 RVA: 0x0009DBA0 File Offset: 0x0009BDA0
private void OnKeyGenerated(object sender, EventArgs e)
{
if (this.persistKey && !this.persisted)
{
this.store.KeyValue = this.ToXmlString(!this.rsa.PublicOnly);
this.store.Save();
this.persisted = true;
}
}
/// <summary>Gets a <see cref="T:System.Security.Cryptography.CspKeyContainerInfo" /> object that describes additional information about a cryptographic key pair. </summary>
/// <returns>A <see cref="T:System.Security.Cryptography.CspKeyContainerInfo" /> object that describes additional information about a cryptographic key pair.</returns>
// Token: 0x1700097B RID: 2427
// (get) Token: 0x0600302D RID: 12333 RVA: 0x0009DBF4 File Offset: 0x0009BDF4
[MonoTODO("Always return null")]
[ComVisible(false)]
public CspKeyContainerInfo CspKeyContainerInfo
{
get
{
return null;
}
}
/// <summary>Exports a blob containing the key information associated with an <see cref="T:System.Security.Cryptography.RSACryptoServiceProvider" /> object. </summary>
/// <returns>A byte array containing the key information associated with an <see cref="T:System.Security.Cryptography.RSACryptoServiceProvider" /> object.</returns>
/// <param name="includePrivateParameters">true to include the private key; otherwise, false.</param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x0600302E RID: 12334 RVA: 0x0009DBF8 File Offset: 0x0009BDF8
[ComVisible(false)]
public byte[] ExportCspBlob(bool includePrivateParameters)
{
byte[] array;
if (includePrivateParameters)
{
array = CryptoConvert.ToCapiPrivateKeyBlob(this);
}
else
{
array = CryptoConvert.ToCapiPublicKeyBlob(this);
}
array[5] = 164;
return array;
}
/// <summary>Imports a blob that represents RSA key information. </summary>
/// <param name="keyBlob">A byte array that represents an RSA key blob.</param>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
/// <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x0600302F RID: 12335 RVA: 0x0009DC2C File Offset: 0x0009BE2C
[ComVisible(false)]
public void ImportCspBlob(byte[] keyBlob)
{
if (keyBlob == null)
{
throw new ArgumentNullException("keyBlob");
}
RSA rsa = CryptoConvert.FromCapiKeyBlob(keyBlob);
if (rsa is RSACryptoServiceProvider)
{
RSAParameters rsaparameters = rsa.ExportParameters(!(rsa as RSACryptoServiceProvider).PublicOnly);
this.ImportParameters(rsaparameters);
}
else
{
try
{
RSAParameters rsaparameters2 = rsa.ExportParameters(true);
this.ImportParameters(rsaparameters2);
}
catch
{
RSAParameters rsaparameters3 = rsa.ExportParameters(false);
this.ImportParameters(rsaparameters3);
}
}
}
// Token: 0x04001392 RID: 5010
private const int PROV_RSA_FULL = 1;
// Token: 0x04001393 RID: 5011
private KeyPairPersistence store;
// Token: 0x04001394 RID: 5012
private bool persistKey;
// Token: 0x04001395 RID: 5013
private bool persisted;
// Token: 0x04001396 RID: 5014
private bool privateKeyExportable = true;
// Token: 0x04001397 RID: 5015
private bool m_disposed;
// Token: 0x04001398 RID: 5016
private RSAManaged rsa;
// Token: 0x04001399 RID: 5017
private static bool useMachineKeyStore;
}
}