277 lines
12 KiB
C#
277 lines
12 KiB
C#
using System;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math.EC;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Multiplier;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers
|
|
{
|
|
// Token: 0x02001BA3 RID: 7075
|
|
[Token(Token = "0x2001BA3")]
|
|
public class ECDsaSigner : IDsaExt, IDsa
|
|
{
|
|
// Token: 0x0600B0CF RID: 45263 RVA: 0x00266900 File Offset: 0x00264B00
|
|
[Token(Token = "0x600B0CF")]
|
|
[Address(RVA = "0x1893E00", Offset = "0x1892C00", VA = "0x181893E00")]
|
|
public ECDsaSigner()
|
|
{
|
|
RandomDsaKCalculator randomDsaKCalculator = new RandomDsaKCalculator();
|
|
this.kCalculator = randomDsaKCalculator;
|
|
}
|
|
|
|
// Token: 0x0600B0D0 RID: 45264 RVA: 0x00266920 File Offset: 0x00264B20
|
|
[Token(Token = "0x600B0D0")]
|
|
[Address(RVA = "0x3FFB80", Offset = "0x3FE980", VA = "0x1803FFB80")]
|
|
public ECDsaSigner(IDsaKCalculator kCalculator)
|
|
{
|
|
this.kCalculator = kCalculator;
|
|
}
|
|
|
|
// Token: 0x17001BD8 RID: 7128
|
|
// (get) Token: 0x0600B0D1 RID: 45265 RVA: 0x0026693C File Offset: 0x00264B3C
|
|
[Token(Token = "0x17001BD8")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x600B0D1")]
|
|
[Address(RVA = "0x1893E60", Offset = "0x1892C60", VA = "0x181893E60", Slot = "9")]
|
|
get
|
|
{
|
|
return "ECDSA";
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B0D2 RID: 45266 RVA: 0x00266950 File Offset: 0x00264B50
|
|
[Token(Token = "0x600B0D2")]
|
|
[Address(RVA = "0x18936D0", Offset = "0x18924D0", VA = "0x1818936D0", Slot = "10")]
|
|
public virtual void Init(bool forSigning, ICipherParameters parameters)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B0D2)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers.ECDsaSigner::Init(System.Boolean,BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.ICipherParameters)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_75:
|
|
stloc:InvalidKeyException(var_11_7F, newobj:InvalidKeyException(InvalidKeyException::.ctor, ldstr:string("EC public key required for verification")))
|
|
}
|
|
|
|
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: 0x17001BD9 RID: 7129
|
|
// (get) Token: 0x0600B0D3 RID: 45267 RVA: 0x002669E0 File Offset: 0x00264BE0
|
|
[Token(Token = "0x17001BD9")]
|
|
public virtual BigInteger Order
|
|
{
|
|
[Token(Token = "0x600B0D3")]
|
|
[Address(RVA = "0x1893E90", Offset = "0x1892C90", VA = "0x181893E90", Slot = "11")]
|
|
get
|
|
{
|
|
return this.key.parameters.n;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B0D4 RID: 45268 RVA: 0x00266A04 File Offset: 0x00264C04
|
|
[Token(Token = "0x600B0D4")]
|
|
[Address(RVA = "0x1893110", Offset = "0x1891F10", VA = "0x181893110", Slot = "12")]
|
|
public virtual BigInteger[] GenerateSignature(byte[] message)
|
|
{
|
|
BigInteger n;
|
|
ECKeyParameters eckeyParameters;
|
|
do
|
|
{
|
|
n = this.key.parameters.n;
|
|
eckeyParameters = this.key;
|
|
}
|
|
while (eckeyParameters == 0 || eckeyParameters == 0);
|
|
IDsaKCalculator dsaKCalculator = this.kCalculator;
|
|
IDsaKCalculator dsaKCalculator2 = this.kCalculator;
|
|
if (eckeyParameters == 0)
|
|
{
|
|
SecureRandom secureRandom = this.random;
|
|
}
|
|
int num = 0;
|
|
IDsaKCalculator dsaKCalculator3 = this.kCalculator;
|
|
if (num < dsaKCalculator2)
|
|
{
|
|
num += num;
|
|
num++;
|
|
}
|
|
uint num2;
|
|
if (num < (int)num2)
|
|
{
|
|
num += num;
|
|
num++;
|
|
}
|
|
char c;
|
|
string text = c.ToString();
|
|
BigInteger bigInteger;
|
|
while (bigInteger.sign == 0)
|
|
{
|
|
}
|
|
BigInteger bigInteger3;
|
|
BigInteger bigInteger4;
|
|
BigInteger bigInteger2 = bigInteger3.Multiply(bigInteger4).Mod(n);
|
|
while (bigInteger2.sign == 0)
|
|
{
|
|
}
|
|
return new BigInteger[] { bigInteger, bigInteger2 };
|
|
}
|
|
|
|
// Token: 0x0600B0D5 RID: 45269 RVA: 0x00266AD8 File Offset: 0x00264CD8
|
|
[Token(Token = "0x600B0D5")]
|
|
[Address(RVA = "0x18939B0", Offset = "0x18927B0", VA = "0x1818939B0", Slot = "13")]
|
|
public virtual bool VerifySignature(byte[] message, BigInteger r, BigInteger s)
|
|
{
|
|
BigInteger n = this.key.parameters.n;
|
|
int num = r.CompareTo(n);
|
|
int num2 = s.CompareTo(n);
|
|
BigInteger bigInteger = s.ModInverse(n);
|
|
BigInteger bigInteger3;
|
|
BigInteger bigInteger2 = bigInteger3.Mod(n);
|
|
BigInteger bigInteger4 = r.Multiply(bigInteger);
|
|
int num3 = 0;
|
|
BigInteger bigInteger5 = bigInteger4.Mod(n);
|
|
ECPoint ecpoint = ECAlgorithms.SumOfTwoMultiplies(this.key.parameters.g, bigInteger2, num3, bigInteger5);
|
|
if (!ecpoint.IsInfinity)
|
|
{
|
|
bool flag = ecpoint.SatisfiesOrder();
|
|
if (flag && flag)
|
|
{
|
|
BigInteger eight = ECDsaSigner.Eight;
|
|
ECMultiplier ecmultiplier = this.CreateBasePointMultiplier();
|
|
if (ecmultiplier != 0 && ecmultiplier == 0)
|
|
{
|
|
ECFieldElement affineYCoord = ecpoint.AffineYCoord;
|
|
if (flag.GetTypeCode() != TypeCode.Empty)
|
|
{
|
|
int num4 = flag.CompareTo(r);
|
|
bool flag2;
|
|
if (!flag2)
|
|
{
|
|
BigInteger bigInteger6 = r.Add(n);
|
|
}
|
|
return true;
|
|
}
|
|
goto IL_DD;
|
|
}
|
|
}
|
|
bool flag3 = ecpoint.IsNormalized();
|
|
sbyte b;
|
|
string text = b.ToString();
|
|
}
|
|
IL_DD:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600B0D6 RID: 45270 RVA: 0x00266BC8 File Offset: 0x00264DC8
|
|
[Token(Token = "0x600B0D6")]
|
|
[Address(RVA = "0x1893000", Offset = "0x1891E00", VA = "0x181893000", Slot = "14")]
|
|
protected virtual BigInteger CalculateE(BigInteger n, byte[] message)
|
|
{
|
|
int num = message.Length;
|
|
BigInteger bigInteger = new BigInteger(1, message);
|
|
if (n.BitLength < num)
|
|
{
|
|
int bitLength = n.BitLength;
|
|
num -= bitLength;
|
|
BigInteger bigInteger2 = bigInteger.ShiftRight(num);
|
|
}
|
|
return bigInteger;
|
|
}
|
|
|
|
// Token: 0x0600B0D7 RID: 45271 RVA: 0x00266C08 File Offset: 0x00264E08
|
|
[Token(Token = "0x600B0D7")]
|
|
[Address(RVA = "0x18930C0", Offset = "0x1891EC0", VA = "0x1818930C0", Slot = "15")]
|
|
protected virtual ECMultiplier CreateBasePointMultiplier()
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B0D7)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling BestHTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Multiplier.ECMultiplier BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers.ECDsaSigner::CreateBasePointMultiplier()
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
Block_0:
|
|
stloc:FixedPointCombMultiplier(var_0_05, newobj:FixedPointCombMultiplier(FixedPointCombMultiplier::.ctor))
|
|
}
|
|
|
|
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: 0x0600B0D8 RID: 45272 RVA: 0x00266C1C File Offset: 0x00264E1C
|
|
[Token(Token = "0x600B0D8")]
|
|
[Address(RVA = "0x18935B0", Offset = "0x18923B0", VA = "0x1818935B0", Slot = "16")]
|
|
protected virtual ECFieldElement GetDenominator(int coordinateSystem, ECPoint p)
|
|
{
|
|
if (coordinateSystem <= 6)
|
|
{
|
|
BigInteger bigInteger = p.YCoord.ToBigInteger();
|
|
bool flag = p.SatisfiesCurveEquation();
|
|
}
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600B0D9 RID: 45273 RVA: 0x00266C48 File Offset: 0x00264E48
|
|
[Token(Token = "0x600B0D9")]
|
|
[Address(RVA = "0x1893660", Offset = "0x1892460", VA = "0x181893660", Slot = "17")]
|
|
protected virtual SecureRandom InitSecureRandom(bool needed, SecureRandom provided)
|
|
{
|
|
do
|
|
{
|
|
if (!needed)
|
|
{
|
|
}
|
|
}
|
|
while (provided != 0);
|
|
return new SecureRandom();
|
|
}
|
|
|
|
// Token: 0x0600B0DA RID: 45274 RVA: 0x00266C64 File Offset: 0x00264E64
|
|
// Note: this type is marked as 'beforefieldinit'.
|
|
[Token(Token = "0x600B0DA")]
|
|
[Address(RVA = "0x1893DA0", Offset = "0x1892BA0", VA = "0x181893DA0")]
|
|
static ECDsaSigner()
|
|
{
|
|
BigInteger bigInteger;
|
|
ECDsaSigner.Eight = bigInteger;
|
|
}
|
|
|
|
// Token: 0x0400709F RID: 28831
|
|
[Token(Token = "0x400709F")]
|
|
private static readonly BigInteger Eight;
|
|
|
|
// Token: 0x040070A0 RID: 28832
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x40070A0")]
|
|
protected readonly IDsaKCalculator kCalculator;
|
|
|
|
// Token: 0x040070A1 RID: 28833
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x40070A1")]
|
|
protected ECKeyParameters key;
|
|
|
|
// Token: 0x040070A2 RID: 28834
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x40070A2")]
|
|
protected SecureRandom random;
|
|
}
|
|
}
|