Files
2026-04-08 23:40:05 +02:00

359 lines
10 KiB
C#

using System;
using System.Collections;
using System.Runtime.InteropServices;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Prng.Drbg
{
// Token: 0x020015F9 RID: 5625
[Token(Token = "0x20015F9")]
[StructLayout(3)]
public class HashSP800Drbg : ISP80090Drbg
{
// Token: 0x06009656 RID: 38486 RVA: 0x00215E74 File Offset: 0x00214074
[Token(Token = "0x6009656")]
[Address(RVA = "0x1E43010", Offset = "0x1E41A10", VA = "0x181E43010")]
static HashSP800Drbg()
{
IDictionary dictionary = HashSP800Drbg.seedlens;
IDictionary dictionary2 = HashSP800Drbg.seedlens;
IDictionary dictionary3 = HashSP800Drbg.seedlens;
IDictionary dictionary4 = HashSP800Drbg.seedlens;
IDictionary dictionary5 = HashSP800Drbg.seedlens;
IDictionary dictionary6 = HashSP800Drbg.seedlens;
IDictionary dictionary7 = HashSP800Drbg.seedlens;
}
// Token: 0x06009657 RID: 38487 RVA: 0x00215EEC File Offset: 0x002140EC
[Token(Token = "0x6009657")]
[Address(RVA = "0x1E43340", Offset = "0x1E41D40", VA = "0x181E43340")]
public HashSP800Drbg(IDigest digest, int securityStrength, IEntropySource entropySource, byte[] personalizationString, byte[] nonce)
{
int num;
do
{
base..ctor();
this.mDigest = digest;
this.mEntropySource = entropySource;
this.mSecurityStrength = securityStrength;
IDictionary dictionary = HashSP800Drbg.seedlens;
num = 0;
}
while ("{il2cpp array field local12->}" != num);
byte[] one = HashSP800Drbg.ONE;
this.mSeedLength = one;
byte[] entropy = this.GetEntropy();
byte[][] array = new byte[3][];
if (entropy != 0)
{
}
array[0] = entropy;
byte[] array2 = Arrays.ConcatenateAll(array);
IDigest digest2 = this.mDigest;
int num2 = this.mSeedLength;
byte[] array3 = DrbgUtilities.HashDF(digest2, array2, num2);
this.mV = array3;
int num3 = array3.Length;
num3++;
byte[] array4 = new byte[num3];
byte[] array5 = this.mV;
int length = array5.Length;
int num4 = 0;
Array.Copy(array5, num4, array4, 1, length);
int num5 = this.mSeedLength;
byte[] array6 = DrbgUtilities.HashDF(this.mDigest, array4, num5);
this.mC = array6;
this.mReseedCounter = (long)((ulong)1L);
}
// Token: 0x170017F6 RID: 6134
// (get) Token: 0x06009658 RID: 38488 RVA: 0x00215FEC File Offset: 0x002141EC
[Token(Token = "0x170017F6")]
public int BlockSize
{
[Token(Token = "0x6009658")]
[Address(RVA = "0x1E437A0", Offset = "0x1E421A0", VA = "0x181E437A0", Slot = "4")]
get
{
IDigest digest = this.mDigest;
throw new NullReferenceException();
}
}
// Token: 0x06009659 RID: 38489 RVA: 0x00216008 File Offset: 0x00214208
[Token(Token = "0x6009659")]
[Address(RVA = "0x1E426A0", Offset = "0x1E410A0", VA = "0x181E426A0", Slot = "5")]
public int Generate(byte[] output, byte[] additionalInput, bool predictionResistant)
{
int length = output.Length;
long num = this.mReseedCounter;
if (predictionResistant)
{
this.Reseed(additionalInput);
}
if (additionalInput != 0)
{
byte[] array = this.mV;
int num2 = additionalInput.Length;
num2++;
byte[] array2 = new byte[num2];
array2[0] = (byte)((ulong)2L);
byte[] array3 = this.mV;
int length2 = array3.Length;
int num3 = 0;
uint num4;
Array.Copy(array3, num3, array2, (int)num4, length2);
int num5 = this.mV.Length;
int length3 = additionalInput.Length;
num5++;
int num6 = 0;
Array.Copy(additionalInput, num6, array2, num5, length3);
byte[] array4 = this.Hash(array2);
byte[] array5 = this.mV;
this.AddTo(array5, array4);
}
byte[] array6 = this.mV;
IDigest digest = this.mDigest;
byte[] array7 = new byte[array6.Length];
int length4 = array6.Length;
int num7 = 0;
int num8 = 0;
Array.Copy(array6, num8, array7, num7, length4);
byte[] array8 = new byte[additionalInput];
IDigest digest2 = this.mDigest;
byte[] array9 = new byte[array8];
int i = 0;
this.DoHash(array7, array9);
int num9 = array9.Length;
int num10 = array8.Length;
int num11 = i * num9;
num10 -= num11;
if (num10 <= num9)
{
num9 = num10;
}
int num12 = 0;
Array.Copy(array9, num12, array8, num11, num9);
byte[] one = HashSP800Drbg.ONE;
this.AddTo(array7, one);
i++;
while (i <= additionalInput)
{
}
int num13 = this.mV.Length;
num13++;
byte[] array10 = new byte[num13];
byte[] array11 = this.mV;
int length5 = array11.Length;
int num14 = 0;
Array.Copy(array11, num14, array10, 1, length5);
array10[0] = (byte)((ulong)3L);
byte[] array12 = this.Hash(array10);
byte[] array13 = this.mV;
this.AddTo(array13, array12);
byte[] array14 = this.mC;
byte[] array15 = this.mV;
this.AddTo(array15, array14);
byte[] array16 = new byte[0];
long num15 = this.mReseedCounter;
array16[0] = (byte)num15;
long num16 = this.mReseedCounter;
array16[0] = (byte)num16;
long num17 = this.mReseedCounter;
array16[0] = (byte)num17;
long num18 = this.mReseedCounter;
array16[0] = (byte)num18;
byte[] array17 = this.mV;
this.AddTo(array17, array16);
int num19 = 0;
int length6 = output.Length;
int num20 = 0;
Array.Copy(array8, num20, output, num19, length6);
return length;
}
// Token: 0x0600965A RID: 38490 RVA: 0x00216290 File Offset: 0x00214490
[Token(Token = "0x600965A")]
[Address(RVA = "0x1E42C00", Offset = "0x1E41600", VA = "0x181E42C00")]
private byte[] GetEntropy()
{
IEntropySource entropySource = this.mEntropySource;
int num = this.mSecurityStrength;
num += 7;
num += typeof(IEntropySource).TypeHandle;
throw new NullReferenceException();
}
// Token: 0x0600965B RID: 38491 RVA: 0x002162BC File Offset: 0x002144BC
[Token(Token = "0x600965B")]
[Address(RVA = "0x1E42510", Offset = "0x1E40F10", VA = "0x181E42510")]
private void AddTo(byte[] longer, byte[] shorter)
{
int length = shorter.Length;
int num = 0;
int num2 = longer.Length;
int num3 = length - 1;
num2 -= length;
byte b;
num += (int)b;
byte b2;
num += (int)b2;
num3 = num2 - 1;
byte b3;
num += (int)b3;
}
// Token: 0x0600965C RID: 38492 RVA: 0x002162FC File Offset: 0x002144FC
[Token(Token = "0x600965C")]
[Address(RVA = "0x1E42D30", Offset = "0x1E41730", VA = "0x181E42D30", Slot = "6")]
public void Reseed(byte[] additionalInput)
{
byte[] entropy = this.GetEntropy();
byte[][] array = new byte[4][];
byte[] one = HashSP800Drbg.ONE;
if (one != 0)
{
}
array[0] = one;
byte[] array2 = this.mV;
if (array2 != 0)
{
}
array[1] = array2;
if (entropy != 0)
{
}
array[2] = entropy;
if (additionalInput != 0)
{
}
array[3] = additionalInput;
byte[] array3 = Arrays.ConcatenateAll(array);
IDigest digest = this.mDigest;
int num = this.mSeedLength;
byte[] array4 = DrbgUtilities.HashDF(digest, array3, num);
this.mV = array4;
int num2 = array4.Length;
num2++;
byte[] array5 = new byte[num2];
array5[0] = (byte)((ulong)0L);
byte[] array6 = this.mV;
int length = array6.Length;
int num3 = 0;
Array.Copy(array6, num3, array5, 1, length);
int num4 = this.mSeedLength;
byte[] array7 = DrbgUtilities.HashDF(this.mDigest, array5, num4);
this.mC = array7;
this.mReseedCounter = (long)((ulong)1L);
}
// Token: 0x0600965D RID: 38493 RVA: 0x002163F8 File Offset: 0x002145F8
[Token(Token = "0x600965D")]
[Address(RVA = "0x1E42CA0", Offset = "0x1E416A0", VA = "0x181E42CA0")]
private byte[] Hash(byte[] input)
{
IDigest digest = this.mDigest;
byte[] array = new byte[0];
this.DoHash(input, array);
return array;
}
// Token: 0x0600965E RID: 38494 RVA: 0x00216424 File Offset: 0x00214624
[Token(Token = "0x600965E")]
[Address(RVA = "0x1E42600", Offset = "0x1E41000", VA = "0x181E42600")]
private void DoHash(byte[] input, byte[] output)
{
IDigest digest = this.mDigest;
int length = input.Length;
IDigest digest2 = this.mDigest;
}
// Token: 0x0600965F RID: 38495 RVA: 0x0021644C File Offset: 0x0021464C
[Token(Token = "0x600965F")]
[Address(RVA = "0x1E437F0", Offset = "0x1E421F0", VA = "0x181E437F0")]
private byte[] hashgen(byte[] input, int lengthInBits)
{
IDigest digest = this.mDigest;
byte[] array = new byte[input.Length];
int length = input.Length;
int i = 0;
int num = 0;
int num2 = 0;
Array.Copy(input, num2, array, num, length);
byte[] array2 = new byte[lengthInBits];
IDigest digest2 = this.mDigest;
byte[] array3 = new byte[array2];
this.DoHash(array, array3);
int num3 = array3.Length;
int num4 = array2.Length;
int num5 = num3 * i;
num4 -= num5;
if (num4 <= num3)
{
num3 = num4;
}
int num6 = 0;
Array.Copy(array3, num6, array2, num5, num3);
byte[] one = HashSP800Drbg.ONE;
this.AddTo(array, one);
i++;
while (i <= lengthInBits)
{
}
return array2;
}
// Token: 0x04006347 RID: 25415
[Token(Token = "0x4006347")]
private static readonly byte[] ONE = new byte[] { (byte)((ulong)1L) };
// Token: 0x04006348 RID: 25416
[Token(Token = "0x4006348")]
private static readonly long RESEED_MAX = (long)((ulong)140737488355328L);
// Token: 0x04006349 RID: 25417
[Token(Token = "0x4006349")]
private static readonly int MAX_BITS_REQUEST;
// Token: 0x0400634A RID: 25418
[Token(Token = "0x400634A")]
private static readonly IDictionary seedlens = Platform.CreateHashtable();
// Token: 0x0400634B RID: 25419
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
[Token(Token = "0x400634B")]
private readonly IDigest mDigest;
// Token: 0x0400634C RID: 25420
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
[Token(Token = "0x400634C")]
private readonly IEntropySource mEntropySource;
// Token: 0x0400634D RID: 25421
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
[Token(Token = "0x400634D")]
private readonly int mSecurityStrength;
// Token: 0x0400634E RID: 25422
[global::Cpp2IlInjected.FieldOffset(Offset = "0x24")]
[Token(Token = "0x400634E")]
private readonly int mSeedLength;
// Token: 0x0400634F RID: 25423
[global::Cpp2IlInjected.FieldOffset(Offset = "0x28")]
[Token(Token = "0x400634F")]
private byte[] mV;
// Token: 0x04006350 RID: 25424
[global::Cpp2IlInjected.FieldOffset(Offset = "0x30")]
[Token(Token = "0x4006350")]
private byte[] mC;
// Token: 0x04006351 RID: 25425
[global::Cpp2IlInjected.FieldOffset(Offset = "0x38")]
[Token(Token = "0x4006351")]
private long mReseedCounter;
}
}