This commit is contained in:
niko
2026-04-12 16:51:38 +02:00
parent 1b6f6d81d0
commit c12fbe3fc6
17828 changed files with 2994770 additions and 0 deletions
@@ -0,0 +1,488 @@
using System;
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: 0x02001CB3 RID: 7347
[Token(Token = "0x2001CB3")]
public class CtrSP800Drbg : ISP80090Drbg
{
// Token: 0x0600B5DE RID: 46558 RVA: 0x002758C4 File Offset: 0x00273AC4
[Token(Token = "0x600B5DE")]
[Address(RVA = "0x2354090", Offset = "0x2353090", VA = "0x182354090")]
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: 0x0600B5DF RID: 46559 RVA: 0x00275930 File Offset: 0x00273B30
[Token(Token = "0x600B5DF")]
[Address(RVA = "0x2352E00", Offset = "0x2351E00", VA = "0x182352E00")]
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: 0x0600B5E0 RID: 46560 RVA: 0x002759DC File Offset: 0x00273BDC
[Token(Token = "0x600B5E0")]
[Address(RVA = "0x23530D0", Offset = "0x23520D0", VA = "0x1823530D0")]
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: 0x0600B5E1 RID: 46561 RVA: 0x00275AC4 File Offset: 0x00273CC4
[Token(Token = "0x600B5E1")]
[Address(RVA = "0x2353020", Offset = "0x2352020", VA = "0x182353020")]
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: 0x0600B5E2 RID: 46562 RVA: 0x00275B10 File Offset: 0x00273D10
[Token(Token = "0x600B5E2")]
[Address(RVA = "0x2353F30", Offset = "0x2352F30", VA = "0x182353F30")]
private void XOR(byte[] output, byte[] a, byte[] b, int bOff)
{
int num = 0;
int length = output.Length;
if (num < length)
{
num++;
}
}
// Token: 0x0600B5E3 RID: 46563 RVA: 0x00275B34 File Offset: 0x00273D34
[Token(Token = "0x600B5E3")]
[Address(RVA = "0x23525D0", Offset = "0x23515D0", VA = "0x1823525D0")]
private void AddOneTo(byte[] longer)
{
int num = longer.Length;
uint num2;
num -= (int)num2;
byte b;
num2 += (uint)b;
}
// Token: 0x0600B5E4 RID: 46564 RVA: 0x00275B58 File Offset: 0x00273D58
[Token(Token = "0x600B5E4")]
[Address(RVA = "0x2353950", Offset = "0x2352950", VA = "0x182353950")]
private byte[] GetEntropy()
{
IEntropySource entropySource = this.mEntropySource;
int num = this.mSecurityStrength;
num += 7;
num += typeof(IEntropySource).TypeHandle;
throw new NullReferenceException();
}
// Token: 0x0600B5E5 RID: 46565 RVA: 0x00275B84 File Offset: 0x00273D84
[Token(Token = "0x600B5E5")]
[Address(RVA = "0x2352920", Offset = "0x2351920", VA = "0x182352920")]
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: 0x0600B5E6 RID: 46566 RVA: 0x00275D78 File Offset: 0x00273F78
[Token(Token = "0x600B5E6")]
[Address(RVA = "0x2352630", Offset = "0x2351630", VA = "0x182352630")]
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: 0x0600B5E7 RID: 46567 RVA: 0x00275E08 File Offset: 0x00274008
[Token(Token = "0x600B5E7")]
[Address(RVA = "0x23542C0", Offset = "0x23532C0", VA = "0x1823542C0")]
private void copyIntToByteArray(byte[] buf, int value, int offSet)
{
int num = offSet + 1;
}
// Token: 0x17001C92 RID: 7314
// (get) Token: 0x0600B5E8 RID: 46568 RVA: 0x00275E20 File Offset: 0x00274020
[Token(Token = "0x17001C92")]
public int BlockSize
{
[Token(Token = "0x600B5E8")]
[Address(RVA = "0x2354360", Offset = "0x2353360", VA = "0x182354360", Slot = "4")]
get
{
return this.mV.Length;
}
}
// Token: 0x0600B5E9 RID: 46569 RVA: 0x00275E40 File Offset: 0x00274040
[Token(Token = "0x600B5E9")]
[Address(RVA = "0x23534B0", Offset = "0x23524B0", VA = "0x1823534B0", Slot = "5")]
public int Generate(byte[] output, byte[] additionalInput, bool predictionResistant)
{
long num = this.mReseedCounter;
if (!this.mIsTdea)
{
int num2 = CtrSP800Drbg.AES_MAX_BITS_REQUEST;
if (output == 0)
{
goto IL_34;
}
num2 += typeof(DrbgUtilities).TypeHandle;
}
int num3 = CtrSP800Drbg.TDEA_MAX_BITS_REQUEST;
if (output != 0)
{
num3 += typeof(DrbgUtilities).TypeHandle;
}
IL_34:
int num4 = 0;
if (predictionResistant)
{
this.CTR_DRBG_Reseed_algorithm(additionalInput);
}
int num5 = this.mSeedLength;
if (num4 == 0)
{
byte[] array = new byte[num5];
}
byte[] array2 = this.mV;
byte[] array3 = this.mKey;
byte[] array4;
this.CTR_DRBG_Update(array4, array3, array2);
byte[] array5 = new byte[this.mV.Length];
byte[] array6 = this.mKey;
IBlockCipher blockCipher = this.mEngine;
KeyParameter keyParameter = new KeyParameter(this.ExpandKey(array6));
int num6 = output.Length;
int num7 = array5.Length;
int num8 = num7 * num4;
num6 -= num8;
int length = this.mV.Length;
num7 = num6;
int num9 = length * num4;
num7 -= num9;
if (num7 != 0)
{
byte[] array7 = this.mV;
this.AddOneTo(array7);
IBlockCipher blockCipher2 = this.mEngine;
int num10 = array5.Length * num4;
int num11 = 0;
Array.Copy(array5, num11, output, num10, num7);
}
num4++;
byte[] array8 = this.mV;
byte[] array9 = this.mKey;
this.CTR_DRBG_Update(array4, array9, array8);
return output.Length;
}
// Token: 0x0600B5EA RID: 46570 RVA: 0x00275FA4 File Offset: 0x002741A4
[Token(Token = "0x600B5EA")]
[Address(RVA = "0x2353F20", Offset = "0x2352F20", VA = "0x182353F20", Slot = "6")]
public void Reseed(byte[] additionalInput)
{
this.CTR_DRBG_Reseed_algorithm(additionalInput);
}
// Token: 0x0600B5EB RID: 46571 RVA: 0x00275FB8 File Offset: 0x002741B8
[Token(Token = "0x600B5EB")]
[Address(RVA = "0x2353AA0", Offset = "0x2352AA0", VA = "0x182353AA0")]
private bool IsTdea(IBlockCipher cipher)
{
bool flag;
bool flag2;
return flag || flag2;
}
// Token: 0x0600B5EC RID: 46572 RVA: 0x00275FD4 File Offset: 0x002741D4
[Token(Token = "0x600B5EC")]
[Address(RVA = "0x23539F0", Offset = "0x23529F0", VA = "0x1823539F0")]
private int GetMaxSecurityStrength(IBlockCipher cipher, int keySizeInBits)
{
if (!this.IsTdea(cipher) || keySizeInBits == 168)
{
}
return -1;
}
// Token: 0x0600B5ED RID: 46573 RVA: 0x00275FFC File Offset: 0x002741FC
[Token(Token = "0x600B5ED")]
[Address(RVA = "0x23533E0", Offset = "0x23523E0", VA = "0x1823533E0")]
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: 0x0600B5EE RID: 46574 RVA: 0x00276044 File Offset: 0x00274244
[Token(Token = "0x600B5EE")]
[Address(RVA = "0x2353B30", Offset = "0x2352B30", VA = "0x182353B30")]
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;
}
// Token: 0x0400732C RID: 29484
[Token(Token = "0x400732C")]
private static readonly long TDEA_RESEED_MAX = (long)((uint)int.MinValue);
// Token: 0x0400732D RID: 29485
[Token(Token = "0x400732D")]
private static readonly long AES_RESEED_MAX = (long)((ulong)140737488355328L);
// Token: 0x0400732E RID: 29486
[Token(Token = "0x400732E")]
private static readonly int TDEA_MAX_BITS_REQUEST;
// Token: 0x0400732F RID: 29487
[Token(Token = "0x400732F")]
private static readonly int AES_MAX_BITS_REQUEST;
// Token: 0x04007330 RID: 29488
[FieldOffset(Offset = "0x10")]
[Token(Token = "0x4007330")]
private readonly IEntropySource mEntropySource;
// Token: 0x04007331 RID: 29489
[FieldOffset(Offset = "0x18")]
[Token(Token = "0x4007331")]
private readonly IBlockCipher mEngine;
// Token: 0x04007332 RID: 29490
[FieldOffset(Offset = "0x20")]
[Token(Token = "0x4007332")]
private readonly int mKeySizeInBits;
// Token: 0x04007333 RID: 29491
[FieldOffset(Offset = "0x24")]
[Token(Token = "0x4007333")]
private readonly int mSeedLength;
// Token: 0x04007334 RID: 29492
[FieldOffset(Offset = "0x28")]
[Token(Token = "0x4007334")]
private readonly int mSecurityStrength;
// Token: 0x04007335 RID: 29493
[FieldOffset(Offset = "0x30")]
[Token(Token = "0x4007335")]
private byte[] mKey;
// Token: 0x04007336 RID: 29494
[FieldOffset(Offset = "0x38")]
[Token(Token = "0x4007336")]
private byte[] mV;
// Token: 0x04007337 RID: 29495
[FieldOffset(Offset = "0x40")]
[Token(Token = "0x4007337")]
private long mReseedCounter;
// Token: 0x04007338 RID: 29496
[FieldOffset(Offset = "0x48")]
[Token(Token = "0x4007338")]
private bool mIsTdea;
// Token: 0x04007339 RID: 29497
[Token(Token = "0x4007339")]
private static readonly byte[] K_BITS = Hex.Decode("000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F");
}
}
@@ -0,0 +1,129 @@
using System;
using System.Collections;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Prng.Drbg
{
// Token: 0x02001CB4 RID: 7348
[Token(Token = "0x2001CB4")]
internal class DrbgUtilities
{
// Token: 0x0600B5F0 RID: 46576 RVA: 0x002760F4 File Offset: 0x002742F4
[Token(Token = "0x600B5F0")]
[Address(RVA = "0x2355430", Offset = "0x2354430", VA = "0x182355430")]
static DrbgUtilities()
{
IDictionary dictionary = Platform.CreateHashtable();
}
// Token: 0x0600B5F1 RID: 46577 RVA: 0x00276110 File Offset: 0x00274310
[Token(Token = "0x600B5F1")]
[Address(RVA = "0x2354CE0", Offset = "0x2353CE0", VA = "0x182354CE0")]
internal static int GetMaxSecurityStrength(IDigest d)
{
throw new NullReferenceException();
}
// Token: 0x0600B5F2 RID: 46578 RVA: 0x00276124 File Offset: 0x00274324
[Token(Token = "0x600B5F2")]
[Address(RVA = "0x2354DB0", Offset = "0x2353DB0", VA = "0x182354DB0")]
internal static int GetMaxSecurityStrength(IMac m)
{
throw new NullReferenceException();
}
// Token: 0x0600B5F3 RID: 46579 RVA: 0x00276140 File Offset: 0x00274340
[Token(Token = "0x600B5F3")]
[Address(RVA = "0x2354EB0", Offset = "0x2353EB0", VA = "0x182354EB0")]
internal static byte[] HashDF(IDigest digest, byte[] seedMaterial, int seedLength)
{
byte[] array = new byte[seedMaterial];
byte[] array2 = new byte[array.Length];
int num = 0;
if (num < digest)
{
num += num;
num++;
}
num += num;
num++;
num += num;
num++;
num += num;
num++;
num += num;
num++;
int num2 = seedMaterial.Length;
uint num3;
if (num < (int)num3)
{
num += num;
num++;
}
if (num < num2)
{
num += num;
num++;
}
int num4 = array2.Length;
num2 = num4;
int num5 = array.Length;
num5 -= num2;
if (num5 <= num4)
{
num4 = num5;
}
int num6 = 0;
Array.Copy(array2, num6, array, num2, num4);
if (seedLength != 0)
{
uint num7;
num7 -= (uint)seedLength;
int length = array.Length;
if (num != length)
{
num++;
byte b;
b += b;
b = (byte)((int)b + seedLength);
b += b;
b = (byte)((int)b + seedLength);
b += b;
b = (byte)((int)b + seedLength);
b += b;
b = (byte)((int)b + seedLength);
b += b;
b = (byte)((int)b + seedLength);
b += b;
b = (byte)((int)b + seedLength);
b += b;
b = (byte)((int)b + seedLength);
}
}
return array;
}
// Token: 0x0600B5F4 RID: 46580 RVA: 0x00276264 File Offset: 0x00274464
[Token(Token = "0x600B5F4")]
[Address(RVA = "0x2355420", Offset = "0x2354420", VA = "0x182355420")]
internal static bool IsTooLarge(byte[] bytes, int maxBytes)
{
if (bytes == 0)
{
}
return bytes.Length > maxBytes;
}
// Token: 0x0600B5F5 RID: 46581 RVA: 0x00276280 File Offset: 0x00274480
[Token(Token = "0x600B5F5")]
[Address(RVA = "0x412370", Offset = "0x411370", VA = "0x180412370")]
public DrbgUtilities()
{
}
// Token: 0x0400733A RID: 29498
[Token(Token = "0x400733A")]
private static readonly IDictionary maxSecurityStrengths;
}
}
@@ -0,0 +1,238 @@
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;
}
}
@@ -0,0 +1,356 @@
using System;
using System.Collections;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Prng.Drbg
{
// Token: 0x02001CB6 RID: 7350
[Token(Token = "0x2001CB6")]
public class HashSP800Drbg : ISP80090Drbg
{
// Token: 0x0600B5FE RID: 46590 RVA: 0x00276654 File Offset: 0x00274854
[Token(Token = "0x600B5FE")]
[Address(RVA = "0x235E280", Offset = "0x235D280", VA = "0x18235E280")]
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: 0x0600B5FF RID: 46591 RVA: 0x002766CC File Offset: 0x002748CC
[Token(Token = "0x600B5FF")]
[Address(RVA = "0x235E5B0", Offset = "0x235D5B0", VA = "0x18235E5B0")]
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: 0x17001C94 RID: 7316
// (get) Token: 0x0600B600 RID: 46592 RVA: 0x002767CC File Offset: 0x002749CC
[Token(Token = "0x17001C94")]
public int BlockSize
{
[Token(Token = "0x600B600")]
[Address(RVA = "0x235EA10", Offset = "0x235DA10", VA = "0x18235EA10", Slot = "4")]
get
{
IDigest digest = this.mDigest;
throw new NullReferenceException();
}
}
// Token: 0x0600B601 RID: 46593 RVA: 0x002767E8 File Offset: 0x002749E8
[Token(Token = "0x600B601")]
[Address(RVA = "0x235D910", Offset = "0x235C910", VA = "0x18235D910", 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: 0x0600B602 RID: 46594 RVA: 0x00276A70 File Offset: 0x00274C70
[Token(Token = "0x600B602")]
[Address(RVA = "0x235DE70", Offset = "0x235CE70", VA = "0x18235DE70")]
private byte[] GetEntropy()
{
IEntropySource entropySource = this.mEntropySource;
int num = this.mSecurityStrength;
num += 7;
num += typeof(IEntropySource).TypeHandle;
throw new NullReferenceException();
}
// Token: 0x0600B603 RID: 46595 RVA: 0x00276A9C File Offset: 0x00274C9C
[Token(Token = "0x600B603")]
[Address(RVA = "0x235D780", Offset = "0x235C780", VA = "0x18235D780")]
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: 0x0600B604 RID: 46596 RVA: 0x00276ADC File Offset: 0x00274CDC
[Token(Token = "0x600B604")]
[Address(RVA = "0x235DFA0", Offset = "0x235CFA0", VA = "0x18235DFA0", 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: 0x0600B605 RID: 46597 RVA: 0x00276BD8 File Offset: 0x00274DD8
[Token(Token = "0x600B605")]
[Address(RVA = "0x235DF10", Offset = "0x235CF10", VA = "0x18235DF10")]
private byte[] Hash(byte[] input)
{
IDigest digest = this.mDigest;
byte[] array = new byte[0];
this.DoHash(input, array);
return array;
}
// Token: 0x0600B606 RID: 46598 RVA: 0x00276C04 File Offset: 0x00274E04
[Token(Token = "0x600B606")]
[Address(RVA = "0x235D870", Offset = "0x235C870", VA = "0x18235D870")]
private void DoHash(byte[] input, byte[] output)
{
IDigest digest = this.mDigest;
int length = input.Length;
IDigest digest2 = this.mDigest;
}
// Token: 0x0600B607 RID: 46599 RVA: 0x00276C2C File Offset: 0x00274E2C
[Token(Token = "0x600B607")]
[Address(RVA = "0x235EA60", Offset = "0x235DA60", VA = "0x18235EA60")]
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: 0x04007343 RID: 29507
[Token(Token = "0x4007343")]
private static readonly byte[] ONE = new byte[] { (byte)((ulong)1L) };
// Token: 0x04007344 RID: 29508
[Token(Token = "0x4007344")]
private static readonly long RESEED_MAX = (long)((ulong)140737488355328L);
// Token: 0x04007345 RID: 29509
[Token(Token = "0x4007345")]
private static readonly int MAX_BITS_REQUEST;
// Token: 0x04007346 RID: 29510
[Token(Token = "0x4007346")]
private static readonly IDictionary seedlens = Platform.CreateHashtable();
// Token: 0x04007347 RID: 29511
[FieldOffset(Offset = "0x10")]
[Token(Token = "0x4007347")]
private readonly IDigest mDigest;
// Token: 0x04007348 RID: 29512
[FieldOffset(Offset = "0x18")]
[Token(Token = "0x4007348")]
private readonly IEntropySource mEntropySource;
// Token: 0x04007349 RID: 29513
[FieldOffset(Offset = "0x20")]
[Token(Token = "0x4007349")]
private readonly int mSecurityStrength;
// Token: 0x0400734A RID: 29514
[FieldOffset(Offset = "0x24")]
[Token(Token = "0x400734A")]
private readonly int mSeedLength;
// Token: 0x0400734B RID: 29515
[FieldOffset(Offset = "0x28")]
[Token(Token = "0x400734B")]
private byte[] mV;
// Token: 0x0400734C RID: 29516
[FieldOffset(Offset = "0x30")]
[Token(Token = "0x400734C")]
private byte[] mC;
// Token: 0x0400734D RID: 29517
[FieldOffset(Offset = "0x38")]
[Token(Token = "0x400734D")]
private long mReseedCounter;
}
}
@@ -0,0 +1,30 @@
using System;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Prng.Drbg
{
// Token: 0x02001CB7 RID: 7351
[Token(Token = "0x2001CB7")]
public interface ISP80090Drbg
{
// Token: 0x17001C95 RID: 7317
// (get) Token: 0x0600B608 RID: 46600
[Token(Token = "0x17001C95")]
int BlockSize
{
[Token(Token = "0x600B608")]
[Address(Slot = "0")]
get;
}
// Token: 0x0600B609 RID: 46601
[Token(Token = "0x600B609")]
[Address(Slot = "1")]
int Generate(byte[] output, byte[] additionalInput, bool predictionResistant);
// Token: 0x0600B60A RID: 46602
[Token(Token = "0x600B60A")]
[Address(Slot = "2")]
void Reseed(byte[] additionalInput);
}
}