242 lines
11 KiB
C#
242 lines
11 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Rfc8032;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers
|
|
{
|
|
// Token: 0x02001C88 RID: 7304
|
|
[Token(Token = "0x2001C88")]
|
|
public class Ed25519ctxSigner : ISigner
|
|
{
|
|
// Token: 0x0600B4C2 RID: 46274 RVA: 0x00270584 File Offset: 0x0026E784
|
|
[Token(Token = "0x600B4C2")]
|
|
[Address(RVA = "0x2359420", Offset = "0x2358420", VA = "0x182359420")]
|
|
public Ed25519ctxSigner(byte[] context)
|
|
{
|
|
Ed25519ctxSigner.Buffer buffer = new Ed25519ctxSigner.Buffer();
|
|
this.buffer = buffer;
|
|
base..ctor();
|
|
byte[] array = Arrays.Clone(context);
|
|
this.context = array;
|
|
}
|
|
|
|
// Token: 0x17001C7C RID: 7292
|
|
// (get) Token: 0x0600B4C3 RID: 46275 RVA: 0x002705B4 File Offset: 0x0026E7B4
|
|
[Token(Token = "0x17001C7C")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x600B4C3")]
|
|
[Address(RVA = "0x23594C0", Offset = "0x23584C0", VA = "0x1823594C0", Slot = "11")]
|
|
get
|
|
{
|
|
return "Ed25519ctx";
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B4C4 RID: 46276 RVA: 0x002705C8 File Offset: 0x0026E7C8
|
|
[Token(Token = "0x600B4C4")]
|
|
[Address(RVA = "0x2359290", Offset = "0x2358290", VA = "0x182359290", Slot = "12")]
|
|
public virtual void Init(bool forSigning, ICipherParameters parameters)
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
this.forSigning = forSigning;
|
|
num = 0;
|
|
if (!forSigning)
|
|
{
|
|
this.privateKey = num;
|
|
if (parameters == 0)
|
|
{
|
|
goto IL_2B;
|
|
}
|
|
if (parameters == 0)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
while (parameters != 0 && parameters == 0);
|
|
this.privateKey = num;
|
|
IL_2B:
|
|
Ed25519PublicKeyParameters ed25519PublicKeyParameters;
|
|
this.publicKey = ed25519PublicKeyParameters;
|
|
string algorithmName = ((ISigner)this).AlgorithmName;
|
|
}
|
|
|
|
// Token: 0x0600B4C5 RID: 46277 RVA: 0x00270610 File Offset: 0x0026E810
|
|
[Token(Token = "0x600B4C5")]
|
|
[Address(RVA = "0xAC4CC0", Offset = "0xAC3CC0", VA = "0x180AC4CC0", Slot = "13")]
|
|
public virtual void Update(byte b)
|
|
{
|
|
((IDisposable)this.buffer).Dispose();
|
|
}
|
|
|
|
// Token: 0x0600B4C6 RID: 46278 RVA: 0x00270630 File Offset: 0x0026E830
|
|
[Token(Token = "0x600B4C6")]
|
|
[Address(RVA = "0x2358F30", Offset = "0x2357F30", VA = "0x182358F30", Slot = "14")]
|
|
public virtual void BlockUpdate(byte[] buf, int off, int len)
|
|
{
|
|
int num = this.buffer.Read(buf, off, len);
|
|
}
|
|
|
|
// Token: 0x0600B4C7 RID: 46279 RVA: 0x00270654 File Offset: 0x0026E854
|
|
[Token(Token = "0x600B4C7")]
|
|
[Address(RVA = "0x2359200", Offset = "0x2358200", VA = "0x182359200", Slot = "15")]
|
|
public virtual byte[] GenerateSignature()
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B4C7)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers.Ed25519ctxSigner::GenerateSignature()
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_33:
|
|
stloc:InvalidOperationException(var_5_3D, newobj:InvalidOperationException(InvalidOperationException::.ctor, ldstr:string("Ed25519ctxSigner not initialised for signature generation.")))
|
|
}
|
|
|
|
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: 0x0600B4C8 RID: 46280 RVA: 0x002706A0 File Offset: 0x0026E8A0
|
|
[Token(Token = "0x600B4C8")]
|
|
[Address(RVA = "0x2359380", Offset = "0x2358380", VA = "0x182359380", Slot = "16")]
|
|
public virtual bool VerifySignature(byte[] signature)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B4C8)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Boolean BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers.Ed25519ctxSigner::VerifySignature(System.Byte[])
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_2C:
|
|
stloc:InvalidOperationException(var_4_36, newobj:InvalidOperationException(InvalidOperationException::.ctor, ldstr:string("Ed25519ctxSigner not initialised 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: 0x0600B4C9 RID: 46281 RVA: 0x002706E4 File Offset: 0x0026E8E4
|
|
[Token(Token = "0x600B4C9")]
|
|
[Address(RVA = "0x2359360", Offset = "0x2358360", VA = "0x182359360", Slot = "17")]
|
|
public virtual void Reset()
|
|
{
|
|
this.buffer.Reset();
|
|
}
|
|
|
|
// Token: 0x04007265 RID: 29285
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x4007265")]
|
|
private readonly Ed25519ctxSigner.Buffer buffer;
|
|
|
|
// Token: 0x04007266 RID: 29286
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x4007266")]
|
|
private readonly byte[] context;
|
|
|
|
// Token: 0x04007267 RID: 29287
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4007267")]
|
|
private bool forSigning;
|
|
|
|
// Token: 0x04007268 RID: 29288
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x4007268")]
|
|
private Ed25519PrivateKeyParameters privateKey;
|
|
|
|
// Token: 0x04007269 RID: 29289
|
|
[FieldOffset(Offset = "0x30")]
|
|
[Token(Token = "0x4007269")]
|
|
private Ed25519PublicKeyParameters publicKey;
|
|
|
|
// Token: 0x02001C89 RID: 7305
|
|
[Token(Token = "0x2001C89")]
|
|
private class Buffer : MemoryStream
|
|
{
|
|
// Token: 0x0600B4CA RID: 46282 RVA: 0x00270704 File Offset: 0x0026E904
|
|
[Token(Token = "0x600B4CA")]
|
|
[Address(RVA = "0x2351890", Offset = "0x2350890", VA = "0x182351890")]
|
|
internal byte[] GenerateSignature(Ed25519PrivateKeyParameters privateKey, Ed25519PublicKeyParameters publicKey, byte[] ctx)
|
|
{
|
|
int num;
|
|
byte[] array;
|
|
do
|
|
{
|
|
num = 0;
|
|
long length = this.Length;
|
|
array = new byte[Ed25519PrivateKeyParameters.SignatureSize];
|
|
this.Reset();
|
|
Monitor.Exit(this);
|
|
}
|
|
while (num != 0);
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x0600B4CB RID: 46283 RVA: 0x0027073C File Offset: 0x0026E93C
|
|
[Token(Token = "0x600B4CB")]
|
|
[Address(RVA = "0x2351CA0", Offset = "0x2350CA0", VA = "0x182351CA0")]
|
|
internal bool VerifySignature(Ed25519PublicKeyParameters publicKey, byte[] ctx, byte[] signature)
|
|
{
|
|
int num;
|
|
bool flag;
|
|
do
|
|
{
|
|
num = 0;
|
|
long length = this.Length;
|
|
byte[] encoded = publicKey.GetEncoded();
|
|
int num2 = 0;
|
|
int num3 = 0;
|
|
flag = Ed25519.Verify(signature, num3, encoded, num2, ctx, encoded, num, (int)length);
|
|
this.Reset();
|
|
Monitor.Exit(this);
|
|
}
|
|
while (num != 0);
|
|
return flag;
|
|
}
|
|
|
|
// Token: 0x0600B4CC RID: 46284 RVA: 0x00270788 File Offset: 0x0026E988
|
|
[Token(Token = "0x600B4CC")]
|
|
[Address(RVA = "0x2351B00", Offset = "0x2350B00", VA = "0x182351B00")]
|
|
internal void Reset()
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
long length = this.Length;
|
|
long position = this.Position;
|
|
Monitor.Exit(this);
|
|
}
|
|
while (num != 0);
|
|
}
|
|
|
|
// Token: 0x0600B4CD RID: 46285 RVA: 0x002707B0 File Offset: 0x0026E9B0
|
|
[Token(Token = "0x600B4CD")]
|
|
[Address(RVA = "0x495270", Offset = "0x494270", VA = "0x180495270")]
|
|
public Buffer()
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|