using System; using System.Runtime.InteropServices; namespace System.Security.Cryptography { /// Represents the abstract base class from which all implementations of symmetric algorithms must inherit. // Token: 0x02000538 RID: 1336 [ComVisible(true)] public abstract class SymmetricAlgorithm : IDisposable { /// Initializes a new instance of the class. /// The implementation of the class derived from the symmetric algorithm is not valid. // Token: 0x060030DE RID: 12510 RVA: 0x000A80C8 File Offset: 0x000A62C8 protected SymmetricAlgorithm() { this.ModeValue = CipherMode.CBC; this.PaddingValue = PaddingMode.PKCS7; this.m_disposed = false; } /// Releases the unmanaged resources used by the and optionally releases the managed resources. // Token: 0x060030DF RID: 12511 RVA: 0x000A80E8 File Offset: 0x000A62E8 void IDisposable.Dispose() { this.Dispose(true); GC.SuppressFinalize(this); } // Token: 0x060030E0 RID: 12512 RVA: 0x000A80F8 File Offset: 0x000A62F8 ~SymmetricAlgorithm() { this.Dispose(false); } /// Releases all resources used by the class. // Token: 0x060030E1 RID: 12513 RVA: 0x000A8134 File Offset: 0x000A6334 public void Clear() { this.Dispose(true); } /// Releases the unmanaged resources used by the and optionally releases the managed resources. /// true to release both managed and unmanaged resources; false to release only unmanaged resources. // Token: 0x060030E2 RID: 12514 RVA: 0x000A8140 File Offset: 0x000A6340 protected virtual void Dispose(bool disposing) { if (!this.m_disposed) { if (this.KeyValue != null) { Array.Clear(this.KeyValue, 0, this.KeyValue.Length); this.KeyValue = null; } if (disposing) { } this.m_disposed = true; } } /// Gets or sets the block size, in bits, of the cryptographic operation. /// The block size, in bits. /// The block size is invalid. // Token: 0x1700098F RID: 2447 // (get) Token: 0x060030E3 RID: 12515 RVA: 0x000A818C File Offset: 0x000A638C // (set) Token: 0x060030E4 RID: 12516 RVA: 0x000A8194 File Offset: 0x000A6394 public virtual int BlockSize { get { return this.BlockSizeValue; } set { if (!KeySizes.IsLegalKeySize(this.LegalBlockSizesValue, value)) { throw new CryptographicException(Locale.GetText("block size not supported by algorithm")); } if (this.BlockSizeValue != value) { this.BlockSizeValue = value; this.IVValue = null; } } } /// Gets or sets the feedback size, in bits, of the cryptographic operation. /// The feedback size in bits. /// The feedback size is larger than the block size. // Token: 0x17000990 RID: 2448 // (get) Token: 0x060030E5 RID: 12517 RVA: 0x000A81D4 File Offset: 0x000A63D4 // (set) Token: 0x060030E6 RID: 12518 RVA: 0x000A81DC File Offset: 0x000A63DC public virtual int FeedbackSize { get { return this.FeedbackSizeValue; } set { if (value <= 0 || value > this.BlockSizeValue) { throw new CryptographicException(Locale.GetText("feedback size larger than block size")); } this.FeedbackSizeValue = value; } } /// Gets or sets the initialization vector () for the symmetric algorithm. /// The initialization vector. /// An attempt was made to set the initialization vector to null. /// An attempt was made to set the initialization vector to an invalid size. // Token: 0x17000991 RID: 2449 // (get) Token: 0x060030E7 RID: 12519 RVA: 0x000A8214 File Offset: 0x000A6414 // (set) Token: 0x060030E8 RID: 12520 RVA: 0x000A8238 File Offset: 0x000A6438 public virtual byte[] IV { get { if (this.IVValue == null) { this.GenerateIV(); } return (byte[])this.IVValue.Clone(); } set { if (value == null) { throw new ArgumentNullException("IV"); } if (value.Length << 3 != this.BlockSizeValue) { throw new CryptographicException(Locale.GetText("IV length is different than block size")); } this.IVValue = (byte[])value.Clone(); } } /// Gets or sets the secret key for the symmetric algorithm. /// The secret key to use for the symmetric algorithm. /// An attempt was made to set the key to null. /// The key size is invalid. // Token: 0x17000992 RID: 2450 // (get) Token: 0x060030E9 RID: 12521 RVA: 0x000A8288 File Offset: 0x000A6488 // (set) Token: 0x060030EA RID: 12522 RVA: 0x000A82AC File Offset: 0x000A64AC public virtual byte[] Key { get { if (this.KeyValue == null) { this.GenerateKey(); } return (byte[])this.KeyValue.Clone(); } set { if (value == null) { throw new ArgumentNullException("Key"); } int num = value.Length << 3; if (!KeySizes.IsLegalKeySize(this.LegalKeySizesValue, num)) { throw new CryptographicException(Locale.GetText("Key size not supported by algorithm")); } this.KeySizeValue = num; this.KeyValue = (byte[])value.Clone(); } } /// Gets or sets the size, in bits, of the secret key used by the symmetric algorithm. /// The size, in bits, of the secret key used by the symmetric algorithm. /// The key size is not valid. // Token: 0x17000993 RID: 2451 // (get) Token: 0x060030EB RID: 12523 RVA: 0x000A830C File Offset: 0x000A650C // (set) Token: 0x060030EC RID: 12524 RVA: 0x000A8314 File Offset: 0x000A6514 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; this.KeyValue = null; } } /// Gets the block sizes, in bits, that are supported by the symmetric algorithm. /// An array that contains the block sizes supported by the algorithm. // Token: 0x17000994 RID: 2452 // (get) Token: 0x060030ED RID: 12525 RVA: 0x000A8348 File Offset: 0x000A6548 public virtual KeySizes[] LegalBlockSizes { get { return this.LegalBlockSizesValue; } } /// Gets the key sizes, in bits, that are supported by the symmetric algorithm. /// An array that contains the key sizes supported by the algorithm. // Token: 0x17000995 RID: 2453 // (get) Token: 0x060030EE RID: 12526 RVA: 0x000A8350 File Offset: 0x000A6550 public virtual KeySizes[] LegalKeySizes { get { return this.LegalKeySizesValue; } } /// Gets or sets the mode for operation of the symmetric algorithm. /// The mode for operation of the symmetric algorithm. The default is . /// The cipher mode is not one of the values. // Token: 0x17000996 RID: 2454 // (get) Token: 0x060030EF RID: 12527 RVA: 0x000A8358 File Offset: 0x000A6558 // (set) Token: 0x060030F0 RID: 12528 RVA: 0x000A8360 File Offset: 0x000A6560 public virtual CipherMode Mode { get { return this.ModeValue; } set { if (!Enum.IsDefined(this.ModeValue.GetType(), value)) { throw new CryptographicException(Locale.GetText("Cipher mode not available")); } this.ModeValue = value; } } /// Gets or sets the padding mode used in the symmetric algorithm. /// The padding mode used in the symmetric algorithm. The default is . /// The padding mode is not one of the values. // Token: 0x17000997 RID: 2455 // (get) Token: 0x060030F1 RID: 12529 RVA: 0x000A839C File Offset: 0x000A659C // (set) Token: 0x060030F2 RID: 12530 RVA: 0x000A83A4 File Offset: 0x000A65A4 public virtual PaddingMode Padding { get { return this.PaddingValue; } set { if (!Enum.IsDefined(this.PaddingValue.GetType(), value)) { throw new CryptographicException(Locale.GetText("Padding mode not available")); } this.PaddingValue = value; } } /// Creates a symmetric decryptor object with the current property and initialization vector (). /// A symmetric decryptor object. // Token: 0x060030F3 RID: 12531 RVA: 0x000A83E0 File Offset: 0x000A65E0 public virtual ICryptoTransform CreateDecryptor() { return this.CreateDecryptor(this.Key, this.IV); } /// When overridden in a derived class, creates a symmetric decryptor object with the specified property and initialization vector (). /// A symmetric decryptor object. /// The secret key to use for the symmetric algorithm. /// The initialization vector to use for the symmetric algorithm. // Token: 0x060030F4 RID: 12532 public abstract ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV); /// Creates a symmetric encryptor object with the current property and initialization vector (). /// A symmetric encryptor object. // Token: 0x060030F5 RID: 12533 RVA: 0x000A83F4 File Offset: 0x000A65F4 public virtual ICryptoTransform CreateEncryptor() { return this.CreateEncryptor(this.Key, this.IV); } /// When overridden in a derived class, creates a symmetric encryptor object with the specified property and initialization vector (). /// A symmetric encryptor object. /// The secret key to use for the symmetric algorithm. /// The initialization vector to use for the symmetric algorithm. // Token: 0x060030F6 RID: 12534 public abstract ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[] rgbIV); /// When overridden in a derived class, generates a random initialization vector () to use for the algorithm. // Token: 0x060030F7 RID: 12535 public abstract void GenerateIV(); /// When overridden in a derived class, generates a random key () to use for the algorithm. // Token: 0x060030F8 RID: 12536 public abstract void GenerateKey(); /// Determines whether the specified key size is valid for the current algorithm. /// true if the specified key size is valid for the current algorithm; otherwise, false. /// The length, in bits, to check for a valid key size. // Token: 0x060030F9 RID: 12537 RVA: 0x000A8408 File Offset: 0x000A6608 public bool ValidKeySize(int bitLength) { return KeySizes.IsLegalKeySize(this.LegalKeySizesValue, bitLength); } /// Creates a default cryptographic object used to perform the symmetric algorithm. /// A default cryptographic object used to perform the symmetric algorithm. /// /// /// // Token: 0x060030FA RID: 12538 RVA: 0x000A8418 File Offset: 0x000A6618 public static SymmetricAlgorithm Create() { return SymmetricAlgorithm.Create("System.Security.Cryptography.SymmetricAlgorithm"); } /// Creates the specified cryptographic object used to perform the symmetric algorithm. /// A cryptographic object used to perform the symmetric algorithm. /// The name of the specific implementation of the class to use. // Token: 0x060030FB RID: 12539 RVA: 0x000A8424 File Offset: 0x000A6624 public static SymmetricAlgorithm Create(string algName) { return (SymmetricAlgorithm)CryptoConfig.CreateFromName(algName); } /// Represents the block size, in bits, of the cryptographic operation. // Token: 0x040013F9 RID: 5113 protected int BlockSizeValue; /// Represents the initialization vector () for the symmetric algorithm. // Token: 0x040013FA RID: 5114 protected byte[] IVValue; /// Represents the size, in bits, of the secret key used by the symmetric algorithm. // Token: 0x040013FB RID: 5115 protected int KeySizeValue; /// Represents the secret key for the symmetric algorithm. // Token: 0x040013FC RID: 5116 protected byte[] KeyValue; /// Specifies the block sizes, in bits, that are supported by the symmetric algorithm. // Token: 0x040013FD RID: 5117 protected KeySizes[] LegalBlockSizesValue; /// Specifies the key sizes, in bits, that are supported by the symmetric algorithm. // Token: 0x040013FE RID: 5118 protected KeySizes[] LegalKeySizesValue; /// Represents the feedback size, in bits, of the cryptographic operation. // Token: 0x040013FF RID: 5119 protected int FeedbackSizeValue; /// Represents the cipher mode used in the symmetric algorithm. // Token: 0x04001400 RID: 5120 protected CipherMode ModeValue; /// Represents the padding mode used in the symmetric algorithm. // Token: 0x04001401 RID: 5121 protected PaddingMode PaddingValue; // Token: 0x04001402 RID: 5122 private bool m_disposed; } }