239 lines
6.7 KiB
C#
239 lines
6.7 KiB
C#
using System;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Prng.Drbg
|
|
{
|
|
// Token: 0x02001CB5 RID: 7349
|
|
[Token(Token = "0x2001CB5")]
|
|
public class HMacSP800Drbg : ISP80090Drbg
|
|
{
|
|
// Token: 0x0600B5F6 RID: 46582 RVA: 0x00276294 File Offset: 0x00274494
|
|
[Token(Token = "0x600B5F6")]
|
|
[Address(RVA = "0x235D0D0", Offset = "0x235C0D0", VA = "0x18235D0D0")]
|
|
public HMacSP800Drbg(IMac hMac, int securityStrength, IEntropySource entropySource, byte[] personalizationString, byte[] nonce)
|
|
{
|
|
this.mHMac = hMac;
|
|
this.mSecurityStrength = securityStrength;
|
|
this.mEntropySource = entropySource;
|
|
byte[] entropy = this.GetEntropy();
|
|
byte[][] array = new byte[3][];
|
|
if (entropy != 0)
|
|
{
|
|
}
|
|
array[0] = entropy;
|
|
byte[] array2 = Arrays.ConcatenateAll(array);
|
|
byte[] array3 = new byte[array2];
|
|
this.mK = array3;
|
|
byte[] array4 = new byte[array3.Length];
|
|
this.mV = array4;
|
|
int num = 0;
|
|
this.hmac_DRBG_Update_Func(array2, (byte)num);
|
|
if (array2 != 0)
|
|
{
|
|
}
|
|
this.mReseedCounter = (long)((ulong)1L);
|
|
}
|
|
|
|
// Token: 0x0600B5F7 RID: 46583 RVA: 0x00276330 File Offset: 0x00274530
|
|
[Token(Token = "0x600B5F7")]
|
|
[Address(RVA = "0x235D6A0", Offset = "0x235C6A0", VA = "0x18235D6A0")]
|
|
private void hmac_DRBG_Update(byte[] seedMaterial)
|
|
{
|
|
int num = 0;
|
|
this.hmac_DRBG_Update_Func(seedMaterial, (byte)num);
|
|
if (seedMaterial != 0)
|
|
{
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B5F8 RID: 46584 RVA: 0x0027634C File Offset: 0x0027454C
|
|
[Token(Token = "0x600B5F8")]
|
|
[Address(RVA = "0x235D4B0", Offset = "0x235C4B0", VA = "0x18235D4B0")]
|
|
private void hmac_DRBG_Update_Func(byte[] seedMaterial, byte vValue)
|
|
{
|
|
IMac mac = this.mHMac;
|
|
KeyParameter keyParameter = new KeyParameter(this.mK);
|
|
byte[] array = this.mV;
|
|
IMac mac2 = this.mHMac;
|
|
int length = array.Length;
|
|
IMac mac3 = this.mHMac;
|
|
if (seedMaterial != 0)
|
|
{
|
|
IMac mac4 = this.mHMac;
|
|
int length2 = seedMaterial.Length;
|
|
}
|
|
IMac mac5 = this.mHMac;
|
|
IMac mac6 = this.mHMac;
|
|
KeyParameter keyParameter2 = new KeyParameter(this.mK);
|
|
byte[] array2 = this.mV;
|
|
IMac mac7 = this.mHMac;
|
|
int length3 = array2.Length;
|
|
IMac mac8 = this.mHMac;
|
|
}
|
|
|
|
// Token: 0x17001C93 RID: 7315
|
|
// (get) Token: 0x0600B5F9 RID: 46585 RVA: 0x002763E8 File Offset: 0x002745E8
|
|
[Token(Token = "0x17001C93")]
|
|
public int BlockSize
|
|
{
|
|
[Token(Token = "0x600B5F9")]
|
|
[Address(RVA = "0x235D490", Offset = "0x235C490", VA = "0x18235D490", Slot = "4")]
|
|
get
|
|
{
|
|
return this.mV.Length;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B5FA RID: 46586 RVA: 0x00276408 File Offset: 0x00274608
|
|
[Token(Token = "0x600B5FA")]
|
|
[Address(RVA = "0x235C9E0", Offset = "0x235B9E0", VA = "0x18235C9E0", Slot = "5")]
|
|
public int Generate(byte[] output, byte[] additionalInput, bool predictionResistant)
|
|
{
|
|
int length = output.Length;
|
|
long num = this.mReseedCounter;
|
|
if (predictionResistant)
|
|
{
|
|
byte[] array = Arrays.Concatenate(this.GetEntropy(), additionalInput);
|
|
int num2 = 0;
|
|
this.hmac_DRBG_Update_Func(array, (byte)num2);
|
|
if (array != 0)
|
|
{
|
|
ulong num3;
|
|
this.hmac_DRBG_Update_Func(array, (byte)num3);
|
|
}
|
|
this.mReseedCounter = (long)((ulong)1L);
|
|
}
|
|
if (additionalInput != 0)
|
|
{
|
|
int num4 = 0;
|
|
this.hmac_DRBG_Update_Func(additionalInput, (byte)num4);
|
|
ulong num5;
|
|
this.hmac_DRBG_Update_Func(additionalInput, (byte)num5);
|
|
}
|
|
byte[] array2 = new byte[output.Length];
|
|
byte[] array3 = this.mV;
|
|
int length2 = output.Length;
|
|
IMac mac = this.mHMac;
|
|
KeyParameter keyParameter = new KeyParameter(this.mK);
|
|
int num6 = 0;
|
|
int num10;
|
|
if (length2 > 0)
|
|
{
|
|
byte[] array4 = this.mV;
|
|
IMac mac2 = this.mHMac;
|
|
int num7 = 0;
|
|
if (num7 < mac)
|
|
{
|
|
num7 += num7;
|
|
num7++;
|
|
}
|
|
int num8 = 0;
|
|
IMac mac3 = this.mHMac;
|
|
int num9 = 0;
|
|
if (num9 < num8)
|
|
{
|
|
num9 += num9;
|
|
num9++;
|
|
}
|
|
byte[] array5 = this.mV;
|
|
num10 = array5.Length;
|
|
int num11 = num10 * num6;
|
|
int num12 = 0;
|
|
Array.Copy(array5, num12, array2, num11, num10);
|
|
num6++;
|
|
}
|
|
num10 = this.mV.Length;
|
|
if (num10 * length2 < array2.Length)
|
|
{
|
|
IMac mac4 = this.mHMac;
|
|
IMac mac5 = this.mHMac;
|
|
byte[] array6 = this.mV;
|
|
int length3 = array6.Length;
|
|
int num13 = array2.Length;
|
|
int num14 = 0;
|
|
int num15 = length3 * length2;
|
|
num13 -= num15;
|
|
Array.Copy(array6, num14, array2, num15, num13);
|
|
}
|
|
int num16 = 0;
|
|
this.hmac_DRBG_Update_Func(additionalInput, (byte)num16);
|
|
if (additionalInput != 0)
|
|
{
|
|
ulong num17;
|
|
this.hmac_DRBG_Update_Func(additionalInput, (byte)num17);
|
|
}
|
|
int num18 = 0;
|
|
int length4 = output.Length;
|
|
int num19 = 0;
|
|
Array.Copy(array2, num19, output, num18, length4);
|
|
return length;
|
|
}
|
|
|
|
// Token: 0x0600B5FB RID: 46587 RVA: 0x002765D8 File Offset: 0x002747D8
|
|
[Token(Token = "0x600B5FB")]
|
|
[Address(RVA = "0x235CFC0", Offset = "0x235BFC0", VA = "0x18235CFC0", Slot = "6")]
|
|
public void Reseed(byte[] additionalInput)
|
|
{
|
|
byte[] array = Arrays.Concatenate(this.GetEntropy(), additionalInput);
|
|
int num = 0;
|
|
this.hmac_DRBG_Update_Func(array, (byte)num);
|
|
if (array != 0)
|
|
{
|
|
}
|
|
this.mReseedCounter = (long)((ulong)1L);
|
|
}
|
|
|
|
// Token: 0x0600B5FC RID: 46588 RVA: 0x0027660C File Offset: 0x0027480C
|
|
[Token(Token = "0x600B5FC")]
|
|
[Address(RVA = "0x235CF20", Offset = "0x235BF20", VA = "0x18235CF20")]
|
|
private byte[] GetEntropy()
|
|
{
|
|
IEntropySource entropySource = this.mEntropySource;
|
|
int num = this.mSecurityStrength;
|
|
num += 7;
|
|
num += typeof(IEntropySource).TypeHandle;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0400733B RID: 29499
|
|
[Token(Token = "0x400733B")]
|
|
private static readonly long RESEED_MAX = (long)((ulong)140737488355328L);
|
|
|
|
// Token: 0x0400733C RID: 29500
|
|
[Token(Token = "0x400733C")]
|
|
private static readonly int MAX_BITS_REQUEST;
|
|
|
|
// Token: 0x0400733D RID: 29501
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x400733D")]
|
|
private readonly byte[] mK;
|
|
|
|
// Token: 0x0400733E RID: 29502
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x400733E")]
|
|
private readonly byte[] mV;
|
|
|
|
// Token: 0x0400733F RID: 29503
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x400733F")]
|
|
private readonly IEntropySource mEntropySource;
|
|
|
|
// Token: 0x04007340 RID: 29504
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x4007340")]
|
|
private readonly IMac mHMac;
|
|
|
|
// Token: 0x04007341 RID: 29505
|
|
[FieldOffset(Offset = "0x30")]
|
|
[Token(Token = "0x4007341")]
|
|
private readonly int mSecurityStrength;
|
|
|
|
// Token: 0x04007342 RID: 29506
|
|
[FieldOffset(Offset = "0x38")]
|
|
[Token(Token = "0x4007342")]
|
|
private long mReseedCounter;
|
|
}
|
|
}
|