311 lines
14 KiB
C#
311 lines
14 KiB
C#
using System;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Prng;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Security
|
|
{
|
|
// Token: 0x020019B3 RID: 6579
|
|
[Token(Token = "0x20019B3")]
|
|
public class SecureRandom : Random
|
|
{
|
|
// Token: 0x06009D35 RID: 40245 RVA: 0x0020F59C File Offset: 0x0020D79C
|
|
[Token(Token = "0x6009D35")]
|
|
[Address(RVA = "0x1B22360", Offset = "0x1B21160", VA = "0x181B22360")]
|
|
private static long NextCounterValue()
|
|
{
|
|
long num;
|
|
return num;
|
|
}
|
|
|
|
// Token: 0x17001907 RID: 6407
|
|
// (get) Token: 0x06009D36 RID: 40246 RVA: 0x0020F5AC File Offset: 0x0020D7AC
|
|
[Token(Token = "0x17001907")]
|
|
private static SecureRandom Master
|
|
{
|
|
[Token(Token = "0x6009D36")]
|
|
[Address(RVA = "0x1B22B70", Offset = "0x1B21970", VA = "0x181B22B70")]
|
|
get
|
|
{
|
|
return SecureRandom.master;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06009D37 RID: 40247 RVA: 0x0020F5C0 File Offset: 0x0020D7C0
|
|
[Token(Token = "0x6009D37")]
|
|
[Address(RVA = "0x1B21B90", Offset = "0x1B20990", VA = "0x181B21B90")]
|
|
private static DigestRandomGenerator CreatePrng(string digestName, bool autoSeed)
|
|
{
|
|
IDigest digest = DigestUtilities.GetDigest(digestName);
|
|
if (digest != 0)
|
|
{
|
|
DigestRandomGenerator digestRandomGenerator = new DigestRandomGenerator(digest);
|
|
if (autoSeed)
|
|
{
|
|
long num;
|
|
digestRandomGenerator.AddSeedMaterial(num);
|
|
byte[] array;
|
|
digestRandomGenerator.AddSeedMaterial(array);
|
|
}
|
|
return digestRandomGenerator;
|
|
}
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009D38 RID: 40248 RVA: 0x0020F5F8 File Offset: 0x0020D7F8
|
|
[Token(Token = "0x6009D38")]
|
|
[Address(RVA = "0x1B22110", Offset = "0x1B20F10", VA = "0x181B22110")]
|
|
public static byte[] GetNextBytes(SecureRandom secureRandom, int length)
|
|
{
|
|
byte[] array = new byte[length];
|
|
double num = secureRandom.NextDouble();
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x06009D39 RID: 40249 RVA: 0x0020F61C File Offset: 0x0020D81C
|
|
[Token(Token = "0x6009D39")]
|
|
[Address(RVA = "0x1B21E10", Offset = "0x1B20C10", VA = "0x181B21E10")]
|
|
public static SecureRandom GetInstance(string algorithm)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (06009D39)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling BestHTTP.SecureProtocol.Org.BouncyCastle.Security.SecureRandom BestHTTP.SecureProtocol.Org.BouncyCastle.Security.SecureRandom::GetInstance(System.String)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_4B:
|
|
stloc:ArgumentException(var_7_60, newobj:ArgumentException(ArgumentException::.ctor, call:string(string::Concat, ldstr:string("Unrecognised PRNG algorithm: "), ldloc:string(algorithm)), ldstr:string("algorithm")))
|
|
}
|
|
|
|
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 1660
|
|
*/;
|
|
}
|
|
|
|
// Token: 0x06009D3A RID: 40250 RVA: 0x0020F68C File Offset: 0x0020D88C
|
|
[Token(Token = "0x6009D3A")]
|
|
[Address(RVA = "0x1B21FB0", Offset = "0x1B20DB0", VA = "0x181B21FB0")]
|
|
public static SecureRandom GetInstance(string algorithm, bool autoSeed)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (06009D3A)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling BestHTTP.SecureProtocol.Org.BouncyCastle.Security.SecureRandom BestHTTP.SecureProtocol.Org.BouncyCastle.Security.SecureRandom::GetInstance(System.String,System.Boolean)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_48:
|
|
stloc:ArgumentException(var_6_5D, newobj:ArgumentException(ArgumentException::.ctor, call:string(string::Concat, ldstr:string("Unrecognised PRNG algorithm: "), ldloc:string(algorithm)), ldstr:string("algorithm")))
|
|
}
|
|
|
|
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 1660
|
|
*/;
|
|
}
|
|
|
|
// Token: 0x06009D3B RID: 40251 RVA: 0x0020F6F8 File Offset: 0x0020D8F8
|
|
[Token(Token = "0x6009D3B")]
|
|
[Address(RVA = "0x1B22180", Offset = "0x1B20F80", VA = "0x181B22180")]
|
|
[Obsolete]
|
|
public static byte[] GetSeed(int length)
|
|
{
|
|
SecureRandom secureRandom = SecureRandom.master;
|
|
byte[] array = new byte[length];
|
|
double num = secureRandom.NextDouble();
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x06009D3C RID: 40252 RVA: 0x0020F720 File Offset: 0x0020D920
|
|
[Token(Token = "0x6009D3C")]
|
|
[Address(RVA = "0x1B22AF0", Offset = "0x1B218F0", VA = "0x181B22AF0")]
|
|
public SecureRandom()
|
|
{
|
|
DigestRandomGenerator digestRandomGenerator = SecureRandom.CreatePrng("SHA256", true);
|
|
int num = 0;
|
|
base..ctor(num);
|
|
this.generator = digestRandomGenerator;
|
|
}
|
|
|
|
// Token: 0x06009D3D RID: 40253 RVA: 0x0020F74C File Offset: 0x0020D94C
|
|
[Token(Token = "0x6009D3D")]
|
|
[Address(RVA = "0x1B229E0", Offset = "0x1B217E0", VA = "0x181B229E0")]
|
|
[Obsolete]
|
|
public SecureRandom(byte[] seed)
|
|
{
|
|
IDigest digest = DigestUtilities.GetDigest("SHA1");
|
|
if (digest != 0)
|
|
{
|
|
DigestRandomGenerator digestRandomGenerator = new DigestRandomGenerator(digest);
|
|
}
|
|
int num = 0;
|
|
int num2 = 0;
|
|
base..ctor(num2);
|
|
this.generator = num;
|
|
}
|
|
|
|
// Token: 0x06009D3E RID: 40254 RVA: 0x0020F784 File Offset: 0x0020D984
|
|
[Token(Token = "0x6009D3E")]
|
|
[Address(RVA = "0x1B229B0", Offset = "0x1B217B0", VA = "0x181B229B0")]
|
|
public SecureRandom(IRandomGenerator generator)
|
|
{
|
|
int num = 0;
|
|
base..ctor(num);
|
|
this.generator = generator;
|
|
}
|
|
|
|
// Token: 0x06009D3F RID: 40255 RVA: 0x0020F7A4 File Offset: 0x0020D9A4
|
|
[Token(Token = "0x6009D3F")]
|
|
[Address(RVA = "0x1B21D10", Offset = "0x1B20B10", VA = "0x181B21D10", Slot = "10")]
|
|
public virtual byte[] GenerateSeed(int length)
|
|
{
|
|
SecureRandom secureRandom = SecureRandom.master;
|
|
byte[] array = new byte[length];
|
|
double num = secureRandom.NextDouble();
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x06009D40 RID: 40256 RVA: 0x0020F7CC File Offset: 0x0020D9CC
|
|
[Token(Token = "0x6009D40")]
|
|
[Address(RVA = "0x1B22850", Offset = "0x1B21650", VA = "0x181B22850", Slot = "11")]
|
|
public virtual void SetSeed(byte[] seed)
|
|
{
|
|
IRandomGenerator randomGenerator = this.generator;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009D41 RID: 40257 RVA: 0x0020F7E8 File Offset: 0x0020D9E8
|
|
[Token(Token = "0x6009D41")]
|
|
[Address(RVA = "0x1B22790", Offset = "0x1B21590", VA = "0x181B22790", Slot = "12")]
|
|
public virtual void SetSeed(long seed)
|
|
{
|
|
IRandomGenerator randomGenerator = this.generator;
|
|
int num = 0;
|
|
num += num;
|
|
num++;
|
|
randomGenerator.AddSeedMaterial(seed);
|
|
}
|
|
|
|
// Token: 0x06009D42 RID: 40258 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x6009D42")]
|
|
[Address(RVA = "0x1B22770", Offset = "0x1B21570", VA = "0x181B22770", Slot = "5")]
|
|
public override int Next()
|
|
{
|
|
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
|
|
}
|
|
|
|
// Token: 0x06009D43 RID: 40259 RVA: 0x0020F814 File Offset: 0x0020DA14
|
|
[Token(Token = "0x6009D43")]
|
|
[Address(RVA = "0x1B22680", Offset = "0x1B21480", VA = "0x181B22680", Slot = "7")]
|
|
public override int Next(int maxValue)
|
|
{
|
|
int num = maxValue - 1;
|
|
if (maxValue != num)
|
|
{
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// Token: 0x06009D44 RID: 40260 RVA: 0x0020F83C File Offset: 0x0020DA3C
|
|
[Token(Token = "0x6009D44")]
|
|
[Address(RVA = "0x1B225A0", Offset = "0x1B213A0", VA = "0x181B225A0", Slot = "6")]
|
|
public override int Next(int minValue, int maxValue)
|
|
{
|
|
if (maxValue > minValue)
|
|
{
|
|
int num;
|
|
num += minValue;
|
|
return num;
|
|
}
|
|
return minValue;
|
|
}
|
|
|
|
// Token: 0x06009D45 RID: 40261 RVA: 0x0020F860 File Offset: 0x0020DA60
|
|
[Token(Token = "0x6009D45")]
|
|
[Address(RVA = "0x1B22280", Offset = "0x1B21080", VA = "0x181B22280", Slot = "9")]
|
|
public override void NextBytes(byte[] buf)
|
|
{
|
|
IRandomGenerator randomGenerator = this.generator;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009D46 RID: 40262 RVA: 0x0020F87C File Offset: 0x0020DA7C
|
|
[Token(Token = "0x6009D46")]
|
|
[Address(RVA = "0x1B222E0", Offset = "0x1B210E0", VA = "0x181B222E0", Slot = "13")]
|
|
public virtual void NextBytes(byte[] buf, int off, int len)
|
|
{
|
|
IRandomGenerator randomGenerator = this.generator;
|
|
}
|
|
|
|
// Token: 0x06009D47 RID: 40263 RVA: 0x0020F898 File Offset: 0x0020DA98
|
|
[Token(Token = "0x6009D47")]
|
|
[Address(RVA = "0x1B223C0", Offset = "0x1B211C0", VA = "0x181B223C0", Slot = "8")]
|
|
public override double NextDouble()
|
|
{
|
|
return Convert.ToDouble((ulong)this.NextInt());
|
|
}
|
|
|
|
// Token: 0x06009D48 RID: 40264 RVA: 0x0020F8B0 File Offset: 0x0020DAB0
|
|
[Token(Token = "0x6009D48")]
|
|
[Address(RVA = "0x1B22470", Offset = "0x1B21270", VA = "0x181B22470", Slot = "14")]
|
|
public virtual int NextInt()
|
|
{
|
|
byte[] array = new byte[4];
|
|
double num = this.NextDouble();
|
|
int length = array.Length;
|
|
byte b = array[0];
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009D49 RID: 40265 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x6009D49")]
|
|
[Address(RVA = "0x1B22550", Offset = "0x1B21350", VA = "0x181B22550", Slot = "15")]
|
|
public virtual long NextLong()
|
|
{
|
|
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
|
|
}
|
|
|
|
// Token: 0x06009D4A RID: 40266 RVA: 0x0020F8E0 File Offset: 0x0020DAE0
|
|
// Note: this type is marked as 'beforefieldinit'.
|
|
[Token(Token = "0x6009D4A")]
|
|
[Address(RVA = "0x1B228B0", Offset = "0x1B216B0", VA = "0x181B228B0")]
|
|
static SecureRandom()
|
|
{
|
|
CryptoApiRandomGenerator cryptoApiRandomGenerator = new CryptoApiRandomGenerator();
|
|
int num;
|
|
SecureRandom secureRandom = new SecureRandom(num);
|
|
num = 0;
|
|
secureRandom.generator = cryptoApiRandomGenerator;
|
|
SecureRandom.master = secureRandom;
|
|
}
|
|
|
|
// Token: 0x040069EA RID: 27114
|
|
[Token(Token = "0x40069EA")]
|
|
private static long counter = Times.NanoTime();
|
|
|
|
// Token: 0x040069EB RID: 27115
|
|
[Token(Token = "0x40069EB")]
|
|
private static readonly SecureRandom master;
|
|
|
|
// Token: 0x040069EC RID: 27116
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x40069EC")]
|
|
protected readonly IRandomGenerator generator;
|
|
|
|
// Token: 0x040069ED RID: 27117
|
|
[Token(Token = "0x40069ED")]
|
|
private static readonly double DoubleScale;
|
|
}
|
|
}
|