using System;
using System.Runtime.InteropServices;
using Mono.Security.Cryptography;
namespace System.Security.Cryptography
{
/// Represents the abstract class from which all implementations of Hash-based Message Authentication Code (HMAC) must derive.
// Token: 0x02000501 RID: 1281
[ComVisible(true)]
public abstract class HMAC : KeyedHashAlgorithm
{
/// Initializes a new instance of the class.
// Token: 0x06002F4D RID: 12109 RVA: 0x000987AC File Offset: 0x000969AC
protected HMAC()
{
this._disposed = false;
this._blockSizeValue = 64;
}
/// Gets or sets the block size to use in the hash value.
/// The block size to use in the hash value.
// Token: 0x17000957 RID: 2391
// (get) Token: 0x06002F4E RID: 12110 RVA: 0x000987C4 File Offset: 0x000969C4
// (set) Token: 0x06002F4F RID: 12111 RVA: 0x000987CC File Offset: 0x000969CC
protected int BlockSizeValue
{
get
{
return this._blockSizeValue;
}
set
{
this._blockSizeValue = value;
}
}
/// Gets or sets the name of the hash algorithm to use for hashing.
/// The name of the hash algorithm.
/// The current hash algorithm cannot be changed.
// Token: 0x17000958 RID: 2392
// (get) Token: 0x06002F50 RID: 12112 RVA: 0x000987D8 File Offset: 0x000969D8
// (set) Token: 0x06002F51 RID: 12113 RVA: 0x000987E0 File Offset: 0x000969E0
public string HashName
{
get
{
return this._hashName;
}
set
{
this._hashName = value;
this._algo = HashAlgorithm.Create(this._hashName);
}
}
/// Gets or sets the key to use in the hash algorithm.
/// The key to use in the hash algorithm.
/// An attempt is made to change the property after hashing has begun.
// Token: 0x17000959 RID: 2393
// (get) Token: 0x06002F52 RID: 12114 RVA: 0x000987FC File Offset: 0x000969FC
// (set) Token: 0x06002F53 RID: 12115 RVA: 0x00098810 File Offset: 0x00096A10
public override byte[] Key
{
get
{
return (byte[])base.Key.Clone();
}
set
{
if (value != null && value.Length > 64)
{
base.Key = this._algo.ComputeHash(value);
}
else
{
base.Key = (byte[])value.Clone();
}
}
}
// Token: 0x1700095A RID: 2394
// (get) Token: 0x06002F54 RID: 12116 RVA: 0x00098858 File Offset: 0x00096A58
internal BlockProcessor Block
{
get
{
if (this._block == null)
{
this._block = new BlockProcessor(this._algo, this.BlockSizeValue >> 3);
}
return this._block;
}
}
// Token: 0x06002F55 RID: 12117 RVA: 0x00098890 File Offset: 0x00096A90
private byte[] KeySetup(byte[] key, byte padding)
{
byte[] array = new byte[this.BlockSizeValue];
for (int i = 0; i < key.Length; i++)
{
array[i] = key[i] ^ padding;
}
for (int j = key.Length; j < this.BlockSizeValue; j++)
{
array[j] = padding;
}
return array;
}
/// Releases the unmanaged resources used by the class when a key change is legitimate and optionally releases the managed resources.
/// true to release both managed and unmanaged resources; false to release only unmanaged resources.
// Token: 0x06002F56 RID: 12118 RVA: 0x000988E4 File Offset: 0x00096AE4
protected override void Dispose(bool disposing)
{
if (!this._disposed)
{
base.Dispose(disposing);
}
}
/// When overridden in a derived class, routes data written to the object into the default hash algorithm for computing the hash value.
/// The input data.
/// The offset into the byte array from which to begin using data.
/// The number of bytes in the array to use as data.
// Token: 0x06002F57 RID: 12119 RVA: 0x000988F8 File Offset: 0x00096AF8
protected override void HashCore(byte[] rgb, int ib, int cb)
{
if (this._disposed)
{
throw new ObjectDisposedException("HMACSHA1");
}
if (this.State == 0)
{
this.Initialize();
this.State = 1;
}
this.Block.Core(rgb, ib, cb);
}
/// 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 in a byte array.
// Token: 0x06002F58 RID: 12120 RVA: 0x00098944 File Offset: 0x00096B44
protected override byte[] HashFinal()
{
if (this._disposed)
{
throw new ObjectDisposedException("HMAC");
}
this.State = 0;
this.Block.Final();
byte[] hash = this._algo.Hash;
byte[] array = this.KeySetup(this.Key, 92);
this._algo.Initialize();
this._algo.TransformBlock(array, 0, array.Length, array, 0);
this._algo.TransformFinalBlock(hash, 0, hash.Length);
byte[] hash2 = this._algo.Hash;
this._algo.Initialize();
Array.Clear(array, 0, array.Length);
Array.Clear(hash, 0, hash.Length);
return hash2;
}
/// Initializes an instance of the default implementation of .
// Token: 0x06002F59 RID: 12121 RVA: 0x000989F0 File Offset: 0x00096BF0
public override void Initialize()
{
if (this._disposed)
{
throw new ObjectDisposedException("HMAC");
}
this.State = 0;
this.Block.Initialize();
byte[] array = this.KeySetup(this.Key, 54);
this._algo.Initialize();
this.Block.Core(array);
Array.Clear(array, 0, array.Length);
}
/// Creates an instance of the default implementation of a Hash-based Message Authentication Code (HMAC).
/// A new SHA-1 instance, unless the default settings have been changed by using the <cryptoClass> element.
///
///
///
// Token: 0x06002F5A RID: 12122 RVA: 0x00098A58 File Offset: 0x00096C58
public new static HMAC Create()
{
return HMAC.Create("System.Security.Cryptography.HMAC");
}
/// Creates an instance of the specified implementation of a Hash-based Message Authentication Code (HMAC).
/// A new instance of the specified HMAC implementation.
/// The HMAC implementation to use. The following table shows the valid values for the parameter and the algorithms they map to.Parameter valueImplements System.Security.Cryptography.HMACSystem.Security.Cryptography.KeyedHashAlgorithmHMACMD5System.Security.Cryptography.HMACMD5HMACRIPEMD160System.Security.Cryptography.HMACRIPEMD160HMACSHA1System.Security.Cryptography.HMACSHA1HMACSHA256System.Security.Cryptography.HMACSHA256HMACSHA384System.Security.Cryptography.HMACSHA384HMACSHA512System.Security.Cryptography.HMACSHA512MACTripleDESSystem.Security.Cryptography.MACTripleDES
// Token: 0x06002F5B RID: 12123 RVA: 0x00098A64 File Offset: 0x00096C64
public new static HMAC Create(string algorithmName)
{
return (HMAC)CryptoConfig.CreateFromName(algorithmName);
}
// Token: 0x04001351 RID: 4945
private bool _disposed;
// Token: 0x04001352 RID: 4946
private string _hashName;
// Token: 0x04001353 RID: 4947
private HashAlgorithm _algo;
// Token: 0x04001354 RID: 4948
private BlockProcessor _block;
// Token: 0x04001355 RID: 4949
private int _blockSizeValue;
}
}