Files
Aug2021-Cpp2IL-Dump/Assembly-CSharp/BestHTTP/SecureProtocol/Org/BouncyCastle/Crypto/Prng/Drbg/HMacSP800Drbg.cs
T
2026-04-10 22:50:51 +02:00

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: 0x02001BD5 RID: 7125
[Token(Token = "0x2001BD5")]
public class HMacSP800Drbg : ISP80090Drbg
{
// Token: 0x0600B228 RID: 45608 RVA: 0x0026D0D4 File Offset: 0x0026B2D4
[Token(Token = "0x600B228")]
[Address(RVA = "0x1899760", Offset = "0x1898560", VA = "0x181899760")]
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: 0x0600B229 RID: 45609 RVA: 0x0026D170 File Offset: 0x0026B370
[Token(Token = "0x600B229")]
[Address(RVA = "0x1899D30", Offset = "0x1898B30", VA = "0x181899D30")]
private void hmac_DRBG_Update(byte[] seedMaterial)
{
int num = 0;
this.hmac_DRBG_Update_Func(seedMaterial, (byte)num);
if (seedMaterial != 0)
{
}
}
// Token: 0x0600B22A RID: 45610 RVA: 0x0026D18C File Offset: 0x0026B38C
[Token(Token = "0x600B22A")]
[Address(RVA = "0x1899B40", Offset = "0x1898940", VA = "0x181899B40")]
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: 0x17001BF6 RID: 7158
// (get) Token: 0x0600B22B RID: 45611 RVA: 0x0026D228 File Offset: 0x0026B428
[Token(Token = "0x17001BF6")]
public int BlockSize
{
[Token(Token = "0x600B22B")]
[Address(RVA = "0x1899B20", Offset = "0x1898920", VA = "0x181899B20", Slot = "4")]
get
{
return this.mV.Length;
}
}
// Token: 0x0600B22C RID: 45612 RVA: 0x0026D248 File Offset: 0x0026B448
[Token(Token = "0x600B22C")]
[Address(RVA = "0x1899070", Offset = "0x1897E70", VA = "0x181899070", 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: 0x0600B22D RID: 45613 RVA: 0x0026D418 File Offset: 0x0026B618
[Token(Token = "0x600B22D")]
[Address(RVA = "0x1899650", Offset = "0x1898450", VA = "0x181899650", 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: 0x0600B22E RID: 45614 RVA: 0x0026D44C File Offset: 0x0026B64C
[Token(Token = "0x600B22E")]
[Address(RVA = "0x18995B0", Offset = "0x18983B0", VA = "0x1818995B0")]
private byte[] GetEntropy()
{
IEntropySource entropySource = this.mEntropySource;
int num = this.mSecurityStrength;
num += 7;
num += typeof(IEntropySource).TypeHandle;
throw new NullReferenceException();
}
// Token: 0x04007182 RID: 29058
[Token(Token = "0x4007182")]
private static readonly long RESEED_MAX = (long)((ulong)140737488355328L);
// Token: 0x04007183 RID: 29059
[Token(Token = "0x4007183")]
private static readonly int MAX_BITS_REQUEST;
// Token: 0x04007184 RID: 29060
[FieldOffset(Offset = "0x10")]
[Token(Token = "0x4007184")]
private readonly byte[] mK;
// Token: 0x04007185 RID: 29061
[FieldOffset(Offset = "0x18")]
[Token(Token = "0x4007185")]
private readonly byte[] mV;
// Token: 0x04007186 RID: 29062
[FieldOffset(Offset = "0x20")]
[Token(Token = "0x4007186")]
private readonly IEntropySource mEntropySource;
// Token: 0x04007187 RID: 29063
[FieldOffset(Offset = "0x28")]
[Token(Token = "0x4007187")]
private readonly IMac mHMac;
// Token: 0x04007188 RID: 29064
[FieldOffset(Offset = "0x30")]
[Token(Token = "0x4007188")]
private readonly int mSecurityStrength;
// Token: 0x04007189 RID: 29065
[FieldOffset(Offset = "0x38")]
[Token(Token = "0x4007189")]
private long mReseedCounter;
}
}