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

149 lines
3.3 KiB
C#

using System;
using System.Security.Cryptography;
namespace Mono.Security.Cryptography
{
// Token: 0x020000A5 RID: 165
internal class HMACAlgorithm
{
// Token: 0x06000906 RID: 2310 RVA: 0x00023EC8 File Offset: 0x000220C8
public HMACAlgorithm(string algoName)
{
this.CreateHash(algoName);
}
// Token: 0x06000907 RID: 2311 RVA: 0x00023ED8 File Offset: 0x000220D8
~HMACAlgorithm()
{
this.Dispose();
}
// Token: 0x06000908 RID: 2312 RVA: 0x00023F14 File Offset: 0x00022114
private void CreateHash(string algoName)
{
this.algo = HashAlgorithm.Create(algoName);
this.hashName = algoName;
this.block = new BlockProcessor(this.algo, 8);
}
// Token: 0x06000909 RID: 2313 RVA: 0x00023F3C File Offset: 0x0002213C
public void Dispose()
{
if (this.key != null)
{
Array.Clear(this.key, 0, this.key.Length);
}
}
// Token: 0x170000F7 RID: 247
// (get) Token: 0x0600090A RID: 2314 RVA: 0x00023F60 File Offset: 0x00022160
public HashAlgorithm Algo
{
get
{
return this.algo;
}
}
// Token: 0x170000F8 RID: 248
// (get) Token: 0x0600090B RID: 2315 RVA: 0x00023F68 File Offset: 0x00022168
// (set) Token: 0x0600090C RID: 2316 RVA: 0x00023F70 File Offset: 0x00022170
public string HashName
{
get
{
return this.hashName;
}
set
{
this.CreateHash(value);
}
}
// Token: 0x170000F9 RID: 249
// (get) Token: 0x0600090D RID: 2317 RVA: 0x00023F7C File Offset: 0x0002217C
// (set) Token: 0x0600090E RID: 2318 RVA: 0x00023F84 File Offset: 0x00022184
public byte[] Key
{
get
{
return this.key;
}
set
{
if (value != null && value.Length > 64)
{
this.key = this.algo.ComputeHash(value);
}
else
{
this.key = (byte[])value.Clone();
}
}
}
// Token: 0x0600090F RID: 2319 RVA: 0x00023FCC File Offset: 0x000221CC
public void Initialize()
{
this.hash = null;
this.block.Initialize();
byte[] array = this.KeySetup(this.key, 54);
this.algo.Initialize();
this.block.Core(array);
Array.Clear(array, 0, array.Length);
}
// Token: 0x06000910 RID: 2320 RVA: 0x0002401C File Offset: 0x0002221C
private byte[] KeySetup(byte[] key, byte padding)
{
byte[] array = new byte[64];
for (int i = 0; i < key.Length; i++)
{
array[i] = key[i] ^ padding;
}
for (int j = key.Length; j < 64; j++)
{
array[j] = padding;
}
return array;
}
// Token: 0x06000911 RID: 2321 RVA: 0x00024068 File Offset: 0x00022268
public void Core(byte[] rgb, int ib, int cb)
{
this.block.Core(rgb, ib, cb);
}
// Token: 0x06000912 RID: 2322 RVA: 0x00024078 File Offset: 0x00022278
public byte[] Final()
{
this.block.Final();
byte[] array = this.algo.Hash;
byte[] array2 = this.KeySetup(this.key, 92);
this.algo.Initialize();
this.algo.TransformBlock(array2, 0, array2.Length, array2, 0);
this.algo.TransformFinalBlock(array, 0, array.Length);
this.hash = this.algo.Hash;
this.algo.Clear();
Array.Clear(array2, 0, array2.Length);
Array.Clear(array, 0, array.Length);
return this.hash;
}
// Token: 0x040001ED RID: 493
private byte[] key;
// Token: 0x040001EE RID: 494
private byte[] hash;
// Token: 0x040001EF RID: 495
private HashAlgorithm algo;
// Token: 0x040001F0 RID: 496
private string hashName;
// Token: 0x040001F1 RID: 497
private BlockProcessor block;
}
}