223 lines
5.9 KiB
C#
223 lines
5.9 KiB
C#
using System;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Prng
|
|
{
|
|
// Token: 0x02001BD0 RID: 7120
|
|
[Token(Token = "0x2001BD0")]
|
|
internal class X931Rng
|
|
{
|
|
// Token: 0x0600B1FE RID: 45566 RVA: 0x0026C0B0 File Offset: 0x0026A2B0
|
|
[Token(Token = "0x600B1FE")]
|
|
[Address(RVA = "0x18A5850", Offset = "0x18A4650", VA = "0x1818A5850")]
|
|
internal X931Rng(IBlockCipher engine, byte[] dateTimeVector, IEntropySource entropySource)
|
|
{
|
|
this.mEngine = engine;
|
|
this.mEntropySource = entropySource;
|
|
byte[] array = new byte[0];
|
|
this.mDT = array;
|
|
int length = array.Length;
|
|
int num = 0;
|
|
int num2 = 0;
|
|
Array.Copy(dateTimeVector, num2, array, num, length);
|
|
byte[] array2 = new byte[array];
|
|
this.mI = array2;
|
|
byte[] array3 = new byte[array2];
|
|
this.mR = array3;
|
|
}
|
|
|
|
// Token: 0x0600B1FF RID: 45567 RVA: 0x0026C128 File Offset: 0x0026A328
|
|
[Token(Token = "0x600B1FF")]
|
|
[Address(RVA = "0x18A5180", Offset = "0x18A3F80", VA = "0x1818A5180")]
|
|
internal int Generate(byte[] output, bool predictionResistant)
|
|
{
|
|
IBlockCipher blockCipher;
|
|
int length;
|
|
int num2;
|
|
do
|
|
{
|
|
byte[] array = this.mR;
|
|
long num = this.mReseedCounter;
|
|
if ((array.Length != 8 && output == 0) || output != 0)
|
|
{
|
|
}
|
|
if (predictionResistant || this.mV == (ulong)0L)
|
|
{
|
|
IEntropySource entropySource = this.mEntropySource;
|
|
this.mV = array;
|
|
blockCipher = this.mEngine;
|
|
if (array.Length != array)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
byte[] array2 = this.mR;
|
|
length = output.Length;
|
|
num2 = 0;
|
|
}
|
|
while (length <= 0);
|
|
IBlockCipher blockCipher2 = this.mEngine;
|
|
int num3 = 0;
|
|
if (num3 < blockCipher)
|
|
{
|
|
num3 += num3;
|
|
num3++;
|
|
}
|
|
byte[] array3 = this.mV;
|
|
byte[] array4 = this.mI;
|
|
byte[] array5 = this.mR;
|
|
this.Process(array5, array4, array3);
|
|
byte[] array6 = this.mI;
|
|
byte[] array7 = this.mR;
|
|
byte[] array8 = this.mV;
|
|
this.Process(array8, array7, array6);
|
|
byte[] array9 = this.mR;
|
|
int length2 = array9.Length;
|
|
int num4 = length2 * num2;
|
|
int num5 = 0;
|
|
Array.Copy(array9, num5, output, num4, length2);
|
|
byte[] array10 = this.mDT;
|
|
if (array10.Length == array10.Length)
|
|
{
|
|
}
|
|
num2++;
|
|
int length3 = this.mR.Length;
|
|
int num6 = output.Length;
|
|
int num7 = length3 * length;
|
|
num6 -= num7;
|
|
if (num6 > 0)
|
|
{
|
|
IBlockCipher blockCipher3 = this.mEngine;
|
|
byte[] array11 = this.mI;
|
|
byte[] array12 = this.mV;
|
|
byte[] array13 = this.mI;
|
|
byte[] array14 = this.mR;
|
|
this.Process(array14, array13, array12);
|
|
byte[] array15 = this.mI;
|
|
byte[] array16 = this.mR;
|
|
byte[] array17 = this.mV;
|
|
this.Process(array17, array16, array15);
|
|
byte[] array18 = this.mR;
|
|
int num8 = array18.Length * length;
|
|
int num9 = 0;
|
|
Array.Copy(array18, num9, output, num8, num6);
|
|
byte[] array19 = this.mDT;
|
|
int length4 = array19.Length;
|
|
if (length4 == array19.Length)
|
|
{
|
|
}
|
|
}
|
|
return output.Length;
|
|
}
|
|
|
|
// Token: 0x0600B200 RID: 45568 RVA: 0x0026C330 File Offset: 0x0026A530
|
|
[Token(Token = "0x600B200")]
|
|
[Address(RVA = "0x18A5790", Offset = "0x18A4590", VA = "0x1818A5790")]
|
|
internal void Reseed()
|
|
{
|
|
IEntropySource entropySource = this.mEntropySource;
|
|
IBlockCipher blockCipher = this.mEngine;
|
|
this.mReseedCounter = (long)((ulong)1L);
|
|
}
|
|
|
|
// Token: 0x17001BF4 RID: 7156
|
|
// (get) Token: 0x0600B201 RID: 45569 RVA: 0x0026C368 File Offset: 0x0026A568
|
|
[Token(Token = "0x17001BF4")]
|
|
internal IEntropySource EntropySource
|
|
{
|
|
[Token(Token = "0x600B201")]
|
|
[Address(RVA = "0x3F5F40", Offset = "0x3F4D40", VA = "0x1803F5F40")]
|
|
get
|
|
{
|
|
return this.mEntropySource;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B202 RID: 45570 RVA: 0x0026C37C File Offset: 0x0026A57C
|
|
[Token(Token = "0x600B202")]
|
|
[Address(RVA = "0x18A5690", Offset = "0x18A4490", VA = "0x1818A5690")]
|
|
private void Process(byte[] res, byte[] a, byte[] b)
|
|
{
|
|
int num = 0;
|
|
int length = res.Length;
|
|
if (num != length)
|
|
{
|
|
num++;
|
|
}
|
|
IBlockCipher blockCipher = this.mEngine;
|
|
}
|
|
|
|
// Token: 0x0600B203 RID: 45571 RVA: 0x0026C3A8 File Offset: 0x0026A5A8
|
|
[Token(Token = "0x600B203")]
|
|
[Address(RVA = "0x18A5640", Offset = "0x18A4440", VA = "0x1818A5640")]
|
|
private void Increment(byte[] val)
|
|
{
|
|
if (val.Length == val.Length)
|
|
{
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B204 RID: 45572 RVA: 0x0026C3CC File Offset: 0x0026A5CC
|
|
[Token(Token = "0x600B204")]
|
|
[Address(RVA = "0x1891A00", Offset = "0x1890800", VA = "0x181891A00")]
|
|
private static bool IsTooLarge(byte[] bytes, int maxBytes)
|
|
{
|
|
if (bytes == 0)
|
|
{
|
|
}
|
|
return bytes.Length > maxBytes;
|
|
}
|
|
|
|
// Token: 0x04007162 RID: 29026
|
|
[Token(Token = "0x4007162")]
|
|
private const long BLOCK64_RESEED_MAX = 32768L;
|
|
|
|
// Token: 0x04007163 RID: 29027
|
|
[Token(Token = "0x4007163")]
|
|
private const long BLOCK128_RESEED_MAX = 8388608L;
|
|
|
|
// Token: 0x04007164 RID: 29028
|
|
[Token(Token = "0x4007164")]
|
|
private const int BLOCK64_MAX_BITS_REQUEST = 4096;
|
|
|
|
// Token: 0x04007165 RID: 29029
|
|
[Token(Token = "0x4007165")]
|
|
private const int BLOCK128_MAX_BITS_REQUEST = 262144;
|
|
|
|
// Token: 0x04007166 RID: 29030
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x4007166")]
|
|
private readonly IBlockCipher mEngine;
|
|
|
|
// Token: 0x04007167 RID: 29031
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x4007167")]
|
|
private readonly IEntropySource mEntropySource;
|
|
|
|
// Token: 0x04007168 RID: 29032
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4007168")]
|
|
private readonly byte[] mDT;
|
|
|
|
// Token: 0x04007169 RID: 29033
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x4007169")]
|
|
private readonly byte[] mI;
|
|
|
|
// Token: 0x0400716A RID: 29034
|
|
[FieldOffset(Offset = "0x30")]
|
|
[Token(Token = "0x400716A")]
|
|
private readonly byte[] mR;
|
|
|
|
// Token: 0x0400716B RID: 29035
|
|
[FieldOffset(Offset = "0x38")]
|
|
[Token(Token = "0x400716B")]
|
|
private byte[] mV;
|
|
|
|
// Token: 0x0400716C RID: 29036
|
|
[FieldOffset(Offset = "0x40")]
|
|
[Token(Token = "0x400716C")]
|
|
private long mReseedCounter = (long)((ulong)1L);
|
|
}
|
|
}
|