230 lines
10 KiB
C#
230 lines
10 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers
|
|
{
|
|
// Token: 0x02001C86 RID: 7302
|
|
[Token(Token = "0x2001C86")]
|
|
public class Ed25519Signer : ISigner
|
|
{
|
|
// Token: 0x0600B4B6 RID: 46262 RVA: 0x0027037C File Offset: 0x0026E57C
|
|
[Token(Token = "0x600B4B6")]
|
|
[Address(RVA = "0x2359170", Offset = "0x2358170", VA = "0x182359170")]
|
|
public Ed25519Signer()
|
|
{
|
|
Ed25519Signer.Buffer buffer = new Ed25519Signer.Buffer();
|
|
this.buffer = buffer;
|
|
base..ctor();
|
|
}
|
|
|
|
// Token: 0x17001C7B RID: 7291
|
|
// (get) Token: 0x0600B4B7 RID: 46263 RVA: 0x0027039C File Offset: 0x0026E59C
|
|
[Token(Token = "0x17001C7B")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x600B4B7")]
|
|
[Address(RVA = "0x23591D0", Offset = "0x23581D0", VA = "0x1823591D0", Slot = "11")]
|
|
get
|
|
{
|
|
return "Ed25519";
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B4B8 RID: 46264 RVA: 0x002703B0 File Offset: 0x0026E5B0
|
|
[Token(Token = "0x600B4B8")]
|
|
[Address(RVA = "0x2358FF0", Offset = "0x2357FF0", VA = "0x182358FF0", 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: 0x0600B4B9 RID: 46265 RVA: 0x002703F8 File Offset: 0x0026E5F8
|
|
[Token(Token = "0x600B4B9")]
|
|
[Address(RVA = "0xAC4CC0", Offset = "0xAC3CC0", VA = "0x180AC4CC0", Slot = "13")]
|
|
public virtual void Update(byte b)
|
|
{
|
|
((IDisposable)this.buffer).Dispose();
|
|
}
|
|
|
|
// Token: 0x0600B4BA RID: 46266 RVA: 0x00270418 File Offset: 0x0026E618
|
|
[Token(Token = "0x600B4BA")]
|
|
[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: 0x0600B4BB RID: 46267 RVA: 0x0027043C File Offset: 0x0026E63C
|
|
[Token(Token = "0x600B4BB")]
|
|
[Address(RVA = "0x2358F60", Offset = "0x2357F60", VA = "0x182358F60", Slot = "15")]
|
|
public virtual byte[] GenerateSignature()
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B4BB)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers.Ed25519Signer::GenerateSignature()
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_2B:
|
|
stloc:InvalidOperationException(var_3_35, newobj:InvalidOperationException(InvalidOperationException::.ctor, ldstr:string("Ed25519Signer 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: 0x0600B4BC RID: 46268 RVA: 0x00270480 File Offset: 0x0026E680
|
|
[Token(Token = "0x600B4BC")]
|
|
[Address(RVA = "0x23590E0", Offset = "0x23580E0", VA = "0x1823590E0", Slot = "16")]
|
|
public virtual bool VerifySignature(byte[] signature)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B4BC)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Boolean BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers.Ed25519Signer::VerifySignature(System.Byte[])
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_22:
|
|
stloc:InvalidOperationException(var_1_2C, newobj:InvalidOperationException(InvalidOperationException::.ctor, ldstr:string("Ed25519Signer 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: 0x0600B4BD RID: 46269 RVA: 0x002704BC File Offset: 0x0026E6BC
|
|
[Token(Token = "0x600B4BD")]
|
|
[Address(RVA = "0x23590C0", Offset = "0x23580C0", VA = "0x1823590C0", Slot = "17")]
|
|
public virtual void Reset()
|
|
{
|
|
this.buffer.Reset();
|
|
}
|
|
|
|
// Token: 0x04007261 RID: 29281
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x4007261")]
|
|
private readonly Ed25519Signer.Buffer buffer;
|
|
|
|
// Token: 0x04007262 RID: 29282
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x4007262")]
|
|
private bool forSigning;
|
|
|
|
// Token: 0x04007263 RID: 29283
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4007263")]
|
|
private Ed25519PrivateKeyParameters privateKey;
|
|
|
|
// Token: 0x04007264 RID: 29284
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x4007264")]
|
|
private Ed25519PublicKeyParameters publicKey;
|
|
|
|
// Token: 0x02001C87 RID: 7303
|
|
[Token(Token = "0x2001C87")]
|
|
private class Buffer : MemoryStream
|
|
{
|
|
// Token: 0x0600B4BE RID: 46270 RVA: 0x002704DC File Offset: 0x0026E6DC
|
|
[Token(Token = "0x600B4BE")]
|
|
[Address(RVA = "0x2351700", Offset = "0x2350700", VA = "0x182351700")]
|
|
internal byte[] GenerateSignature(Ed25519PrivateKeyParameters privateKey, Ed25519PublicKeyParameters publicKey)
|
|
{
|
|
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: 0x0600B4BF RID: 46271 RVA: 0x00270514 File Offset: 0x0026E714
|
|
[Token(Token = "0x600B4BF")]
|
|
[Address(RVA = "0x2351E10", Offset = "0x2350E10", VA = "0x182351E10")]
|
|
internal bool VerifySignature(Ed25519PublicKeyParameters publicKey, byte[] signature)
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
long length = this.Length;
|
|
byte[] encoded = publicKey.GetEncoded();
|
|
this.Reset();
|
|
Monitor.Exit(this);
|
|
}
|
|
while (num != 0);
|
|
bool flag;
|
|
return flag;
|
|
}
|
|
|
|
// Token: 0x0600B4C0 RID: 46272 RVA: 0x00270548 File Offset: 0x0026E748
|
|
[Token(Token = "0x600B4C0")]
|
|
[Address(RVA = "0x2351BD0", Offset = "0x2350BD0", VA = "0x182351BD0")]
|
|
internal void Reset()
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
long length = this.Length;
|
|
long position = this.Position;
|
|
Monitor.Exit(this);
|
|
}
|
|
while (num != 0);
|
|
}
|
|
|
|
// Token: 0x0600B4C1 RID: 46273 RVA: 0x00270570 File Offset: 0x0026E770
|
|
[Token(Token = "0x600B4C1")]
|
|
[Address(RVA = "0x495270", Offset = "0x494270", VA = "0x180495270")]
|
|
public Buffer()
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|