m
This commit is contained in:
@@ -0,0 +1,325 @@
|
||||
using System;
|
||||
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Digests;
|
||||
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
|
||||
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Utilities;
|
||||
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 BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
||||
using Cpp2IlInjected;
|
||||
|
||||
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
|
||||
{
|
||||
// Token: 0x02001D8A RID: 7562
|
||||
[Token(Token = "0x2001D8A")]
|
||||
public class SM2Engine
|
||||
{
|
||||
// Token: 0x0600BC7C RID: 48252 RVA: 0x0029A57C File Offset: 0x0029877C
|
||||
[Token(Token = "0x600BC7C")]
|
||||
[Address(RVA = "0x27387B0", Offset = "0x27377B0", VA = "0x1827387B0")]
|
||||
public SM2Engine()
|
||||
{
|
||||
SM3Digest sm3Digest = new SM3Digest();
|
||||
base..ctor();
|
||||
this.mDigest = sm3Digest;
|
||||
}
|
||||
|
||||
// Token: 0x0600BC7D RID: 48253 RVA: 0x0029A59C File Offset: 0x0029879C
|
||||
[Token(Token = "0x600BC7D")]
|
||||
[Address(RVA = "0x493D90", Offset = "0x492D90", VA = "0x180493D90")]
|
||||
public SM2Engine(IDigest digest)
|
||||
{
|
||||
this.mDigest = digest;
|
||||
}
|
||||
|
||||
// Token: 0x0600BC7E RID: 48254 RVA: 0x0029A5B8 File Offset: 0x002987B8
|
||||
[Token(Token = "0x600BC7E")]
|
||||
[Address(RVA = "0x2738000", Offset = "0x2737000", VA = "0x182738000", Slot = "4")]
|
||||
public virtual void Init(bool forEncryption, ICipherParameters param)
|
||||
{
|
||||
bool flag;
|
||||
for (;;)
|
||||
{
|
||||
this.mForEncryption = forEncryption;
|
||||
if (!forEncryption)
|
||||
{
|
||||
if (param == 0)
|
||||
{
|
||||
}
|
||||
int num = 0;
|
||||
if (param == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
this.mECKey = param;
|
||||
this.mECParams = num;
|
||||
}
|
||||
if (param != 0)
|
||||
{
|
||||
if (typeof(ParametersWithRandom).TypeHandle == 0)
|
||||
{
|
||||
}
|
||||
if (typeof(ParametersWithRandom).TypeHandle != 0)
|
||||
{
|
||||
this.mECKey = typeof(ParametersWithRandom).TypeHandle;
|
||||
this.mECParams = param;
|
||||
if (typeof(ParametersWithRandom).TypeHandle != 0 && typeof(ParametersWithRandom).TypeHandle != 0 && !flag)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mRandom = flag;
|
||||
string text = this.mECParams.curve.ToString();
|
||||
this.mCurveLength = text;
|
||||
}
|
||||
|
||||
// Token: 0x0600BC7F RID: 48255 RVA: 0x0029A654 File Offset: 0x00298854
|
||||
[Token(Token = "0x600BC7F")]
|
||||
[Address(RVA = "0x2738700", Offset = "0x2737700", VA = "0x182738700", Slot = "5")]
|
||||
public virtual byte[] ProcessBlock(byte[] input, int inOff, int inLen)
|
||||
{
|
||||
if (!this.mForEncryption)
|
||||
{
|
||||
return this.Decrypt(input, inOff, inLen);
|
||||
}
|
||||
return this.Encrypt(input, inOff, inLen);
|
||||
}
|
||||
|
||||
// Token: 0x0600BC80 RID: 48256 RVA: 0x0029A680 File Offset: 0x00298880
|
||||
[Token(Token = "0x600BC80")]
|
||||
[Address(RVA = "0x2737600", Offset = "0x2736600", VA = "0x182737600", Slot = "6")]
|
||||
protected virtual ECMultiplier CreateBasePointMultiplier()
|
||||
{
|
||||
/*
|
||||
An exception occurred when decompiling this method (0600BC80)
|
||||
|
||||
ICSharpCode.Decompiler.DecompilerException: Error decompiling BestHTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Multiplier.ECMultiplier BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.SM2Engine::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: 0x0600BC81 RID: 48257 RVA: 0x0029A694 File Offset: 0x00298894
|
||||
[Token(Token = "0x600BC81")]
|
||||
[Address(RVA = "0x2737AB0", Offset = "0x2736AB0", VA = "0x182737AB0")]
|
||||
private byte[] Encrypt(byte[] input, int inOff, int inLen)
|
||||
{
|
||||
byte[] array;
|
||||
int num2;
|
||||
int num9;
|
||||
for (;;)
|
||||
{
|
||||
array = new byte[inLen];
|
||||
int length = array.Length;
|
||||
int num = 0;
|
||||
Array.Copy(input, inLen, array, num, length);
|
||||
num2 = this.mECParams.n.BitLength;
|
||||
SecureRandom secureRandom = this.mRandom;
|
||||
BigInteger bigInteger = new BigInteger(num2, secureRandom);
|
||||
while (bigInteger.sign == 0)
|
||||
{
|
||||
}
|
||||
BigInteger n = this.mECParams.n;
|
||||
int num3 = 0;
|
||||
int num4 = bigInteger.CompareTo(n);
|
||||
ECPoint g = this.mECParams.g;
|
||||
int num5 = 0;
|
||||
if (num5 < num3)
|
||||
{
|
||||
num5 += num5;
|
||||
num5++;
|
||||
}
|
||||
int num6 = 0;
|
||||
ulong num8;
|
||||
int num7 = num8.CompareTo((ulong)num6);
|
||||
ECKeyParameters eckeyParameters = this.mECKey;
|
||||
num2 = num7;
|
||||
num8 += num8;
|
||||
num7 += 19;
|
||||
if (eckeyParameters != 0)
|
||||
{
|
||||
num9 = 0;
|
||||
if (eckeyParameters != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
int length2 = array.Length;
|
||||
while (num9 == length2)
|
||||
{
|
||||
}
|
||||
num9++;
|
||||
IDigest digest = this.mDigest;
|
||||
byte[] array2 = DigestUtilities.DoFinal(this.mDigest);
|
||||
byte[][] array3 = new byte[3][];
|
||||
if (num2 != 0)
|
||||
{
|
||||
}
|
||||
array3[0] = num2;
|
||||
array3[1] = array;
|
||||
if (array2 != 0)
|
||||
{
|
||||
}
|
||||
array3[2] = array2;
|
||||
return Arrays.ConcatenateAll(array3);
|
||||
}
|
||||
|
||||
// Token: 0x0600BC82 RID: 48258 RVA: 0x0029A7D0 File Offset: 0x002989D0
|
||||
[Token(Token = "0x600BC82")]
|
||||
[Address(RVA = "0x2737650", Offset = "0x2736650", VA = "0x182737650")]
|
||||
private byte[] Decrypt(byte[] input, int inOff, int inLen)
|
||||
{
|
||||
/*
|
||||
An exception occurred when decompiling this method (0600BC82)
|
||||
|
||||
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.SM2Engine::Decrypt(System.Byte[],System.Int32,System.Int32)
|
||||
|
||||
---> System.Exception: Basic block has to end with unconditional control flow.
|
||||
{
|
||||
IL_139:
|
||||
stloc:int32(var_28_13A, ldc.i4:int32(0))
|
||||
call:void(Arrays::Fill, ldloc:uint8[](var_13_6C), ldloc:int32[exp:uint8](var_28_13A))
|
||||
stloc:InvalidCipherTextException(var_29_14F, newobj:InvalidCipherTextException(InvalidCipherTextException::.ctor, ldstr:string("invalid cipher text")))
|
||||
}
|
||||
|
||||
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.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1878
|
||||
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1878
|
||||
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1846
|
||||
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: 0x0600BC83 RID: 48259 RVA: 0x0029A930 File Offset: 0x00298B30
|
||||
[Token(Token = "0x600BC83")]
|
||||
[Address(RVA = "0x2738680", Offset = "0x2737680", VA = "0x182738680")]
|
||||
private bool NotEncrypted(byte[] encData, byte[] input, int inOff)
|
||||
{
|
||||
int num = 0;
|
||||
int length = encData.Length;
|
||||
if (num != length)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x0600BC84 RID: 48260 RVA: 0x0029A958 File Offset: 0x00298B58
|
||||
[Token(Token = "0x600BC84")]
|
||||
[Address(RVA = "0x27382C0", Offset = "0x27372C0", VA = "0x1827382C0")]
|
||||
private void Kdf(IDigest digest, ECPoint c1, byte[] encData)
|
||||
{
|
||||
int num;
|
||||
byte[] array = new byte[num];
|
||||
int num2 = 0;
|
||||
if (array != 0)
|
||||
{
|
||||
int curveCoordinateSystem = c1.CurveCoordinateSystem;
|
||||
ECFieldElement affineXCoord = c1.AffineXCoord;
|
||||
this.AddFieldElement(digest, affineXCoord);
|
||||
num2 += num2;
|
||||
num2++;
|
||||
}
|
||||
int num3 = 0;
|
||||
if (num3 < encData.Length)
|
||||
{
|
||||
if (array == 0)
|
||||
{
|
||||
int curveCoordinateSystem2 = c1.CurveCoordinateSystem;
|
||||
ECFieldElement affineXCoord2 = c1.AffineXCoord;
|
||||
this.AddFieldElement(digest, affineXCoord2);
|
||||
}
|
||||
int num4 = 0;
|
||||
Pack.UInt32_To_BE((uint)1, array, num4);
|
||||
int num5 = encData.Length;
|
||||
num5 -= num2;
|
||||
int num6;
|
||||
this.Xor(encData, array, num2, num6);
|
||||
num2 += num6;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600BC85 RID: 48261 RVA: 0x0029A9F4 File Offset: 0x00298BF4
|
||||
[Token(Token = "0x600BC85")]
|
||||
[Address(RVA = "0x2738730", Offset = "0x2737730", VA = "0x182738730")]
|
||||
private void Xor(byte[] data, byte[] kdfOut, int dOff, int dRemaining)
|
||||
{
|
||||
int num = 0;
|
||||
num++;
|
||||
}
|
||||
|
||||
// Token: 0x0600BC86 RID: 48262 RVA: 0x0029AA10 File Offset: 0x00298C10
|
||||
[Token(Token = "0x600BC86")]
|
||||
[Address(RVA = "0x27385C0", Offset = "0x27375C0", VA = "0x1827385C0")]
|
||||
private BigInteger NextK()
|
||||
{
|
||||
int bitLength = this.mECParams.n.BitLength;
|
||||
SecureRandom secureRandom = this.mRandom;
|
||||
BigInteger bigInteger = new BigInteger(bitLength, secureRandom);
|
||||
while (bigInteger.sign == 0)
|
||||
{
|
||||
}
|
||||
BigInteger n = this.mECParams.n;
|
||||
int num = bigInteger.CompareTo(n);
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
// Token: 0x0600BC87 RID: 48263 RVA: 0x0029AA64 File Offset: 0x00298C64
|
||||
[Token(Token = "0x600BC87")]
|
||||
[Address(RVA = "0x2737570", Offset = "0x2736570", VA = "0x182737570")]
|
||||
private void AddFieldElement(IDigest digest, ECFieldElement v)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x040076C7 RID: 30407
|
||||
[FieldOffset(Offset = "0x10")]
|
||||
[Token(Token = "0x40076C7")]
|
||||
private readonly IDigest mDigest;
|
||||
|
||||
// Token: 0x040076C8 RID: 30408
|
||||
[FieldOffset(Offset = "0x18")]
|
||||
[Token(Token = "0x40076C8")]
|
||||
private bool mForEncryption;
|
||||
|
||||
// Token: 0x040076C9 RID: 30409
|
||||
[FieldOffset(Offset = "0x20")]
|
||||
[Token(Token = "0x40076C9")]
|
||||
private ECKeyParameters mECKey;
|
||||
|
||||
// Token: 0x040076CA RID: 30410
|
||||
[FieldOffset(Offset = "0x28")]
|
||||
[Token(Token = "0x40076CA")]
|
||||
private ECDomainParameters mECParams;
|
||||
|
||||
// Token: 0x040076CB RID: 30411
|
||||
[FieldOffset(Offset = "0x30")]
|
||||
[Token(Token = "0x40076CB")]
|
||||
private int mCurveLength;
|
||||
|
||||
// Token: 0x040076CC RID: 30412
|
||||
[FieldOffset(Offset = "0x38")]
|
||||
[Token(Token = "0x40076CC")]
|
||||
private SecureRandom mRandom;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user