313 lines
14 KiB
C#
313 lines
14 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
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: 0x02001A93 RID: 6803
|
|
[Token(Token = "0x2001A93")]
|
|
public class SecureRandom : Random
|
|
{
|
|
// Token: 0x0600A103 RID: 41219 RVA: 0x00218634 File Offset: 0x00216834
|
|
[Token(Token = "0x600A103")]
|
|
[Address(RVA = "0x5E7DD0", Offset = "0x5E6DD0", VA = "0x1805E7DD0")]
|
|
private static long NextCounterValue()
|
|
{
|
|
long num;
|
|
return num;
|
|
}
|
|
|
|
// Token: 0x170019A4 RID: 6564
|
|
// (get) Token: 0x0600A104 RID: 41220 RVA: 0x00218644 File Offset: 0x00216844
|
|
[Token(Token = "0x170019A4")]
|
|
private static SecureRandom Master
|
|
{
|
|
[Token(Token = "0x600A104")]
|
|
[Address(RVA = "0x5E85E0", Offset = "0x5E75E0", VA = "0x1805E85E0")]
|
|
get
|
|
{
|
|
return SecureRandom.master;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600A105 RID: 41221 RVA: 0x00218658 File Offset: 0x00216858
|
|
[Token(Token = "0x600A105")]
|
|
[Address(RVA = "0x5E7600", Offset = "0x5E6600", VA = "0x1805E7600")]
|
|
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: 0x0600A106 RID: 41222 RVA: 0x00218690 File Offset: 0x00216890
|
|
[Token(Token = "0x600A106")]
|
|
[Address(RVA = "0x5E7B80", Offset = "0x5E6B80", VA = "0x1805E7B80")]
|
|
public static byte[] GetNextBytes(SecureRandom secureRandom, int length)
|
|
{
|
|
byte[] array = new byte[length];
|
|
double num = secureRandom.NextDouble();
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x0600A107 RID: 41223 RVA: 0x002186B4 File Offset: 0x002168B4
|
|
[Token(Token = "0x600A107")]
|
|
[Address(RVA = "0x5E7880", Offset = "0x5E6880", VA = "0x1805E7880")]
|
|
public static SecureRandom GetInstance(string algorithm)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600A107)
|
|
|
|
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: 0x0600A108 RID: 41224 RVA: 0x00218724 File Offset: 0x00216924
|
|
[Token(Token = "0x600A108")]
|
|
[Address(RVA = "0x5E7A20", Offset = "0x5E6A20", VA = "0x1805E7A20")]
|
|
public static SecureRandom GetInstance(string algorithm, bool autoSeed)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600A108)
|
|
|
|
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: 0x0600A109 RID: 41225 RVA: 0x00218790 File Offset: 0x00216990
|
|
[Token(Token = "0x600A109")]
|
|
[Address(RVA = "0x5E7BF0", Offset = "0x5E6BF0", VA = "0x1805E7BF0")]
|
|
[Obsolete]
|
|
public static byte[] GetSeed(int length)
|
|
{
|
|
SecureRandom secureRandom = SecureRandom.master;
|
|
byte[] array = new byte[length];
|
|
double num = secureRandom.NextDouble();
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x0600A10A RID: 41226 RVA: 0x002187B8 File Offset: 0x002169B8
|
|
[Token(Token = "0x600A10A")]
|
|
[Address(RVA = "0x5E8560", Offset = "0x5E7560", VA = "0x1805E8560")]
|
|
public SecureRandom()
|
|
{
|
|
DigestRandomGenerator digestRandomGenerator = SecureRandom.CreatePrng("SHA256", true);
|
|
int num = 0;
|
|
base..ctor(num);
|
|
this.generator = digestRandomGenerator;
|
|
}
|
|
|
|
// Token: 0x0600A10B RID: 41227 RVA: 0x002187E4 File Offset: 0x002169E4
|
|
[Token(Token = "0x600A10B")]
|
|
[Address(RVA = "0x5E8450", Offset = "0x5E7450", VA = "0x1805E8450")]
|
|
[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;
|
|
((IEditableObject)this).BeginEdit();
|
|
}
|
|
|
|
// Token: 0x0600A10C RID: 41228 RVA: 0x00218820 File Offset: 0x00216A20
|
|
[Token(Token = "0x600A10C")]
|
|
[Address(RVA = "0x5E8420", Offset = "0x5E7420", VA = "0x1805E8420")]
|
|
public SecureRandom(IRandomGenerator generator)
|
|
{
|
|
int num = 0;
|
|
base..ctor(num);
|
|
this.generator = generator;
|
|
}
|
|
|
|
// Token: 0x0600A10D RID: 41229 RVA: 0x00218840 File Offset: 0x00216A40
|
|
[Token(Token = "0x600A10D")]
|
|
[Address(RVA = "0x5E7780", Offset = "0x5E6780", VA = "0x1805E7780", Slot = "10")]
|
|
public virtual byte[] GenerateSeed(int length)
|
|
{
|
|
SecureRandom secureRandom = SecureRandom.master;
|
|
byte[] array = new byte[length];
|
|
double num = secureRandom.NextDouble();
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x0600A10E RID: 41230 RVA: 0x00218868 File Offset: 0x00216A68
|
|
[Token(Token = "0x600A10E")]
|
|
[Address(RVA = "0x5E82C0", Offset = "0x5E72C0", VA = "0x1805E82C0", Slot = "11")]
|
|
public virtual void SetSeed(byte[] seed)
|
|
{
|
|
IRandomGenerator randomGenerator = this.generator;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600A10F RID: 41231 RVA: 0x00218884 File Offset: 0x00216A84
|
|
[Token(Token = "0x600A10F")]
|
|
[Address(RVA = "0x5E8200", Offset = "0x5E7200", VA = "0x1805E8200", Slot = "12")]
|
|
public virtual void SetSeed(long seed)
|
|
{
|
|
IRandomGenerator randomGenerator = this.generator;
|
|
int num = 0;
|
|
num += num;
|
|
num++;
|
|
randomGenerator.AddSeedMaterial(seed);
|
|
}
|
|
|
|
// Token: 0x0600A110 RID: 41232 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x600A110")]
|
|
[Address(RVA = "0x5E81E0", Offset = "0x5E71E0", VA = "0x1805E81E0", Slot = "5")]
|
|
public override int Next()
|
|
{
|
|
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
|
|
}
|
|
|
|
// Token: 0x0600A111 RID: 41233 RVA: 0x002188B0 File Offset: 0x00216AB0
|
|
[Token(Token = "0x600A111")]
|
|
[Address(RVA = "0x5E80F0", Offset = "0x5E70F0", VA = "0x1805E80F0", Slot = "7")]
|
|
public override int Next(int maxValue)
|
|
{
|
|
int num = maxValue - 1;
|
|
if (maxValue != num)
|
|
{
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// Token: 0x0600A112 RID: 41234 RVA: 0x002188D8 File Offset: 0x00216AD8
|
|
[Token(Token = "0x600A112")]
|
|
[Address(RVA = "0x5E8010", Offset = "0x5E7010", VA = "0x1805E8010", Slot = "6")]
|
|
public override int Next(int minValue, int maxValue)
|
|
{
|
|
if (maxValue > minValue)
|
|
{
|
|
int num;
|
|
num += minValue;
|
|
return num;
|
|
}
|
|
return minValue;
|
|
}
|
|
|
|
// Token: 0x0600A113 RID: 41235 RVA: 0x002188FC File Offset: 0x00216AFC
|
|
[Token(Token = "0x600A113")]
|
|
[Address(RVA = "0x5E7CF0", Offset = "0x5E6CF0", VA = "0x1805E7CF0", Slot = "9")]
|
|
public override void NextBytes(byte[] buf)
|
|
{
|
|
IRandomGenerator randomGenerator = this.generator;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600A114 RID: 41236 RVA: 0x00218918 File Offset: 0x00216B18
|
|
[Token(Token = "0x600A114")]
|
|
[Address(RVA = "0x5E7D50", Offset = "0x5E6D50", VA = "0x1805E7D50", Slot = "13")]
|
|
public virtual void NextBytes(byte[] buf, int off, int len)
|
|
{
|
|
IRandomGenerator randomGenerator = this.generator;
|
|
}
|
|
|
|
// Token: 0x0600A115 RID: 41237 RVA: 0x00218934 File Offset: 0x00216B34
|
|
[Token(Token = "0x600A115")]
|
|
[Address(RVA = "0x5E7E30", Offset = "0x5E6E30", VA = "0x1805E7E30", Slot = "8")]
|
|
public override double NextDouble()
|
|
{
|
|
return Convert.ToDouble((ulong)this.NextInt());
|
|
}
|
|
|
|
// Token: 0x0600A116 RID: 41238 RVA: 0x0021894C File Offset: 0x00216B4C
|
|
[Token(Token = "0x600A116")]
|
|
[Address(RVA = "0x5E7EE0", Offset = "0x5E6EE0", VA = "0x1805E7EE0", 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: 0x0600A117 RID: 41239 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x600A117")]
|
|
[Address(RVA = "0x5E7FC0", Offset = "0x5E6FC0", VA = "0x1805E7FC0", Slot = "15")]
|
|
public virtual long NextLong()
|
|
{
|
|
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
|
|
}
|
|
|
|
// Token: 0x0600A118 RID: 41240 RVA: 0x0021897C File Offset: 0x00216B7C
|
|
// Note: this type is marked as 'beforefieldinit'.
|
|
[Token(Token = "0x600A118")]
|
|
[Address(RVA = "0x5E8320", Offset = "0x5E7320", VA = "0x1805E8320")]
|
|
static SecureRandom()
|
|
{
|
|
CryptoApiRandomGenerator cryptoApiRandomGenerator = new CryptoApiRandomGenerator();
|
|
int num;
|
|
SecureRandom secureRandom = new SecureRandom(num);
|
|
num = 0;
|
|
secureRandom.generator = cryptoApiRandomGenerator;
|
|
SecureRandom.master = secureRandom;
|
|
}
|
|
|
|
// Token: 0x04006BA3 RID: 27555
|
|
[Token(Token = "0x4006BA3")]
|
|
private static long counter = Times.NanoTime();
|
|
|
|
// Token: 0x04006BA4 RID: 27556
|
|
[Token(Token = "0x4006BA4")]
|
|
private static readonly SecureRandom master;
|
|
|
|
// Token: 0x04006BA5 RID: 27557
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4006BA5")]
|
|
protected readonly IRandomGenerator generator;
|
|
|
|
// Token: 0x04006BA6 RID: 27558
|
|
[Token(Token = "0x4006BA6")]
|
|
private static readonly double DoubleScale;
|
|
}
|
|
}
|