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: 0x02001C8B RID: 7307
|
|
[Token(Token = "0x2001C8B")]
|
|
public class Ed448Signer : ISigner
|
|
{
|
|
// Token: 0x0600B4D6 RID: 46294 RVA: 0x00270994 File Offset: 0x0026EB94
|
|
[Token(Token = "0x600B4D6")]
|
|
[Address(RVA = "0x2359D00", Offset = "0x2358D00", VA = "0x182359D00")]
|
|
public Ed448Signer(byte[] context)
|
|
{
|
|
Ed448Signer.Buffer buffer = new Ed448Signer.Buffer();
|
|
this.buffer = buffer;
|
|
base..ctor();
|
|
byte[] array = Arrays.Clone(context);
|
|
this.context = array;
|
|
}
|
|
|
|
// Token: 0x17001C7E RID: 7294
|
|
// (get) Token: 0x0600B4D7 RID: 46295 RVA: 0x002709C4 File Offset: 0x0026EBC4
|
|
[Token(Token = "0x17001C7E")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x600B4D7")]
|
|
[Address(RVA = "0x2359DA0", Offset = "0x2358DA0", VA = "0x182359DA0", Slot = "11")]
|
|
get
|
|
{
|
|
return "Ed448";
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B4D8 RID: 46296 RVA: 0x002709D8 File Offset: 0x0026EBD8
|
|
[Token(Token = "0x600B4D8")]
|
|
[Address(RVA = "0x2359B70", Offset = "0x2358B70", VA = "0x182359B70", 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:
|
|
Ed448PublicKeyParameters ed448PublicKeyParameters;
|
|
this.publicKey = ed448PublicKeyParameters;
|
|
string algorithmName = ((ISigner)this).AlgorithmName;
|
|
}
|
|
|
|
// Token: 0x0600B4D9 RID: 46297 RVA: 0x00270A20 File Offset: 0x0026EC20
|
|
[Token(Token = "0x600B4D9")]
|
|
[Address(RVA = "0xAC4CC0", Offset = "0xAC3CC0", VA = "0x180AC4CC0", Slot = "13")]
|
|
public virtual void Update(byte b)
|
|
{
|
|
((IDisposable)this.buffer).Dispose();
|
|
}
|
|
|
|
// Token: 0x0600B4DA RID: 46298 RVA: 0x00270A40 File Offset: 0x0026EC40
|
|
[Token(Token = "0x600B4DA")]
|
|
[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: 0x0600B4DB RID: 46299 RVA: 0x00270A64 File Offset: 0x0026EC64
|
|
[Token(Token = "0x600B4DB")]
|
|
[Address(RVA = "0x2359AE0", Offset = "0x2358AE0", VA = "0x182359AE0", Slot = "15")]
|
|
public virtual byte[] GenerateSignature()
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B4DB)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers.Ed448Signer::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("Ed448Signer 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: 0x0600B4DC RID: 46300 RVA: 0x00270AB0 File Offset: 0x0026ECB0
|
|
[Token(Token = "0x600B4DC")]
|
|
[Address(RVA = "0x2359C60", Offset = "0x2358C60", VA = "0x182359C60", Slot = "16")]
|
|
public virtual bool VerifySignature(byte[] signature)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B4DC)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Boolean BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Signers.Ed448Signer::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("Ed448Signer 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: 0x0600B4DD RID: 46301 RVA: 0x00270AF4 File Offset: 0x0026ECF4
|
|
[Token(Token = "0x600B4DD")]
|
|
[Address(RVA = "0x2359C40", Offset = "0x2358C40", VA = "0x182359C40", Slot = "17")]
|
|
public virtual void Reset()
|
|
{
|
|
this.buffer.Reset();
|
|
}
|
|
|
|
// Token: 0x0400726F RID: 29295
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x400726F")]
|
|
private readonly Ed448Signer.Buffer buffer;
|
|
|
|
// Token: 0x04007270 RID: 29296
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x4007270")]
|
|
private readonly byte[] context;
|
|
|
|
// Token: 0x04007271 RID: 29297
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4007271")]
|
|
private bool forSigning;
|
|
|
|
// Token: 0x04007272 RID: 29298
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x4007272")]
|
|
private Ed448PrivateKeyParameters privateKey;
|
|
|
|
// Token: 0x04007273 RID: 29299
|
|
[FieldOffset(Offset = "0x30")]
|
|
[Token(Token = "0x4007273")]
|
|
private Ed448PublicKeyParameters publicKey;
|
|
|
|
// Token: 0x02001C8C RID: 7308
|
|
[Token(Token = "0x2001C8C")]
|
|
private class Buffer : MemoryStream
|
|
{
|
|
// Token: 0x0600B4DE RID: 46302 RVA: 0x00270B14 File Offset: 0x0026ED14
|
|
[Token(Token = "0x600B4DE")]
|
|
[Address(RVA = "0x2351570", Offset = "0x2350570", VA = "0x182351570")]
|
|
internal byte[] GenerateSignature(Ed448PrivateKeyParameters privateKey, Ed448PublicKeyParameters publicKey, byte[] ctx)
|
|
{
|
|
int num;
|
|
byte[] array;
|
|
do
|
|
{
|
|
num = 0;
|
|
long length = this.Length;
|
|
array = new byte[Ed448PrivateKeyParameters.SignatureSize];
|
|
this.Reset();
|
|
Monitor.Exit(this);
|
|
}
|
|
while (num != 0);
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x0600B4DF RID: 46303 RVA: 0x00270B4C File Offset: 0x0026ED4C
|
|
[Token(Token = "0x600B4DF")]
|
|
[Address(RVA = "0x2351F80", Offset = "0x2350F80", VA = "0x182351F80")]
|
|
internal bool VerifySignature(Ed448PublicKeyParameters 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 = Ed448.Verify(signature, num3, encoded, num2, ctx, encoded, num, (int)length);
|
|
this.Reset();
|
|
Monitor.Exit(this);
|
|
}
|
|
while (num != 0);
|
|
return flag;
|
|
}
|
|
|
|
// Token: 0x0600B4E0 RID: 46304 RVA: 0x00270B98 File Offset: 0x0026ED98
|
|
[Token(Token = "0x600B4E0")]
|
|
[Address(RVA = "0x2351A30", Offset = "0x2350A30", VA = "0x182351A30")]
|
|
internal void Reset()
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
long length = this.Length;
|
|
long position = this.Position;
|
|
Monitor.Exit(this);
|
|
}
|
|
while (num != 0);
|
|
}
|
|
|
|
// Token: 0x0600B4E1 RID: 46305 RVA: 0x00270BC0 File Offset: 0x0026EDC0
|
|
[Token(Token = "0x600B4E1")]
|
|
[Address(RVA = "0x495270", Offset = "0x494270", VA = "0x180495270")]
|
|
public Buffer()
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|