using System; using System.IO; using System.Runtime.InteropServices; namespace System.Security.Cryptography { /// Represents the base class from which all implementations of cryptographic hash algorithms must derive. // Token: 0x02000508 RID: 1288 [ComVisible(true)] public abstract class HashAlgorithm : IDisposable, ICryptoTransform { /// Initializes a new instance of the class. // Token: 0x06002F6F RID: 12143 RVA: 0x00098D00 File Offset: 0x00096F00 protected HashAlgorithm() { this.disposed = false; } /// Releases the unmanaged resources used by the and optionally releases the managed resources. // Token: 0x06002F70 RID: 12144 RVA: 0x00098D10 File Offset: 0x00096F10 void IDisposable.Dispose() { this.Dispose(true); GC.SuppressFinalize(this); } /// When overridden in a derived class, gets a value indicating whether multiple blocks can be transformed. /// true if multiple blocks can be transformed; otherwise, false. // Token: 0x1700095D RID: 2397 // (get) Token: 0x06002F71 RID: 12145 RVA: 0x00098D20 File Offset: 0x00096F20 public virtual bool CanTransformMultipleBlocks { get { return true; } } /// Gets a value indicating whether the current transform can be reused. /// Always true. // Token: 0x1700095E RID: 2398 // (get) Token: 0x06002F72 RID: 12146 RVA: 0x00098D24 File Offset: 0x00096F24 public virtual bool CanReuseTransform { get { return true; } } /// Releases all resources used by the class. // Token: 0x06002F73 RID: 12147 RVA: 0x00098D28 File Offset: 0x00096F28 public void Clear() { this.Dispose(true); } /// Computes the hash value for the specified byte array. /// The computed hash code. /// The input to compute the hash code for. /// /// is null. /// The object has already been disposed. // Token: 0x06002F74 RID: 12148 RVA: 0x00098D34 File Offset: 0x00096F34 public byte[] ComputeHash(byte[] buffer) { if (buffer == null) { throw new ArgumentNullException("buffer"); } return this.ComputeHash(buffer, 0, buffer.Length); } /// Computes the hash value for the specified region of the specified byte array. /// The computed hash code. /// The input to compute the hash code for. /// The offset into the byte array from which to begin using data. /// The number of bytes in the array to use as data. /// /// is an invalid value.-or- length is invalid. /// /// is null. /// /// is out of range. This parameter requires a non-negative number. /// The object has already been disposed. // Token: 0x06002F75 RID: 12149 RVA: 0x00098D54 File Offset: 0x00096F54 public byte[] ComputeHash(byte[] buffer, int offset, int count) { if (this.disposed) { throw new ObjectDisposedException("HashAlgorithm"); } if (buffer == null) { throw new ArgumentNullException("buffer"); } if (offset < 0) { throw new ArgumentOutOfRangeException("offset", "< 0"); } if (count < 0) { throw new ArgumentException("count", "< 0"); } if (offset > buffer.Length - count) { throw new ArgumentException("offset + count", Locale.GetText("Overflow")); } this.HashCore(buffer, offset, count); this.HashValue = this.HashFinal(); this.Initialize(); return this.HashValue; } /// Computes the hash value for the specified object. /// The computed hash code. /// The input to compute the hash code for. /// The object has already been disposed. // Token: 0x06002F76 RID: 12150 RVA: 0x00098DF8 File Offset: 0x00096FF8 public byte[] ComputeHash(Stream inputStream) { if (this.disposed) { throw new ObjectDisposedException("HashAlgorithm"); } byte[] array = new byte[4096]; for (int i = inputStream.Read(array, 0, 4096); i > 0; i = inputStream.Read(array, 0, 4096)) { this.HashCore(array, 0, i); } this.HashValue = this.HashFinal(); this.Initialize(); return this.HashValue; } /// Creates an instance of the default implementation of a hash algorithm. /// A new instance, unless the default settings have been changed using the <cryptoClass> element. /// /// /// // Token: 0x06002F77 RID: 12151 RVA: 0x00098E70 File Offset: 0x00097070 public static HashAlgorithm Create() { return HashAlgorithm.Create("System.Security.Cryptography.HashAlgorithm"); } /// Creates an instance of the specified implementation of a hash algorithm. /// A new instance of the specified hash algorithm, or null if is not a valid hash algorithm. /// The hash algorithm implementation to use. The following table shows the valid values for the parameter and the algorithms they map to. Parameter value Implements SHA SHA1 System.Security.Cryptography.SHA1 System.Security.Cryptography.HashAlgorithm MD5 System.Security.Cryptography.MD5 SHA256 SHA-256 System.Security.Cryptography.SHA256 SHA384 SHA-384 System.Security.Cryptography.SHA384 SHA512 SHA-512 System.Security.Cryptography.SHA512 // Token: 0x06002F78 RID: 12152 RVA: 0x00098E7C File Offset: 0x0009707C public static HashAlgorithm Create(string hashName) { return (HashAlgorithm)CryptoConfig.CreateFromName(hashName); } /// Gets the value of the computed hash code. /// The current value of the computed hash code. /// /// is null. /// The object has already been disposed. // Token: 0x1700095F RID: 2399 // (get) Token: 0x06002F79 RID: 12153 RVA: 0x00098E8C File Offset: 0x0009708C public virtual byte[] Hash { get { if (this.HashValue == null) { throw new CryptographicUnexpectedOperationException(Locale.GetText("No hash value computed.")); } return this.HashValue; } } /// When overridden in a derived class, routes data written to the object into the hash algorithm for computing the hash. /// The input to compute the hash code for. /// The offset into the byte array from which to begin using data. /// The number of bytes in the byte array to use as data. // Token: 0x06002F7A RID: 12154 protected abstract void HashCore(byte[] array, int ibStart, int cbSize); /// When overridden in a derived class, finalizes the hash computation after the last data is processed by the cryptographic stream object. /// The computed hash code. // Token: 0x06002F7B RID: 12155 protected abstract byte[] HashFinal(); /// Gets the size, in bits, of the computed hash code. /// The size, in bits, of the computed hash code. // Token: 0x17000960 RID: 2400 // (get) Token: 0x06002F7C RID: 12156 RVA: 0x00098EB0 File Offset: 0x000970B0 public virtual int HashSize { get { return this.HashSizeValue; } } /// Initializes an implementation of the class. // Token: 0x06002F7D RID: 12157 public abstract void Initialize(); /// 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: 0x06002F7E RID: 12158 RVA: 0x00098EB8 File Offset: 0x000970B8 protected virtual void Dispose(bool disposing) { this.disposed = true; } /// When overridden in a derived class, gets the input block size. /// The input block size. // Token: 0x17000961 RID: 2401 // (get) Token: 0x06002F7F RID: 12159 RVA: 0x00098EC4 File Offset: 0x000970C4 public virtual int InputBlockSize { get { return 1; } } /// When overridden in a derived class, gets the output block size. /// The output block size. // Token: 0x17000962 RID: 2402 // (get) Token: 0x06002F80 RID: 12160 RVA: 0x00098EC8 File Offset: 0x000970C8 public virtual int OutputBlockSize { get { return 1; } } /// Computes the hash value for the specified region of the input byte array and copies the specified region of the input byte array to the specified region of the output byte array. /// The number of bytes written. /// The input to compute the hash code for. /// The offset into the input byte array from which to begin using data. /// The number of bytes in the input byte array to use as data. /// A copy of the part of the input array used to compute the hash code. /// The offset into the output byte array from which to begin writing data. /// /// uses an invalid value.-or- has an invalid length. /// /// is null. /// /// is out of range. This parameter requires a non-negative number. /// The object has already been disposed. // Token: 0x06002F81 RID: 12161 RVA: 0x00098ECC File Offset: 0x000970CC public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset) { if (inputBuffer == null) { throw new ArgumentNullException("inputBuffer"); } if (inputOffset < 0) { throw new ArgumentOutOfRangeException("inputOffset", "< 0"); } if (inputCount < 0) { throw new ArgumentException("inputCount"); } if (inputOffset < 0 || inputOffset > inputBuffer.Length - inputCount) { throw new ArgumentException("inputBuffer"); } if (outputBuffer != null) { if (outputOffset < 0) { throw new ArgumentOutOfRangeException("outputOffset", "< 0"); } if (outputOffset > outputBuffer.Length - inputCount) { throw new ArgumentException("outputOffset + inputCount", Locale.GetText("Overflow")); } } this.HashCore(inputBuffer, inputOffset, inputCount); if (outputBuffer != null) { Buffer.BlockCopy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount); } return inputCount; } /// Computes the hash value for the specified region of the specified byte array. /// An array that is a copy of the part of the input that is hashed. /// The input to compute the hash code for. /// The offset into the byte array from which to begin using data. /// The number of bytes in the byte array to use as data. /// /// uses an invalid value.-or- has an invalid offset length. /// /// is null. /// /// is out of range. This parameter requires a non-negative number. /// The object has already been disposed. // Token: 0x06002F82 RID: 12162 RVA: 0x00098F90 File Offset: 0x00097190 public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount) { if (inputBuffer == null) { throw new ArgumentNullException("inputBuffer"); } if (inputCount < 0) { throw new ArgumentException("inputCount"); } if (inputOffset > inputBuffer.Length - inputCount) { throw new ArgumentException("inputOffset + inputCount", Locale.GetText("Overflow")); } byte[] array = new byte[inputCount]; Buffer.BlockCopy(inputBuffer, inputOffset, array, 0, inputCount); this.HashCore(inputBuffer, inputOffset, inputCount); this.HashValue = this.HashFinal(); this.Initialize(); return array; } /// Represents the value of the computed hash code. // Token: 0x0400135A RID: 4954 protected internal byte[] HashValue; /// Represents the size, in bits, of the computed hash code. // Token: 0x0400135B RID: 4955 protected int HashSizeValue; /// Represents the state of the hash computation. // Token: 0x0400135C RID: 4956 protected int State; // Token: 0x0400135D RID: 4957 private bool disposed; } }