using System; using System.Runtime.InteropServices; using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters; using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities; using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Encoders; using Cpp2IlInjected; namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Prng.Drbg { // Token: 0x020015F6 RID: 5622 [Token(Token = "0x20015F6")] [StructLayout(3)] public class CtrSP800Drbg : ISP80090Drbg { // Token: 0x06009636 RID: 38454 RVA: 0x002150C0 File Offset: 0x002132C0 [Token(Token = "0x6009636")] [Address(RVA = "0x1DD1150", Offset = "0x1DCFB50", VA = "0x181DD1150")] public CtrSP800Drbg(IBlockCipher engine, int keySizeInBits, int securityStrength, IEntropySource entropySource, byte[] personalizationString, byte[] nonce) { if (!this.IsTdea(engine) || keySizeInBits == 168) { } this.mEntropySource = 0; this.mEngine = engine; this.mKeySizeInBits = keySizeInBits; this.mSecurityStrength = securityStrength; this.mSeedLength = (int)((uint)2); bool flag = this.IsTdea(engine); this.mIsTdea = flag; byte[] entropy = this.GetEntropy(); } // Token: 0x06009637 RID: 38455 RVA: 0x0021512C File Offset: 0x0021332C [Token(Token = "0x6009637")] [Address(RVA = "0x1DCFE00", Offset = "0x1DCE800", VA = "0x181DCFE00")] private void CTR_DRBG_Instantiate_algorithm(byte[] entropy, byte[] nonce, byte[] personalisationString) { byte[][] array = new byte[3][]; if (entropy != 0) { } array[0] = entropy; if (nonce != 0) { } array[1] = nonce; if (personalisationString != 0) { } array[2] = personalisationString; byte[] array2 = Arrays.ConcatenateAll(array); int num = this.mSeedLength; byte[] array3 = this.Block_Cipher_df(array2, num); IBlockCipher blockCipher = this.mEngine; int num2 = this.mKeySizeInBits; num2 += 7; byte[] array4 = new byte[0]; this.mKey = array4; byte[] array5 = new byte[array3]; byte[] array6 = this.mKey; this.mV = array5; this.CTR_DRBG_Update(array3, array6, array5); this.mReseedCounter = (long)((ulong)1L); } // Token: 0x06009638 RID: 38456 RVA: 0x002151D8 File Offset: 0x002133D8 [Token(Token = "0x6009638")] [Address(RVA = "0x1DD00D0", Offset = "0x1DCEAD0", VA = "0x181DD00D0")] private void CTR_DRBG_Update(byte[] seed, byte[] key, byte[] v) { byte[] array = new byte[seed.Length]; IBlockCipher blockCipher = this.mEngine; byte[] array2 = new byte[array]; IBlockCipher blockCipher2 = this.mEngine; IBlockCipher blockCipher3 = this.mEngine; KeyParameter keyParameter = new KeyParameter(this.ExpandKey(key)); int num = 0; int num6; if (num < seed.Length) { int num2 = v.Length; uint num3; num2 -= (int)num3; byte b; num3 += (uint)b; IBlockCipher blockCipher4 = this.mEngine; if (num < num2) { num += num; num++; } int num4 = array.Length; num4 -= num; int num5 = 0; num += array2; num6 = 0; num5 += num5; num += 4; num += 19; } int length = array.Length; if (num6 < length) { num6++; } int num7 = 0; int length2 = v.Length; int num8 = 0; Array.Copy(array, num7, v, num8, length2); } // Token: 0x06009639 RID: 38457 RVA: 0x002152C0 File Offset: 0x002134C0 [Token(Token = "0x6009639")] [Address(RVA = "0x1DD0020", Offset = "0x1DCEA20", VA = "0x181DD0020")] private void CTR_DRBG_Reseed_algorithm(byte[] additionalInput) { byte[] array = Arrays.Concatenate(this.GetEntropy(), additionalInput); int num = this.mSeedLength; byte[] array2 = this.Block_Cipher_df(array, num); byte[] array3 = this.mV; byte[] array4 = this.mKey; this.CTR_DRBG_Update(array2, array4, array3); this.mReseedCounter = (long)((ulong)1L); } // Token: 0x0600963A RID: 38458 RVA: 0x0021530C File Offset: 0x0021350C [Token(Token = "0x600963A")] [Address(RVA = "0x1DD0FF0", Offset = "0x1DCF9F0", VA = "0x181DD0FF0")] private void XOR(byte[] output, byte[] a, byte[] b, int bOff) { int num = 0; int length = output.Length; if (num < length) { num++; } } // Token: 0x0600963B RID: 38459 RVA: 0x00215330 File Offset: 0x00213530 [Token(Token = "0x600963B")] [Address(RVA = "0x1DCF5D0", Offset = "0x1DCDFD0", VA = "0x181DCF5D0")] private void AddOneTo(byte[] longer) { int num = longer.Length; uint num2; num -= (int)num2; byte b; num2 += (uint)b; } // Token: 0x0600963C RID: 38460 RVA: 0x00215354 File Offset: 0x00213554 [Token(Token = "0x600963C")] [Address(RVA = "0x1DD0950", Offset = "0x1DCF350", VA = "0x181DD0950")] private byte[] GetEntropy() { IEntropySource entropySource = this.mEntropySource; int num = this.mSecurityStrength; num += 7; num += typeof(IEntropySource).TypeHandle; throw new NullReferenceException(); } // Token: 0x0600963D RID: 38461 RVA: 0x00215380 File Offset: 0x00213580 [Token(Token = "0x600963D")] [Address(RVA = "0x1DCF920", Offset = "0x1DCE320", VA = "0x181DCF920")] private byte[] Block_Cipher_df(byte[] inputString, int bitLength) { IBlockCipher blockCipher = this.mEngine; int length = inputString.Length; byte[] array = new byte[0]; int num = 0; int num2 = 0; this.copyIntToByteArray(array, length, num2); this.copyIntToByteArray(array, length, 4); int num3 = 0; Array.Copy(inputString, num3, array, 8, length); int num4 = this.mKeySizeInBits; num3 += num4; byte[] array2 = new byte[num3]; byte[] array3 = new byte[num3]; byte[] array4 = new byte[num3]; int num5 = this.mKeySizeInBits; num3 += num5; byte[] array5 = new byte[num3]; int num6 = 0; int length2 = array5.Length; int num7 = 0; byte[] k_BITS = CtrSP800Drbg.K_BITS; Array.Copy(k_BITS, num7, array5, num6, length2); int num9; if (k_BITS > 0) { array4[0] = (byte)num; array4[0] = (byte)num; array4[0] = (byte)num; array4[0] = (byte)num; this.BCC(array3, array5, array4, array); int num8 = array2.Length; num8 -= num; num9 = 0; Array.Copy(array3, num9, array2, num, num8); int num10 = this.mKeySizeInBits; num += num9; num10 += num9; num++; } byte[] array6 = new byte[num9]; int length3 = array5.Length; int num11 = 0; int num12 = 0; Array.Copy(array2, num12, array5, num11, length3); int length4 = array6.Length; int num13 = 0; int length5 = array5.Length; Array.Copy(array2, length5, array6, num13, length4); byte[] array7 = new byte[0]; IBlockCipher blockCipher2 = this.mEngine; KeyParameter keyParameter = new KeyParameter(this.ExpandKey(array5)); int num14 = 0; if (num14 < array7.Length) { IBlockCipher blockCipher3 = this.mEngine; if (num14 < blockCipher2) { num14 += num14; num14++; } int num15 = array7.Length; num15 -= num14; int num16 = 0; Array.Copy(array6, num16, array7, num14, num15); num16 += num16; num14 += 4; num14 += 19; } return array7; } // Token: 0x0600963E RID: 38462 RVA: 0x00215574 File Offset: 0x00213774 [Token(Token = "0x600963E")] [Address(RVA = "0x1DCF630", Offset = "0x1DCE030", VA = "0x181DCF630")] private void BCC(byte[] bccOut, byte[] k, byte[] iV, byte[] data) { IBlockCipher blockCipher = this.mEngine; byte[] array = new byte[0]; byte[] array2 = new byte[0]; IBlockCipher blockCipher2 = this.mEngine; KeyParameter keyParameter = new KeyParameter(this.ExpandKey(k)); IBlockCipher blockCipher3 = this.mEngine; int num = 0; int length = array2.Length; if (num < length) { num++; } IBlockCipher blockCipher4 = this.mEngine; int num2 = 0; if (num2 < num) { num2 += num2; num2++; } num++; } // Token: 0x0600963F RID: 38463 RVA: 0x00215604 File Offset: 0x00213804 [Token(Token = "0x600963F")] [Address(RVA = "0x1DD1380", Offset = "0x1DCFD80", VA = "0x181DD1380")] private void copyIntToByteArray(byte[] buf, int value, int offSet) { int num = offSet + 1; } // Token: 0x170017F4 RID: 6132 // (get) Token: 0x06009640 RID: 38464 RVA: 0x0021561C File Offset: 0x0021381C [Token(Token = "0x170017F4")] public int BlockSize { [Token(Token = "0x6009640")] [Address(RVA = "0x1DD1420", Offset = "0x1DCFE20", VA = "0x181DD1420", Slot = "4")] get { return this.mV.Length; } } // Token: 0x06009641 RID: 38465 RVA: 0x0021563C File Offset: 0x0021383C [Token(Token = "0x6009641")] [Address(RVA = "0x1DD04B0", Offset = "0x1DCEEB0", VA = "0x181DD04B0", Slot = "5")] public int Generate(byte[] output, byte[] additionalInput, bool predictionResistant) { /* An exception occurred when decompiling this method (06009641) ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Int32 BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Prng.Drbg.CtrSP800Drbg::Generate(System.Byte[],System.Byte[],System.Boolean) ---> System.Exception: Basic block has to end with unconditional control flow. { IL_146: stloc:ArgumentException(var_26_15C, newobj:ArgumentException(ArgumentException::.ctor, call:string(string::Concat, ldstr:string[exp:object]("Number of bits per request limited to "), ldloc:Camera[exp:object](var_25)), ldstr:string("output"))) } at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1852 at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.Optimize(DecompilerContext context, ILBlock method, AutoPropertyProvider autoPropertyProvider, StateMachineKind& stateMachineKind, MethodDef& inlinedMethod, AsyncMethodDebugInfo& asyncInfo, ILAstOptimizationStep abortBeforeStep) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 355 at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(IEnumerable`1 parameters, MethodDebugInfoBuilder& builder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 123 at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 88 --- End of inner exception stack trace --- at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 92 at ICSharpCode.Decompiler.Ast.AstBuilder.AddMethodBody(EntityDeclaration methodNode, EntityDeclaration& updatedNode, MethodDef method, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, MethodKind methodKind) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstBuilder.cs:line 1663 */; } // Token: 0x06009642 RID: 38466 RVA: 0x002157A8 File Offset: 0x002139A8 [Token(Token = "0x6009642")] [Address(RVA = "0x1DD0FE0", Offset = "0x1DCF9E0", VA = "0x181DD0FE0", Slot = "6")] public void Reseed(byte[] additionalInput) { this.CTR_DRBG_Reseed_algorithm(additionalInput); } // Token: 0x06009643 RID: 38467 RVA: 0x002157BC File Offset: 0x002139BC [Token(Token = "0x6009643")] [Address(RVA = "0x1DD0AA0", Offset = "0x1DCF4A0", VA = "0x181DD0AA0")] private bool IsTdea(IBlockCipher cipher) { bool flag; bool flag2; return flag || flag2; } // Token: 0x06009644 RID: 38468 RVA: 0x002157D8 File Offset: 0x002139D8 [Token(Token = "0x6009644")] [Address(RVA = "0x1DD09F0", Offset = "0x1DCF3F0", VA = "0x181DD09F0")] private int GetMaxSecurityStrength(IBlockCipher cipher, int keySizeInBits) { if (!this.IsTdea(cipher) || keySizeInBits == 168) { } return -1; } // Token: 0x06009645 RID: 38469 RVA: 0x00215800 File Offset: 0x00213A00 [Token(Token = "0x6009645")] [Address(RVA = "0x1DD03E0", Offset = "0x1DCEDE0", VA = "0x181DD03E0")] private byte[] ExpandKey(byte[] key) { if (!this.mIsTdea) { return key; } byte[] array = new byte[24]; int num = 0; int num2 = 0; this.PadKey(key, num2, array, num); ulong num3; this.PadKey(key, 7, array, (int)num3); ulong num4; this.PadKey(key, 14, array, (int)num4); return array; } // Token: 0x06009646 RID: 38470 RVA: 0x00215848 File Offset: 0x00213A48 [Token(Token = "0x6009646")] [Address(RVA = "0x1DD0B30", Offset = "0x1DCF530", VA = "0x181DD0B30")] private void PadKey(byte[] keyMaster, int keyOff, byte[] tmp, int tmpOff) { int length = keyMaster.Length; int num = keyOff + 1; byte b; tmp[0] = b; int length2 = keyMaster.Length; byte b2; tmp[0] = b2; int length3 = keyMaster.Length; byte b3; tmp[0] = b3; int length4 = keyMaster.Length; byte b4; tmp[0] = b4; int length5 = keyMaster.Length; byte b5; tmp[0] = b5; int length6 = keyMaster.Length; byte b6; b6 += b6; int length7 = tmp.Length; int length8 = tmp.Length; byte b7; tmp[0] = b7; } // Token: 0x04006330 RID: 25392 [Token(Token = "0x4006330")] private static readonly long TDEA_RESEED_MAX = (long)((uint)int.MinValue); // Token: 0x04006331 RID: 25393 [Token(Token = "0x4006331")] private static readonly long AES_RESEED_MAX = (long)((ulong)140737488355328L); // Token: 0x04006332 RID: 25394 [Token(Token = "0x4006332")] private static readonly int TDEA_MAX_BITS_REQUEST; // Token: 0x04006333 RID: 25395 [Token(Token = "0x4006333")] private static readonly int AES_MAX_BITS_REQUEST; // Token: 0x04006334 RID: 25396 [global::Cpp2IlInjected.FieldOffset(Offset = "0x10")] [Token(Token = "0x4006334")] private readonly IEntropySource mEntropySource; // Token: 0x04006335 RID: 25397 [global::Cpp2IlInjected.FieldOffset(Offset = "0x18")] [Token(Token = "0x4006335")] private readonly IBlockCipher mEngine; // Token: 0x04006336 RID: 25398 [global::Cpp2IlInjected.FieldOffset(Offset = "0x20")] [Token(Token = "0x4006336")] private readonly int mKeySizeInBits; // Token: 0x04006337 RID: 25399 [global::Cpp2IlInjected.FieldOffset(Offset = "0x24")] [Token(Token = "0x4006337")] private readonly int mSeedLength; // Token: 0x04006338 RID: 25400 [global::Cpp2IlInjected.FieldOffset(Offset = "0x28")] [Token(Token = "0x4006338")] private readonly int mSecurityStrength; // Token: 0x04006339 RID: 25401 [global::Cpp2IlInjected.FieldOffset(Offset = "0x30")] [Token(Token = "0x4006339")] private byte[] mKey; // Token: 0x0400633A RID: 25402 [global::Cpp2IlInjected.FieldOffset(Offset = "0x38")] [Token(Token = "0x400633A")] private byte[] mV; // Token: 0x0400633B RID: 25403 [global::Cpp2IlInjected.FieldOffset(Offset = "0x40")] [Token(Token = "0x400633B")] private long mReseedCounter; // Token: 0x0400633C RID: 25404 [global::Cpp2IlInjected.FieldOffset(Offset = "0x48")] [Token(Token = "0x400633C")] private bool mIsTdea; // Token: 0x0400633D RID: 25405 [Token(Token = "0x400633D")] private static readonly byte[] K_BITS = Hex.Decode("000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"); } }