using System; using System.Collections; using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities; using Cpp2IlInjected; namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Prng.Drbg { // Token: 0x02001BD6 RID: 7126 [Token(Token = "0x2001BD6")] public class HashSP800Drbg : ISP80090Drbg { // Token: 0x0600B230 RID: 45616 RVA: 0x0026D494 File Offset: 0x0026B694 [Token(Token = "0x600B230")] [Address(RVA = "0x189A910", Offset = "0x1899710", VA = "0x18189A910")] 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: 0x0600B231 RID: 45617 RVA: 0x0026D50C File Offset: 0x0026B70C [Token(Token = "0x600B231")] [Address(RVA = "0x189AC40", Offset = "0x1899A40", VA = "0x18189AC40")] 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: 0x17001BF7 RID: 7159 // (get) Token: 0x0600B232 RID: 45618 RVA: 0x0026D60C File Offset: 0x0026B80C [Token(Token = "0x17001BF7")] public int BlockSize { [Token(Token = "0x600B232")] [Address(RVA = "0x189B0A0", Offset = "0x1899EA0", VA = "0x18189B0A0", Slot = "4")] get { IDigest digest = this.mDigest; throw new NullReferenceException(); } } // Token: 0x0600B233 RID: 45619 RVA: 0x0026D628 File Offset: 0x0026B828 [Token(Token = "0x600B233")] [Address(RVA = "0x1899FA0", Offset = "0x1898DA0", VA = "0x181899FA0", 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: 0x0600B234 RID: 45620 RVA: 0x0026D8B0 File Offset: 0x0026BAB0 [Token(Token = "0x600B234")] [Address(RVA = "0x189A500", Offset = "0x1899300", VA = "0x18189A500")] private byte[] GetEntropy() { IEntropySource entropySource = this.mEntropySource; int num = this.mSecurityStrength; num += 7; num += typeof(IEntropySource).TypeHandle; throw new NullReferenceException(); } // Token: 0x0600B235 RID: 45621 RVA: 0x0026D8DC File Offset: 0x0026BADC [Token(Token = "0x600B235")] [Address(RVA = "0x1899E10", Offset = "0x1898C10", VA = "0x181899E10")] 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: 0x0600B236 RID: 45622 RVA: 0x0026D91C File Offset: 0x0026BB1C [Token(Token = "0x600B236")] [Address(RVA = "0x189A630", Offset = "0x1899430", VA = "0x18189A630", 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: 0x0600B237 RID: 45623 RVA: 0x0026DA18 File Offset: 0x0026BC18 [Token(Token = "0x600B237")] [Address(RVA = "0x189A5A0", Offset = "0x18993A0", VA = "0x18189A5A0")] private byte[] Hash(byte[] input) { IDigest digest = this.mDigest; byte[] array = new byte[0]; this.DoHash(input, array); return array; } // Token: 0x0600B238 RID: 45624 RVA: 0x0026DA44 File Offset: 0x0026BC44 [Token(Token = "0x600B238")] [Address(RVA = "0x1899F00", Offset = "0x1898D00", VA = "0x181899F00")] private void DoHash(byte[] input, byte[] output) { IDigest digest = this.mDigest; int length = input.Length; IDigest digest2 = this.mDigest; } // Token: 0x0600B239 RID: 45625 RVA: 0x0026DA6C File Offset: 0x0026BC6C [Token(Token = "0x600B239")] [Address(RVA = "0x189B0F0", Offset = "0x1899EF0", VA = "0x18189B0F0")] 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: 0x0400718A RID: 29066 [Token(Token = "0x400718A")] private static readonly byte[] ONE = new byte[] { (byte)((ulong)1L) }; // Token: 0x0400718B RID: 29067 [Token(Token = "0x400718B")] private static readonly long RESEED_MAX = (long)((ulong)140737488355328L); // Token: 0x0400718C RID: 29068 [Token(Token = "0x400718C")] private static readonly int MAX_BITS_REQUEST; // Token: 0x0400718D RID: 29069 [Token(Token = "0x400718D")] private static readonly IDictionary seedlens = Platform.CreateHashtable(); // Token: 0x0400718E RID: 29070 [FieldOffset(Offset = "0x10")] [Token(Token = "0x400718E")] private readonly IDigest mDigest; // Token: 0x0400718F RID: 29071 [FieldOffset(Offset = "0x18")] [Token(Token = "0x400718F")] private readonly IEntropySource mEntropySource; // Token: 0x04007190 RID: 29072 [FieldOffset(Offset = "0x20")] [Token(Token = "0x4007190")] private readonly int mSecurityStrength; // Token: 0x04007191 RID: 29073 [FieldOffset(Offset = "0x24")] [Token(Token = "0x4007191")] private readonly int mSeedLength; // Token: 0x04007192 RID: 29074 [FieldOffset(Offset = "0x28")] [Token(Token = "0x4007192")] private byte[] mV; // Token: 0x04007193 RID: 29075 [FieldOffset(Offset = "0x30")] [Token(Token = "0x4007193")] private byte[] mC; // Token: 0x04007194 RID: 29076 [FieldOffset(Offset = "0x38")] [Token(Token = "0x4007194")] private long mReseedCounter; } }