137 lines
7.1 KiB
C#
137 lines
7.1 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace System.Security.Cryptography
|
|
{
|
|
/// <summary>Represents the abstract base class from which all implementations of asymmetric algorithms must inherit.</summary>
|
|
// Token: 0x020004E5 RID: 1253
|
|
[ComVisible(true)]
|
|
public abstract class AsymmetricAlgorithm : IDisposable
|
|
{
|
|
/// <summary>For a description of this member, see <see cref="M:System.IDisposable.Dispose" />.</summary>
|
|
// Token: 0x06002E7C RID: 11900 RVA: 0x000950A8 File Offset: 0x000932A8
|
|
void IDisposable.Dispose()
|
|
{
|
|
this.Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
/// <summary>When overridden in a derived class, gets the name of the key exchange algorithm.</summary>
|
|
/// <returns>The name of the key exchange algorithm.</returns>
|
|
// Token: 0x1700092A RID: 2346
|
|
// (get) Token: 0x06002E7D RID: 11901
|
|
public abstract string KeyExchangeAlgorithm { get; }
|
|
|
|
/// <summary>Gets or sets the size, in bits, of the key modulus used by the asymmetric algorithm.</summary>
|
|
/// <returns>The size, in bits, of the key modulus used by the asymmetric algorithm.</returns>
|
|
/// <exception cref="T:System.Security.Cryptography.CryptographicException">The key modulus size is invalid. </exception>
|
|
// Token: 0x1700092B RID: 2347
|
|
// (get) Token: 0x06002E7E RID: 11902 RVA: 0x000950B8 File Offset: 0x000932B8
|
|
// (set) Token: 0x06002E7F RID: 11903 RVA: 0x000950C0 File Offset: 0x000932C0
|
|
public virtual int KeySize
|
|
{
|
|
get
|
|
{
|
|
return this.KeySizeValue;
|
|
}
|
|
set
|
|
{
|
|
if (!KeySizes.IsLegalKeySize(this.LegalKeySizesValue, value))
|
|
{
|
|
throw new CryptographicException(Locale.GetText("Key size not supported by algorithm."));
|
|
}
|
|
this.KeySizeValue = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the key sizes that are supported by the asymmetric algorithm.</summary>
|
|
/// <returns>An array that contains the key sizes supported by the asymmetric algorithm.</returns>
|
|
// Token: 0x1700092C RID: 2348
|
|
// (get) Token: 0x06002E80 RID: 11904 RVA: 0x000950F8 File Offset: 0x000932F8
|
|
public virtual KeySizes[] LegalKeySizes
|
|
{
|
|
get
|
|
{
|
|
return this.LegalKeySizesValue;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the name of the signature algorithm.</summary>
|
|
/// <returns>The name of the signature algorithm.</returns>
|
|
// Token: 0x1700092D RID: 2349
|
|
// (get) Token: 0x06002E81 RID: 11905
|
|
public abstract string SignatureAlgorithm { get; }
|
|
|
|
/// <summary>Releases all resources used by the <see cref="T:System.Security.Cryptography.AsymmetricAlgorithm" /> class.</summary>
|
|
// Token: 0x06002E82 RID: 11906 RVA: 0x00095100 File Offset: 0x00093300
|
|
public void Clear()
|
|
{
|
|
this.Dispose(false);
|
|
}
|
|
|
|
/// <summary>When overridden in a derived class, releases the unmanaged resources used by the <see cref="T:System.Security.Cryptography.AsymmetricAlgorithm" /> and optionally releases the managed resources.</summary>
|
|
/// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources. </param>
|
|
// Token: 0x06002E83 RID: 11907
|
|
protected abstract void Dispose(bool disposing);
|
|
|
|
/// <summary>When overridden in a derived class, reconstructs an <see cref="T:System.Security.Cryptography.AsymmetricAlgorithm" /> object from an XML string.</summary>
|
|
/// <param name="xmlString">The XML string to use to reconstruct the <see cref="T:System.Security.Cryptography.AsymmetricAlgorithm" /> object. </param>
|
|
// Token: 0x06002E84 RID: 11908
|
|
public abstract void FromXmlString(string xmlString);
|
|
|
|
/// <summary>When overridden in a derived class, creates and returns an XML string representation of the current <see cref="T:System.Security.Cryptography.AsymmetricAlgorithm" /> object.</summary>
|
|
/// <returns>An XML string encoding of the current <see cref="T:System.Security.Cryptography.AsymmetricAlgorithm" /> object.</returns>
|
|
/// <param name="includePrivateParameters">true to include private parameters; otherwise, false. </param>
|
|
// Token: 0x06002E85 RID: 11909
|
|
public abstract string ToXmlString(bool includePrivateParameters);
|
|
|
|
/// <summary>Creates an instance of the default implementation of an asymmetric algorithm.</summary>
|
|
/// <returns>A new <see cref="T:System.Security.Cryptography.RSACryptoServiceProvider" /> instance, unless the default settings have been changed with the <cryptoClass> element.</returns>
|
|
/// <PermissionSet>
|
|
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
|
|
/// </PermissionSet>
|
|
// Token: 0x06002E86 RID: 11910 RVA: 0x0009510C File Offset: 0x0009330C
|
|
public static AsymmetricAlgorithm Create()
|
|
{
|
|
return AsymmetricAlgorithm.Create("System.Security.Cryptography.AsymmetricAlgorithm");
|
|
}
|
|
|
|
/// <summary>Creates an instance of the specified implementation of an asymmetric algorithm.</summary>
|
|
/// <returns>A new instance of the specified asymmetric algorithm implementation.</returns>
|
|
/// <param name="algName">The asymmetric algorithm implementation to use. The following table shows the valid values for the <paramref name="algName" /> parameter and the algorithms they map to.Parameter valueImplements System.Security.Cryptography.AsymmetricAlgorithm<see cref="T:System.Security.Cryptography.AsymmetricAlgorithm" />RSA<see cref="T:System.Security.Cryptography.RSA" />System.Security.Cryptography.RSA<see cref="T:System.Security.Cryptography.RSA" />DSA<see cref="T:System.Security.Cryptography.DSA" />System.Security.Cryptography.DSA<see cref="T:System.Security.Cryptography.DSA" />ECDsa<see cref="T:System.Security.Cryptography.ECDsa" />ECDsaCng<see cref="T:System.Security.Cryptography.ECDsaCng" />System.Security.Cryptography.ECDsaCng<see cref="T:System.Security.Cryptography.ECDsaCng" />ECDH<see cref="T:System.Security.Cryptography.ECDiffieHellman" />ECDiffieHellman<see cref="T:System.Security.Cryptography.ECDiffieHellman" />ECDiffieHellmanCng<see cref="T:System.Security.Cryptography.ECDiffieHellmanCng" />System.Security.Cryptography.ECDiffieHellmanCng<see cref="T:System.Security.Cryptography.ECDiffieHellmanCng" /></param>
|
|
// Token: 0x06002E87 RID: 11911 RVA: 0x00095118 File Offset: 0x00093318
|
|
public static AsymmetricAlgorithm Create(string algName)
|
|
{
|
|
return (AsymmetricAlgorithm)CryptoConfig.CreateFromName(algName);
|
|
}
|
|
|
|
// Token: 0x06002E88 RID: 11912 RVA: 0x00095128 File Offset: 0x00093328
|
|
internal static byte[] GetNamedParam(string xml, string param)
|
|
{
|
|
string text = "<" + param + ">";
|
|
int num = xml.IndexOf(text);
|
|
if (num == -1)
|
|
{
|
|
return null;
|
|
}
|
|
string text2 = "</" + param + ">";
|
|
int num2 = xml.IndexOf(text2);
|
|
if (num2 == -1 || num2 <= num)
|
|
{
|
|
return null;
|
|
}
|
|
num += text.Length;
|
|
string text3 = xml.Substring(num, num2 - num);
|
|
return Convert.FromBase64String(text3);
|
|
}
|
|
|
|
/// <summary>Represents the size, in bits, of the key modulus used by the asymmetric algorithm.</summary>
|
|
// Token: 0x04001267 RID: 4711
|
|
protected int KeySizeValue;
|
|
|
|
/// <summary>Specifies the key sizes that are supported by the asymmetric algorithm.</summary>
|
|
// Token: 0x04001268 RID: 4712
|
|
protected KeySizes[] LegalKeySizesValue;
|
|
}
|
|
}
|