242 lines
9.7 KiB
C#
242 lines
9.7 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Modes;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
|
|
using Cpp2IlInjected;
|
|
using Hjg.Pngcs;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Tls
|
|
{
|
|
// Token: 0x02001582 RID: 5506
|
|
[Token(Token = "0x2001582")]
|
|
[StructLayout(3)]
|
|
public class TlsAeadCipher : TlsCipher
|
|
{
|
|
// Token: 0x0600923D RID: 37437 RVA: 0x002067D8 File Offset: 0x002049D8
|
|
[Token(Token = "0x600923D")]
|
|
[Address(RVA = "0x1E8EA40", Offset = "0x1E8D440", VA = "0x181E8EA40")]
|
|
public TlsAeadCipher(TlsContext context, IAeadBlockCipher clientWriteCipher, IAeadBlockCipher serverWriteCipher, int cipherKeySize, int macSize)
|
|
{
|
|
}
|
|
|
|
// Token: 0x0600923E RID: 37438 RVA: 0x002067E8 File Offset: 0x002049E8
|
|
[Token(Token = "0x600923E")]
|
|
[Address(RVA = "0x1E8EA70", Offset = "0x1E8D470", VA = "0x181E8EA70")]
|
|
internal TlsAeadCipher(TlsContext context, IAeadBlockCipher clientWriteCipher, IAeadBlockCipher serverWriteCipher, int cipherKeySize, int macSize, int nonceMode)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600923E)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Tls.TlsAeadCipher::.ctor(BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Tls.TlsContext,BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Modes.IAeadBlockCipher,BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Modes.IAeadBlockCipher,System.Int32,System.Int32,System.Int32)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_82:
|
|
stloc:TlsFatalAlert(var_12_89, newobj:TlsFatalAlert(TlsFatalAlert::.ctor, ldloc:uint64[exp:uint8](var_13)))
|
|
stloc:TlsFatalAlert(var_14_92, newobj:TlsFatalAlert(TlsFatalAlert::.ctor, ldloc:uint64[exp:uint8](var_15)))
|
|
}
|
|
|
|
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: 0x0600923F RID: 37439 RVA: 0x00206888 File Offset: 0x00204A88
|
|
[Token(Token = "0x600923F")]
|
|
[Address(RVA = "0x1E8EA30", Offset = "0x1E8D430", VA = "0x181E8EA30", Slot = "7")]
|
|
public virtual int GetPlaintextLimit(int ciphertextLimit)
|
|
{
|
|
return ciphertextLimit;
|
|
}
|
|
|
|
// Token: 0x06009240 RID: 37440 RVA: 0x00206898 File Offset: 0x00204A98
|
|
[Token(Token = "0x6009240")]
|
|
[Address(RVA = "0x1E8E530", Offset = "0x1E8CF30", VA = "0x181E8E530", Slot = "8")]
|
|
public virtual byte[] EncodePlaintext(long seqNo, byte type, byte[] plaintext, int offset, int len)
|
|
{
|
|
byte[] array2;
|
|
byte[] array4;
|
|
for (;;)
|
|
{
|
|
byte[] array = this.encryptImplicitNonce;
|
|
int num = this.record_iv_length;
|
|
int length = array.Length;
|
|
num += length;
|
|
array2 = new byte[num];
|
|
int num2 = this.nonceMode;
|
|
if (num2 == 1)
|
|
{
|
|
byte[] array3 = this.encryptImplicitNonce;
|
|
int length2 = array3.Length;
|
|
int num3 = 0;
|
|
int num4 = 0;
|
|
Array.Copy(array3, num4, array2, num3, length2);
|
|
int length3 = this.encryptImplicitNonce.Length;
|
|
TlsUtilities.WriteUint64(seqNo, array2, length3);
|
|
IAeadBlockCipher aeadBlockCipher = this.encryptCipher;
|
|
int num5 = this.record_iv_length;
|
|
num5 += num2;
|
|
array4 = new byte[num5];
|
|
int num6 = this.record_iv_length;
|
|
if (num6 != 0)
|
|
{
|
|
int num7 = array2.Length;
|
|
num7 -= num6;
|
|
int num8 = 0;
|
|
Array.Copy(array2, num7, array4, num8, num6);
|
|
}
|
|
int num9 = this.macSize;
|
|
IAeadBlockCipher aeadBlockCipher2 = this.encryptCipher;
|
|
IAeadBlockCipher aeadBlockCipher3 = this.encryptCipher;
|
|
IAeadBlockCipher aeadBlockCipher4 = this.encryptCipher;
|
|
AeadParameters aeadParameters;
|
|
num9 += aeadParameters;
|
|
if (num9 == array4.Length)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
else if (num2 == 2)
|
|
{
|
|
goto Block_3;
|
|
}
|
|
}
|
|
return array4;
|
|
Block_3:
|
|
int length4 = array2.Length;
|
|
TlsUtilities.WriteUint64(seqNo, array2, length4);
|
|
int num10 = 0;
|
|
int i = 0;
|
|
byte[] array5 = this.encryptImplicitNonce;
|
|
while (i >= array5.Length)
|
|
{
|
|
}
|
|
num10++;
|
|
byte[] array6 = this.encryptImplicitNonce;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009241 RID: 37441 RVA: 0x002069E0 File Offset: 0x00204BE0
|
|
[Token(Token = "0x6009241")]
|
|
[Address(RVA = "0x1E8E110", Offset = "0x1E8CB10", VA = "0x181E8E110", Slot = "9")]
|
|
public virtual byte[] DecodeCiphertext(long seqNo, byte type, byte[] ciphertext, int offset, int len)
|
|
{
|
|
byte[] array6;
|
|
for (;;)
|
|
{
|
|
byte[] array = this.decryptImplicitNonce;
|
|
int num = this.record_iv_length;
|
|
int length = array.Length;
|
|
num += length;
|
|
byte[] array2 = new byte[num];
|
|
int num2 = this.nonceMode;
|
|
if (num2 == 1)
|
|
{
|
|
byte[] array3 = this.decryptImplicitNonce;
|
|
int length2 = array3.Length;
|
|
int num3 = 0;
|
|
int num4 = 0;
|
|
Array.Copy(array3, num4, array2, num3, length2);
|
|
int num5 = this.record_iv_length;
|
|
int num6 = array2.Length;
|
|
num6 -= num5;
|
|
Array.Copy(ciphertext, (int)seqNo, array2, num6, num5);
|
|
}
|
|
if (num2 == 2)
|
|
{
|
|
int length3 = array2.Length;
|
|
TlsUtilities.WriteUint64(seqNo, array2, length3);
|
|
int num7 = 0;
|
|
int num8 = 0;
|
|
byte[] array4 = this.decryptImplicitNonce;
|
|
if (num8 < array4.Length)
|
|
{
|
|
num7++;
|
|
byte[] array5 = this.decryptImplicitNonce;
|
|
}
|
|
int num9 = this.record_iv_length;
|
|
IAeadBlockCipher aeadBlockCipher = this.decryptCipher;
|
|
array6 = new byte[num9];
|
|
IAeadBlockCipher aeadBlockCipher2 = this.decryptCipher;
|
|
IAeadBlockCipher aeadBlockCipher3 = this.decryptCipher;
|
|
IAeadBlockCipher aeadBlockCipher4 = this.decryptCipher;
|
|
AeadParameters aeadParameters;
|
|
aeadParameters += aeadParameters;
|
|
if (aeadParameters == array6.Length)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return array6;
|
|
}
|
|
|
|
// Token: 0x06009242 RID: 37442 RVA: 0x00206B00 File Offset: 0x00204D00
|
|
[Token(Token = "0x6009242")]
|
|
[Address(RVA = "0x1E8E930", Offset = "0x1E8D330", VA = "0x181E8E930", Slot = "10")]
|
|
protected virtual byte[] GetAdditionalData(long seqNo, byte type, int len)
|
|
{
|
|
byte[] array = new byte[13];
|
|
int num = 0;
|
|
TlsUtilities.WriteUint64(seqNo, array, num);
|
|
TlsUtilities.WriteUint8(type, array, 8);
|
|
TlsContext tlsContext = this.context;
|
|
PngHelperInternal.WriteInt2tobytes(len, array, 11);
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x0400619B RID: 24987
|
|
[Token(Token = "0x400619B")]
|
|
public const int NONCE_RFC5288 = 1;
|
|
|
|
// Token: 0x0400619C RID: 24988
|
|
[Token(Token = "0x400619C")]
|
|
internal const int NONCE_DRAFT_CHACHA20_POLY1305 = 2;
|
|
|
|
// Token: 0x0400619D RID: 24989
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x400619D")]
|
|
protected readonly TlsContext context;
|
|
|
|
// Token: 0x0400619E RID: 24990
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x400619E")]
|
|
protected readonly int macSize;
|
|
|
|
// Token: 0x0400619F RID: 24991
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x1C")]
|
|
[Token(Token = "0x400619F")]
|
|
protected readonly int record_iv_length;
|
|
|
|
// Token: 0x040061A0 RID: 24992
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x40061A0")]
|
|
protected readonly IAeadBlockCipher encryptCipher;
|
|
|
|
// Token: 0x040061A1 RID: 24993
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x40061A1")]
|
|
protected readonly IAeadBlockCipher decryptCipher;
|
|
|
|
// Token: 0x040061A2 RID: 24994
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x30")]
|
|
[Token(Token = "0x40061A2")]
|
|
protected readonly byte[] encryptImplicitNonce;
|
|
|
|
// Token: 0x040061A3 RID: 24995
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x38")]
|
|
[Token(Token = "0x40061A3")]
|
|
protected readonly byte[] decryptImplicitNonce;
|
|
|
|
// Token: 0x040061A4 RID: 24996
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x40")]
|
|
[Token(Token = "0x40061A4")]
|
|
protected readonly int nonceMode;
|
|
}
|
|
}
|