scripts
This commit is contained in:
@@ -0,0 +1,367 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Digests;
|
||||
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.Math.Field;
|
||||
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
|
||||
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Encoders;
|
||||
using Cpp2IlInjected;
|
||||
|
||||
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers
|
||||
{
|
||||
// Token: 0x020015DE RID: 5598
|
||||
[Token(Token = "0x20015DE")]
|
||||
[StructLayout(3)]
|
||||
public class SM2Signer : ISigner
|
||||
{
|
||||
// Token: 0x060095B8 RID: 38328 RVA: 0x0021316C File Offset: 0x0021136C
|
||||
[Token(Token = "0x60095B8")]
|
||||
[Address(RVA = "0x1E4BAD0", Offset = "0x1E4A4D0", VA = "0x181E4BAD0")]
|
||||
public SM2Signer()
|
||||
{
|
||||
RandomDsaKCalculator randomDsaKCalculator = new RandomDsaKCalculator();
|
||||
this.kCalculator = randomDsaKCalculator;
|
||||
SM3Digest sm3Digest = new SM3Digest();
|
||||
this.digest = sm3Digest;
|
||||
base..ctor();
|
||||
this.encoding = typeof(StandardDsaEncoding).TypeHandle;
|
||||
}
|
||||
|
||||
// Token: 0x060095B9 RID: 38329 RVA: 0x002131A4 File Offset: 0x002113A4
|
||||
[Token(Token = "0x60095B9")]
|
||||
[Address(RVA = "0x1E4BB80", Offset = "0x1E4A580", VA = "0x181E4BB80")]
|
||||
public SM2Signer(IDsaEncoding encoding)
|
||||
{
|
||||
RandomDsaKCalculator randomDsaKCalculator = new RandomDsaKCalculator();
|
||||
this.kCalculator = randomDsaKCalculator;
|
||||
SM3Digest sm3Digest = new SM3Digest();
|
||||
this.digest = sm3Digest;
|
||||
base..ctor();
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
// Token: 0x170017ED RID: 6125
|
||||
// (get) Token: 0x060095BA RID: 38330 RVA: 0x002131D8 File Offset: 0x002113D8
|
||||
[Token(Token = "0x170017ED")]
|
||||
public virtual string AlgorithmName
|
||||
{
|
||||
[Token(Token = "0x60095BA")]
|
||||
[Address(RVA = "0x1E4BC10", Offset = "0x1E4A610", VA = "0x181E4BC10", Slot = "11")]
|
||||
get
|
||||
{
|
||||
return "SM2Sign";
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060095BB RID: 38331 RVA: 0x002131EC File Offset: 0x002113EC
|
||||
[Token(Token = "0x60095BB")]
|
||||
[Address(RVA = "0x1E4B0C0", Offset = "0x1E49AC0", VA = "0x181E4B0C0", Slot = "12")]
|
||||
public virtual void Init(bool forSigning, ICipherParameters parameters)
|
||||
{
|
||||
byte[] array;
|
||||
ECKeyParameters eckeyParameters;
|
||||
for (;;)
|
||||
{
|
||||
if (parameters == 0 || parameters == 0 || (parameters != 0 && parameters != 0 && parameters != 0 && parameters != 0))
|
||||
{
|
||||
array = Hex.Decode("31323334353637383132333435363738");
|
||||
if (!forSigning)
|
||||
{
|
||||
if (parameters == 0)
|
||||
{
|
||||
}
|
||||
int num = 0;
|
||||
if (parameters == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
this.ecKey = parameters;
|
||||
this.ecParams = num;
|
||||
if (parameters == 0 || parameters == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
int num2;
|
||||
if (parameters != 0)
|
||||
{
|
||||
if ((parameters == 0 && parameters == 0) || parameters == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
num2 = 0;
|
||||
this.ecParams = num2;
|
||||
IDsaKCalculator dsaKCalculator = this.kCalculator;
|
||||
}
|
||||
int num3 = 0;
|
||||
this.ecKey = num3;
|
||||
IDsaKCalculator dsaKCalculator2 = this.kCalculator;
|
||||
this.ecParams = num2;
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
ECDomainParameters ecdomainParameters = this.ecParams;
|
||||
eckeyParameters = this.ecKey;
|
||||
if (eckeyParameters != 0 && eckeyParameters != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.pubPoint = eckeyParameters;
|
||||
SM3Digest sm3Digest = this.digest;
|
||||
byte[] array2 = this.GetZ(array);
|
||||
this.z = array2;
|
||||
SM3Digest sm3Digest2 = this.digest;
|
||||
int length = array2.Length;
|
||||
int num4 = 0;
|
||||
sm3Digest2.BlockUpdate(array2, num4, length);
|
||||
}
|
||||
|
||||
// Token: 0x060095BC RID: 38332 RVA: 0x00213318 File Offset: 0x00211518
|
||||
[Token(Token = "0x60095BC")]
|
||||
[Address(RVA = "0x1E4B700", Offset = "0x1E4A100", VA = "0x181E4B700", Slot = "13")]
|
||||
public virtual void Update(byte b)
|
||||
{
|
||||
this.digest.Update(b);
|
||||
}
|
||||
|
||||
// Token: 0x060095BD RID: 38333 RVA: 0x00213338 File Offset: 0x00211538
|
||||
[Token(Token = "0x60095BD")]
|
||||
[Address(RVA = "0x1E4A810", Offset = "0x1E49210", VA = "0x181E4A810", Slot = "14")]
|
||||
public virtual void BlockUpdate(byte[] buf, int off, int len)
|
||||
{
|
||||
this.digest.BlockUpdate(buf, off, len);
|
||||
}
|
||||
|
||||
// Token: 0x060095BE RID: 38334 RVA: 0x0021335C File Offset: 0x0021155C
|
||||
[Token(Token = "0x60095BE")]
|
||||
[Address(RVA = "0x1E4B720", Offset = "0x1E4A120", VA = "0x181E4B720", Slot = "15")]
|
||||
public virtual bool VerifySignature(byte[] signature)
|
||||
{
|
||||
IDsaEncoding dsaEncoding = this.encoding;
|
||||
byte[] seed = this.ecParams.seed;
|
||||
bool flag;
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x060095BF RID: 38335 RVA: 0x002133A0 File Offset: 0x002115A0
|
||||
[Token(Token = "0x60095BF")]
|
||||
[Address(RVA = "0x1E4B6A0", Offset = "0x1E4A0A0", VA = "0x181E4B6A0", Slot = "16")]
|
||||
public virtual void Reset()
|
||||
{
|
||||
if (this.z != (ulong)0L)
|
||||
{
|
||||
SM3Digest sm3Digest = this.digest;
|
||||
byte[] array = this.z;
|
||||
SM3Digest sm3Digest2 = this.digest;
|
||||
int length = array.Length;
|
||||
int num = 0;
|
||||
sm3Digest2.BlockUpdate(array, num, length);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060095C0 RID: 38336 RVA: 0x002133E8 File Offset: 0x002115E8
|
||||
[Token(Token = "0x60095C0")]
|
||||
[Address(RVA = "0x1E4A8F0", Offset = "0x1E492F0", VA = "0x181E4A8F0", Slot = "17")]
|
||||
public virtual byte[] GenerateSignature()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
byte[] array = DigestUtilities.DoFinal(this.digest);
|
||||
BigInteger n = this.ecParams.n;
|
||||
ECKeyParameters eckeyParameters = this.ecKey;
|
||||
if ("{il2cpp array field local3->}" == typeof(ECPrivateKeyParameters).TypeHandle)
|
||||
{
|
||||
}
|
||||
if (eckeyParameters != 0)
|
||||
{
|
||||
int num = 0;
|
||||
if (eckeyParameters != 0)
|
||||
{
|
||||
int num2 = 0;
|
||||
IDsaKCalculator dsaKCalculator = this.kCalculator;
|
||||
if (num2 < num)
|
||||
{
|
||||
num2 += num2;
|
||||
num2++;
|
||||
}
|
||||
ECDomainParameters ecdomainParameters = this.ecParams;
|
||||
int num3 = 0;
|
||||
uint num4;
|
||||
if (num3 < (int)num4)
|
||||
{
|
||||
num3 += num3;
|
||||
num3++;
|
||||
}
|
||||
char c;
|
||||
string text = c.ToString();
|
||||
BigInteger bigInteger2;
|
||||
BigInteger bigInteger = bigInteger2.Mod(n);
|
||||
while (bigInteger.sign == 0)
|
||||
{
|
||||
}
|
||||
if (bigInteger.Add(num2) == 0)
|
||||
{
|
||||
BigInteger one = BigInteger.One;
|
||||
BigInteger bigInteger4;
|
||||
BigInteger bigInteger3 = bigInteger4.ModInverse(n);
|
||||
BigInteger bigInteger5 = bigInteger.Multiply(n);
|
||||
BigInteger bigInteger7;
|
||||
BigInteger bigInteger6 = bigInteger7.Mod(n);
|
||||
if (bigInteger3.Multiply(bigInteger6).Mod(n).sign != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
IDsaEncoding dsaEncoding = this.encoding;
|
||||
ECDomainParameters ecdomainParameters2 = this.ecParams;
|
||||
throw new NullReferenceException();
|
||||
}
|
||||
|
||||
// Token: 0x060095C1 RID: 38337 RVA: 0x002134FC File Offset: 0x002116FC
|
||||
[Token(Token = "0x60095C1")]
|
||||
[Address(RVA = "0x1E4B810", Offset = "0x1E4A210", VA = "0x181E4B810")]
|
||||
private bool VerifySignature(BigInteger r, BigInteger s)
|
||||
{
|
||||
BigInteger n = this.ecParams.n;
|
||||
BigInteger one = BigInteger.One;
|
||||
int num = r.CompareTo(one);
|
||||
int num2 = r.CompareTo(n);
|
||||
BigInteger one2 = BigInteger.One;
|
||||
int num3 = s.CompareTo(one2);
|
||||
int num4 = s.CompareTo(n);
|
||||
byte[] array = DigestUtilities.DoFinal(this.digest);
|
||||
byte[] array2 = this.GenerateSignature();
|
||||
BigInteger bigInteger = r.Add(s);
|
||||
int num5 = 0;
|
||||
BigInteger bigInteger2 = bigInteger.Mod(n);
|
||||
if (bigInteger2.sign != 0)
|
||||
{
|
||||
bool flag = ECAlgorithms.SumOfTwoMultiplies(this.ecParams.g, s, num5, bigInteger2).IsNormalized();
|
||||
bool flag2;
|
||||
if (!flag2)
|
||||
{
|
||||
sbyte b;
|
||||
string text = b.ToString();
|
||||
BigInteger bigInteger4;
|
||||
BigInteger bigInteger3 = bigInteger4.Mod(n);
|
||||
}
|
||||
}
|
||||
throw new NullReferenceException();
|
||||
}
|
||||
|
||||
// Token: 0x060095C2 RID: 38338 RVA: 0x002135B4 File Offset: 0x002117B4
|
||||
[Token(Token = "0x60095C2")]
|
||||
[Address(RVA = "0x1E4AE50", Offset = "0x1E49850", VA = "0x181E4AE50")]
|
||||
private byte[] GetZ(byte[] userID)
|
||||
{
|
||||
SM3Digest sm3Digest = this.digest;
|
||||
int length = userID.Length;
|
||||
IFiniteField field = this.ecParams.curve.Field;
|
||||
ECDomainParameters ecdomainParameters = this.ecParams;
|
||||
SM3Digest sm3Digest2 = this.digest;
|
||||
ECFieldElement a = ecdomainParameters.curve.A;
|
||||
this.AddFieldElement(sm3Digest2, a);
|
||||
int curveCoordinateSystem = this.ecParams.g.CurveCoordinateSystem;
|
||||
ECDomainParameters ecdomainParameters2 = this.ecParams;
|
||||
SM3Digest sm3Digest3 = this.digest;
|
||||
ECFieldElement affineXCoord = ecdomainParameters2.g.AffineXCoord;
|
||||
this.AddFieldElement(sm3Digest3, affineXCoord);
|
||||
int curveCoordinateSystem2 = this.pubPoint.CurveCoordinateSystem;
|
||||
ECPoint ecpoint = this.pubPoint;
|
||||
SM3Digest sm3Digest4 = this.digest;
|
||||
ECFieldElement affineXCoord2 = ecpoint.AffineXCoord;
|
||||
this.AddFieldElement(sm3Digest4, affineXCoord2);
|
||||
return DigestUtilities.DoFinal(this.digest);
|
||||
}
|
||||
|
||||
// Token: 0x060095C3 RID: 38339 RVA: 0x00213684 File Offset: 0x00211884
|
||||
[Token(Token = "0x60095C3")]
|
||||
[Address(RVA = "0x1E4A760", Offset = "0x1E49160", VA = "0x181E4A760")]
|
||||
private void AddUserID(IDigest digest, byte[] userID)
|
||||
{
|
||||
int length = userID.Length;
|
||||
}
|
||||
|
||||
// Token: 0x060095C4 RID: 38340 RVA: 0x002136A0 File Offset: 0x002118A0
|
||||
[Token(Token = "0x60095C4")]
|
||||
[Address(RVA = "0x1E4A6D0", Offset = "0x1E490D0", VA = "0x181E4A6D0")]
|
||||
private void AddFieldElement(IDigest digest, ECFieldElement v)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060095C5 RID: 38341 RVA: 0x002136B4 File Offset: 0x002118B4
|
||||
[Token(Token = "0x60095C5")]
|
||||
[Address(RVA = "0x1E4A840", Offset = "0x1E49240", VA = "0x181E4A840", Slot = "18")]
|
||||
protected virtual BigInteger CalculateE(byte[] message)
|
||||
{
|
||||
return new BigInteger(1, message);
|
||||
}
|
||||
|
||||
// Token: 0x060095C6 RID: 38342 RVA: 0x002136C8 File Offset: 0x002118C8
|
||||
[Token(Token = "0x60095C6")]
|
||||
[Address(RVA = "0x1E4A8A0", Offset = "0x1E492A0", VA = "0x181E4A8A0", Slot = "19")]
|
||||
protected virtual ECMultiplier CreateBasePointMultiplier()
|
||||
{
|
||||
/*
|
||||
An exception occurred when decompiling this method (060095C6)
|
||||
|
||||
ICSharpCode.Decompiler.DecompilerException: Error decompiling BestHTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Multiplier.ECMultiplier BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers.SM2Signer::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: 0x040062D8 RID: 25304
|
||||
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
|
||||
[Token(Token = "0x40062D8")]
|
||||
private readonly IDsaKCalculator kCalculator;
|
||||
|
||||
// Token: 0x040062D9 RID: 25305
|
||||
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
|
||||
[Token(Token = "0x40062D9")]
|
||||
private readonly SM3Digest digest;
|
||||
|
||||
// Token: 0x040062DA RID: 25306
|
||||
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
|
||||
[Token(Token = "0x40062DA")]
|
||||
private readonly IDsaEncoding encoding;
|
||||
|
||||
// Token: 0x040062DB RID: 25307
|
||||
[global::Cpp2IlInjected.FieldOffset(Offset = "0x28")]
|
||||
[Token(Token = "0x40062DB")]
|
||||
private ECDomainParameters ecParams;
|
||||
|
||||
// Token: 0x040062DC RID: 25308
|
||||
[global::Cpp2IlInjected.FieldOffset(Offset = "0x30")]
|
||||
[Token(Token = "0x40062DC")]
|
||||
private ECPoint pubPoint;
|
||||
|
||||
// Token: 0x040062DD RID: 25309
|
||||
[global::Cpp2IlInjected.FieldOffset(Offset = "0x38")]
|
||||
[Token(Token = "0x40062DD")]
|
||||
private ECKeyParameters ecKey;
|
||||
|
||||
// Token: 0x040062DE RID: 25310
|
||||
[global::Cpp2IlInjected.FieldOffset(Offset = "0x40")]
|
||||
[Token(Token = "0x40062DE")]
|
||||
private byte[] z;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user