322 lines
14 KiB
C#
322 lines
14 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Runtime.InteropServices;
|
|
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: 0x020013D6 RID: 5078
|
|
[Token(Token = "0x20013D6")]
|
|
[StructLayout(3)]
|
|
public class SecureRandom : Random
|
|
{
|
|
// Token: 0x0600815B RID: 33115 RVA: 0x001B7FDC File Offset: 0x001B61DC
|
|
[Token(Token = "0x600815B")]
|
|
[Address(RVA = "0x1C61FB0", Offset = "0x1C609B0", VA = "0x181C61FB0")]
|
|
private static long NextCounterValue()
|
|
{
|
|
long num;
|
|
return num;
|
|
}
|
|
|
|
// Token: 0x17001506 RID: 5382
|
|
// (get) Token: 0x0600815C RID: 33116 RVA: 0x001B7FEC File Offset: 0x001B61EC
|
|
[Token(Token = "0x17001506")]
|
|
private static SecureRandom Master
|
|
{
|
|
[Token(Token = "0x600815C")]
|
|
[Address(RVA = "0x1C627C0", Offset = "0x1C611C0", VA = "0x181C627C0")]
|
|
get
|
|
{
|
|
return SecureRandom.master;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600815D RID: 33117 RVA: 0x001B8000 File Offset: 0x001B6200
|
|
[Token(Token = "0x600815D")]
|
|
[Address(RVA = "0x1C61770", Offset = "0x1C60170", VA = "0x181C61770")]
|
|
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: 0x0600815E RID: 33118 RVA: 0x001B8038 File Offset: 0x001B6238
|
|
[Token(Token = "0x600815E")]
|
|
[Address(RVA = "0x1C61CF0", Offset = "0x1C606F0", VA = "0x181C61CF0")]
|
|
public static byte[] GetNextBytes(SecureRandom secureRandom, int length)
|
|
{
|
|
byte[] array = new byte[length];
|
|
double num = secureRandom.NextDouble();
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x0600815F RID: 33119 RVA: 0x001B805C File Offset: 0x001B625C
|
|
[Token(Token = "0x600815F")]
|
|
[Address(RVA = "0x1C619F0", Offset = "0x1C603F0", VA = "0x181C619F0")]
|
|
public static SecureRandom GetInstance(string algorithm)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600815F)
|
|
|
|
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 1663
|
|
*/;
|
|
}
|
|
|
|
// Token: 0x06008160 RID: 33120 RVA: 0x001B80CC File Offset: 0x001B62CC
|
|
[Token(Token = "0x6008160")]
|
|
[Address(RVA = "0x1C61B90", Offset = "0x1C60590", VA = "0x181C61B90")]
|
|
public static SecureRandom GetInstance(string algorithm, bool autoSeed)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (06008160)
|
|
|
|
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 1663
|
|
*/;
|
|
}
|
|
|
|
// Token: 0x06008161 RID: 33121 RVA: 0x001B8138 File Offset: 0x001B6338
|
|
[Token(Token = "0x6008161")]
|
|
[Address(RVA = "0x1C61D60", Offset = "0x1C60760", VA = "0x181C61D60")]
|
|
[Obsolete]
|
|
public static byte[] GetSeed(int length)
|
|
{
|
|
SecureRandom secureRandom = SecureRandom.master;
|
|
byte[] array = new byte[length];
|
|
double num = secureRandom.NextDouble();
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x06008162 RID: 33122 RVA: 0x001B8160 File Offset: 0x001B6360
|
|
[Token(Token = "0x6008162")]
|
|
[Address(RVA = "0x1C62740", Offset = "0x1C61140", VA = "0x181C62740")]
|
|
public SecureRandom()
|
|
{
|
|
DigestRandomGenerator digestRandomGenerator = SecureRandom.CreatePrng("SHA256", true);
|
|
int num = 0;
|
|
base..ctor(num);
|
|
this.generator = digestRandomGenerator;
|
|
}
|
|
|
|
// Token: 0x06008163 RID: 33123 RVA: 0x001B818C File Offset: 0x001B638C
|
|
[Token(Token = "0x6008163")]
|
|
[Address(RVA = "0x1C62630", Offset = "0x1C61030", VA = "0x181C62630")]
|
|
[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;
|
|
bool isChanged = ((IChangeTracking)this).IsChanged;
|
|
}
|
|
|
|
// Token: 0x06008164 RID: 33124 RVA: 0x001B81CC File Offset: 0x001B63CC
|
|
[Token(Token = "0x6008164")]
|
|
[Address(RVA = "0x1C62600", Offset = "0x1C61000", VA = "0x181C62600")]
|
|
public SecureRandom(IRandomGenerator generator)
|
|
{
|
|
int num = 0;
|
|
base..ctor(num);
|
|
this.generator = generator;
|
|
}
|
|
|
|
// Token: 0x06008165 RID: 33125 RVA: 0x001B81EC File Offset: 0x001B63EC
|
|
[Token(Token = "0x6008165")]
|
|
[Address(RVA = "0x1C618F0", Offset = "0x1C602F0", VA = "0x181C618F0", Slot = "10")]
|
|
public virtual byte[] GenerateSeed(int length)
|
|
{
|
|
SecureRandom secureRandom = SecureRandom.master;
|
|
byte[] array = new byte[length];
|
|
double num = secureRandom.NextDouble();
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x06008166 RID: 33126 RVA: 0x001B8214 File Offset: 0x001B6414
|
|
[Token(Token = "0x6008166")]
|
|
[Address(RVA = "0x1C624A0", Offset = "0x1C60EA0", VA = "0x181C624A0", Slot = "11")]
|
|
public virtual void SetSeed(byte[] seed)
|
|
{
|
|
IRandomGenerator randomGenerator = this.generator;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06008167 RID: 33127 RVA: 0x001B8230 File Offset: 0x001B6430
|
|
[Token(Token = "0x6008167")]
|
|
[Address(RVA = "0x1C623E0", Offset = "0x1C60DE0", VA = "0x181C623E0", Slot = "12")]
|
|
public virtual void SetSeed(long seed)
|
|
{
|
|
IRandomGenerator randomGenerator = this.generator;
|
|
int num = 0;
|
|
num += num;
|
|
num++;
|
|
randomGenerator.AddSeedMaterial(seed);
|
|
}
|
|
|
|
// Token: 0x06008168 RID: 33128 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x6008168")]
|
|
[Address(RVA = "0x1C623C0", Offset = "0x1C60DC0", VA = "0x181C623C0", Slot = "5")]
|
|
public override int Next()
|
|
{
|
|
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
|
|
}
|
|
|
|
// Token: 0x06008169 RID: 33129 RVA: 0x001B825C File Offset: 0x001B645C
|
|
[Token(Token = "0x6008169")]
|
|
[Address(RVA = "0x1C622D0", Offset = "0x1C60CD0", VA = "0x181C622D0", Slot = "7")]
|
|
public override int Next(int maxValue)
|
|
{
|
|
int num = maxValue - 1;
|
|
if (maxValue != num)
|
|
{
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// Token: 0x0600816A RID: 33130 RVA: 0x001B8284 File Offset: 0x001B6484
|
|
[Token(Token = "0x600816A")]
|
|
[Address(RVA = "0x1C621F0", Offset = "0x1C60BF0", VA = "0x181C621F0", Slot = "6")]
|
|
public override int Next(int minValue, int maxValue)
|
|
{
|
|
if (maxValue > minValue)
|
|
{
|
|
int num;
|
|
num += minValue;
|
|
return num;
|
|
}
|
|
return minValue;
|
|
}
|
|
|
|
// Token: 0x0600816B RID: 33131 RVA: 0x001B82A8 File Offset: 0x001B64A8
|
|
[Token(Token = "0x600816B")]
|
|
[Address(RVA = "0x1C61E60", Offset = "0x1C60860", VA = "0x181C61E60", Slot = "9")]
|
|
public override void NextBytes(byte[] buf)
|
|
{
|
|
IRandomGenerator randomGenerator = this.generator;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600816C RID: 33132 RVA: 0x001B82C4 File Offset: 0x001B64C4
|
|
[Token(Token = "0x600816C")]
|
|
[Address(RVA = "0x1C61EC0", Offset = "0x1C608C0", VA = "0x181C61EC0", Slot = "13")]
|
|
public virtual void NextBytes(byte[] buf, int off, int len)
|
|
{
|
|
IRandomGenerator randomGenerator = this.generator;
|
|
int num = 0;
|
|
if (num < off)
|
|
{
|
|
num += num;
|
|
num++;
|
|
}
|
|
randomGenerator.AddSeedMaterial(buf);
|
|
}
|
|
|
|
// Token: 0x0600816D RID: 33133 RVA: 0x001B82F4 File Offset: 0x001B64F4
|
|
[Token(Token = "0x600816D")]
|
|
[Address(RVA = "0x1C62010", Offset = "0x1C60A10", VA = "0x181C62010", Slot = "8")]
|
|
public override double NextDouble()
|
|
{
|
|
return Convert.ToDouble((ulong)this.NextInt());
|
|
}
|
|
|
|
// Token: 0x0600816E RID: 33134 RVA: 0x001B830C File Offset: 0x001B650C
|
|
[Token(Token = "0x600816E")]
|
|
[Address(RVA = "0x1C620C0", Offset = "0x1C60AC0", VA = "0x181C620C0", 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: 0x0600816F RID: 33135 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x600816F")]
|
|
[Address(RVA = "0x1C621A0", Offset = "0x1C60BA0", VA = "0x181C621A0", Slot = "15")]
|
|
public virtual long NextLong()
|
|
{
|
|
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
|
|
}
|
|
|
|
// Token: 0x06008170 RID: 33136 RVA: 0x001B833C File Offset: 0x001B653C
|
|
// Note: this type is marked as 'beforefieldinit'.
|
|
[Token(Token = "0x6008170")]
|
|
[Address(RVA = "0x1C62500", Offset = "0x1C60F00", VA = "0x181C62500")]
|
|
static SecureRandom()
|
|
{
|
|
CryptoApiRandomGenerator cryptoApiRandomGenerator = new CryptoApiRandomGenerator();
|
|
int num;
|
|
SecureRandom secureRandom = new SecureRandom(num);
|
|
num = 0;
|
|
secureRandom.generator = cryptoApiRandomGenerator;
|
|
SecureRandom.master = secureRandom;
|
|
}
|
|
|
|
// Token: 0x04005BA7 RID: 23463
|
|
[Token(Token = "0x4005BA7")]
|
|
private static long counter = Times.NanoTime();
|
|
|
|
// Token: 0x04005BA8 RID: 23464
|
|
[Token(Token = "0x4005BA8")]
|
|
private static readonly SecureRandom master;
|
|
|
|
// Token: 0x04005BA9 RID: 23465
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4005BA9")]
|
|
protected readonly IRandomGenerator generator;
|
|
|
|
// Token: 0x04005BAA RID: 23466
|
|
[Token(Token = "0x4005BAA")]
|
|
private static readonly double DoubleScale;
|
|
}
|
|
}
|