201 lines
8.0 KiB
C#
201 lines
8.0 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers
|
|
{
|
|
// Token: 0x020015C5 RID: 5573
|
|
[Token(Token = "0x20015C5")]
|
|
[StructLayout(3)]
|
|
public class DsaSigner : IDsaExt, IDsa
|
|
{
|
|
// Token: 0x060094EC RID: 38124 RVA: 0x0020EFCC File Offset: 0x0020D1CC
|
|
[Token(Token = "0x60094EC")]
|
|
[Address(RVA = "0x1E3B720", Offset = "0x1E3A120", VA = "0x181E3B720")]
|
|
public DsaSigner()
|
|
{
|
|
RandomDsaKCalculator randomDsaKCalculator = new RandomDsaKCalculator();
|
|
this.kCalculator = randomDsaKCalculator;
|
|
}
|
|
|
|
// Token: 0x060094ED RID: 38125 RVA: 0x0020EFEC File Offset: 0x0020D1EC
|
|
[Token(Token = "0x60094ED")]
|
|
[Address(RVA = "0x3C3A30", Offset = "0x3C2430", VA = "0x1803C3A30")]
|
|
public DsaSigner(IDsaKCalculator kCalculator)
|
|
{
|
|
this.kCalculator = kCalculator;
|
|
}
|
|
|
|
// Token: 0x170017D5 RID: 6101
|
|
// (get) Token: 0x060094EE RID: 38126 RVA: 0x0020F008 File Offset: 0x0020D208
|
|
[Token(Token = "0x170017D5")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x60094EE")]
|
|
[Address(RVA = "0x1E3B780", Offset = "0x1E3A180", VA = "0x181E3B780", Slot = "9")]
|
|
get
|
|
{
|
|
return "DSA";
|
|
}
|
|
}
|
|
|
|
// Token: 0x060094EF RID: 38127 RVA: 0x0020F01C File Offset: 0x0020D21C
|
|
[Token(Token = "0x60094EF")]
|
|
[Address(RVA = "0x1E3B210", Offset = "0x1E39C10", VA = "0x181E3B210", Slot = "10")]
|
|
public virtual void Init(bool forSigning, ICipherParameters parameters)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (060094EF)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers.DsaSigner::Init(System.Boolean,BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.ICipherParameters)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_5E:
|
|
stloc:InvalidKeyException(var_9_68, newobj:InvalidKeyException(InvalidKeyException::.ctor, ldstr:string("DSA 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: 0x170017D6 RID: 6102
|
|
// (get) Token: 0x060094F0 RID: 38128 RVA: 0x0020F094 File Offset: 0x0020D294
|
|
[Token(Token = "0x170017D6")]
|
|
public virtual BigInteger Order
|
|
{
|
|
[Token(Token = "0x60094F0")]
|
|
[Address(RVA = "0x1E3B7B0", Offset = "0x1E3A1B0", VA = "0x181E3B7B0", Slot = "11")]
|
|
get
|
|
{
|
|
return this.key.parameters.q;
|
|
}
|
|
}
|
|
|
|
// Token: 0x060094F1 RID: 38129 RVA: 0x0020F0B8 File Offset: 0x0020D2B8
|
|
[Token(Token = "0x60094F1")]
|
|
[Address(RVA = "0x1E3AE90", Offset = "0x1E39890", VA = "0x181E3AE90", Slot = "12")]
|
|
public virtual BigInteger[] GenerateSignature(byte[] message)
|
|
{
|
|
DsaParameters parameters;
|
|
BigInteger q;
|
|
int num;
|
|
for (;;)
|
|
{
|
|
parameters = this.key.parameters;
|
|
q = parameters.q;
|
|
DsaKeyParameters dsaKeyParameters = this.key;
|
|
if (dsaKeyParameters != 0)
|
|
{
|
|
num = 0;
|
|
if (dsaKeyParameters != 0)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
IDsaKCalculator dsaKCalculator = this.kCalculator;
|
|
IDsaKCalculator dsaKCalculator2 = this.kCalculator;
|
|
if (num == 0)
|
|
{
|
|
SecureRandom secureRandom = this.random;
|
|
}
|
|
IDsaKCalculator dsaKCalculator3 = this.kCalculator;
|
|
BigInteger g = parameters.g;
|
|
BigInteger bigInteger2;
|
|
BigInteger bigInteger = bigInteger2.Mod(q);
|
|
BigInteger bigInteger4;
|
|
BigInteger bigInteger5;
|
|
BigInteger bigInteger3 = bigInteger4.Multiply(bigInteger5).Mod(q);
|
|
BigInteger[] array = new BigInteger[2];
|
|
if (bigInteger != 0)
|
|
{
|
|
}
|
|
array[0] = bigInteger;
|
|
if (bigInteger3 != 0)
|
|
{
|
|
}
|
|
array[1] = bigInteger3;
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x060094F2 RID: 38130 RVA: 0x0020F164 File Offset: 0x0020D364
|
|
[Token(Token = "0x60094F2")]
|
|
[Address(RVA = "0x1E3B4F0", Offset = "0x1E39EF0", VA = "0x181E3B4F0", Slot = "13")]
|
|
public virtual bool VerifySignature(byte[] message, BigInteger r, BigInteger s)
|
|
{
|
|
DsaParameters parameters = this.key.parameters;
|
|
BigInteger q = parameters.q;
|
|
if (r.sign > 0 && q.CompareTo(r) > 0 && s.sign > 0 && q.CompareTo(s) > 0)
|
|
{
|
|
BigInteger bigInteger = s.ModInverse(q);
|
|
BigInteger bigInteger3;
|
|
BigInteger bigInteger2 = bigInteger3.Mod(q);
|
|
BigInteger bigInteger4 = r.Multiply(bigInteger).Mod(q);
|
|
BigInteger g = parameters.g;
|
|
BigInteger p = parameters.p;
|
|
BigInteger bigInteger5 = g.ModPow(bigInteger2, p);
|
|
int nBitLength = bigInteger5.nBitLength;
|
|
BigInteger bigInteger7;
|
|
BigInteger bigInteger6 = bigInteger5.Multiply(bigInteger7).Mod(p).Mod(q);
|
|
}
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x060094F3 RID: 38131 RVA: 0x0020F214 File Offset: 0x0020D414
|
|
[Token(Token = "0x60094F3")]
|
|
[Address(RVA = "0x1E3ADC0", Offset = "0x1E397C0", VA = "0x181E3ADC0", Slot = "14")]
|
|
protected virtual BigInteger CalculateE(BigInteger n, byte[] message)
|
|
{
|
|
int num = 0;
|
|
int num2 = n.BitLength;
|
|
int length = message.Length;
|
|
num += num2;
|
|
num2 = Math.Min(length, num);
|
|
int num3;
|
|
BigInteger bigInteger = new BigInteger(1, message, num3, num2);
|
|
num3 = 0;
|
|
return bigInteger;
|
|
}
|
|
|
|
// Token: 0x060094F4 RID: 38132 RVA: 0x0020F254 File Offset: 0x0020D454
|
|
[Token(Token = "0x60094F4")]
|
|
[Address(RVA = "0x1E3B1A0", Offset = "0x1E39BA0", VA = "0x181E3B1A0", Slot = "15")]
|
|
protected virtual SecureRandom InitSecureRandom(bool needed, SecureRandom provided)
|
|
{
|
|
do
|
|
{
|
|
if (!needed)
|
|
{
|
|
}
|
|
}
|
|
while (provided != 0);
|
|
return new SecureRandom();
|
|
}
|
|
|
|
// Token: 0x04006259 RID: 25177
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x4006259")]
|
|
protected readonly IDsaKCalculator kCalculator;
|
|
|
|
// Token: 0x0400625A RID: 25178
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x400625A")]
|
|
protected DsaKeyParameters key;
|
|
|
|
// Token: 0x0400625B RID: 25179
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x400625B")]
|
|
protected SecureRandom random;
|
|
}
|
|
}
|