274 lines
9.9 KiB
C#
274 lines
9.9 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Tls
|
|
{
|
|
// Token: 0x02001585 RID: 5509
|
|
[Token(Token = "0x2001585")]
|
|
[StructLayout(3)]
|
|
public class TlsBlockCipher : TlsCipher
|
|
{
|
|
// Token: 0x1700179B RID: 6043
|
|
// (get) Token: 0x06009246 RID: 37446 RVA: 0x00206B40 File Offset: 0x00204D40
|
|
[Token(Token = "0x1700179B")]
|
|
public virtual TlsMac WriteMac
|
|
{
|
|
[Token(Token = "0x6009246")]
|
|
[Address(RVA = "0x3EE8E0", Offset = "0x3ED2E0", VA = "0x1803EE8E0", Slot = "7")]
|
|
get
|
|
{
|
|
return this.mWriteMac;
|
|
}
|
|
}
|
|
|
|
// Token: 0x1700179C RID: 6044
|
|
// (get) Token: 0x06009247 RID: 37447 RVA: 0x00206B54 File Offset: 0x00204D54
|
|
[Token(Token = "0x1700179C")]
|
|
public virtual TlsMac ReadMac
|
|
{
|
|
[Token(Token = "0x6009247")]
|
|
[Address(RVA = "0x3D32F0", Offset = "0x3D1CF0", VA = "0x1803D32F0", Slot = "8")]
|
|
get
|
|
{
|
|
return this.mReadMac;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06009248 RID: 37448 RVA: 0x00206B68 File Offset: 0x00204D68
|
|
[Token(Token = "0x6009248")]
|
|
[Address(RVA = "0x1E8FB30", Offset = "0x1E8E530", VA = "0x181E8FB30")]
|
|
public TlsBlockCipher(TlsContext context, IBlockCipher clientWriteCipher, IBlockCipher serverWriteCipher, IDigest clientWriteDigest, IDigest serverWriteDigest, int cipherKeySize)
|
|
{
|
|
this.context = context;
|
|
byte[] array = new byte[256];
|
|
this.randomData = array;
|
|
bool flag = TlsUtilities.IsTlsV11(context);
|
|
this.useExplicitIV = flag;
|
|
this.encryptThenMac = flag;
|
|
if (!this.useExplicitIV)
|
|
{
|
|
}
|
|
TlsMac tlsMac;
|
|
TlsMac tlsMac2;
|
|
tlsMac += tlsMac2;
|
|
byte[] array3;
|
|
if (!this.useExplicitIV)
|
|
{
|
|
byte[] array2;
|
|
tlsMac += array2;
|
|
tlsMac += array3;
|
|
}
|
|
byte[] array4 = new byte[array3];
|
|
byte[] array5 = new byte[array4];
|
|
KeyParameter keyParameter;
|
|
KeyParameter keyParameter2;
|
|
if (array5 == 0)
|
|
{
|
|
this.mWriteMac = tlsMac;
|
|
this.mReadMac = tlsMac2;
|
|
this.encryptCipher = clientWriteCipher;
|
|
this.decryptCipher = serverWriteCipher;
|
|
ParametersWithIV parametersWithIV = new ParametersWithIV(keyParameter, array4);
|
|
ParametersWithIV parametersWithIV2 = new ParametersWithIV(keyParameter2, array5);
|
|
}
|
|
this.mWriteMac = tlsMac2;
|
|
this.mReadMac = tlsMac;
|
|
this.encryptCipher = serverWriteCipher;
|
|
this.decryptCipher = clientWriteCipher;
|
|
ParametersWithIV parametersWithIV3 = new ParametersWithIV(keyParameter2, array5);
|
|
ParametersWithIV parametersWithIV4 = new ParametersWithIV(keyParameter, array4);
|
|
IBlockCipher blockCipher = this.encryptCipher;
|
|
IBlockCipher blockCipher2 = this.decryptCipher;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009249 RID: 37449 RVA: 0x00206C70 File Offset: 0x00204E70
|
|
[Token(Token = "0x6009249")]
|
|
[Address(RVA = "0x1E8FA50", Offset = "0x1E8E450", VA = "0x181E8FA50", Slot = "9")]
|
|
public virtual int GetPlaintextLimit(int ciphertextLimit)
|
|
{
|
|
IBlockCipher blockCipher = this.encryptCipher;
|
|
byte[] macSecret = this.mWriteMac.MacSecret;
|
|
if (!this.encryptThenMac)
|
|
{
|
|
return ciphertextLimit - 1;
|
|
}
|
|
return ciphertextLimit - 1;
|
|
}
|
|
|
|
// Token: 0x0600924A RID: 37450 RVA: 0x00206CA8 File Offset: 0x00204EA8
|
|
[Token(Token = "0x600924A")]
|
|
[Address(RVA = "0x1E8F530", Offset = "0x1E8DF30", VA = "0x181E8F530", Slot = "10")]
|
|
public virtual byte[] EncodePlaintext(long seqNo, byte type, byte[] plaintext, int offset, int len)
|
|
{
|
|
IBlockCipher blockCipher = this.encryptCipher;
|
|
byte[] macSecret = this.mWriteMac.MacSecret;
|
|
TlsContext tlsContext = this.context;
|
|
if (!this.encryptThenMac)
|
|
{
|
|
TlsContext tlsContext2 = this.context;
|
|
}
|
|
TlsContext tlsContext3 = this.context;
|
|
byte[] array = new byte[this];
|
|
int num = 0;
|
|
if ((this.useExplicitIV ? 1 : 0) != num)
|
|
{
|
|
if (this.explicitIV != 0)
|
|
{
|
|
}
|
|
TlsContext tlsContext4 = this.context;
|
|
IBlockCipher blockCipher2 = this.encryptCipher;
|
|
byte[] array2 = this.explicitIV;
|
|
int num2;
|
|
ParametersWithIV parametersWithIV = new ParametersWithIV(num2, array2);
|
|
num2 = 0;
|
|
byte[] array3 = this.explicitIV;
|
|
}
|
|
if (!this.encryptThenMac)
|
|
{
|
|
int size = this.mWriteMac.Size;
|
|
}
|
|
int num3 = 0;
|
|
num3++;
|
|
IBlockCipher blockCipher3 = this.encryptCipher;
|
|
if (num3 < array)
|
|
{
|
|
num3 += num3;
|
|
num3++;
|
|
}
|
|
if (this.encryptThenMac)
|
|
{
|
|
int size2 = this.mWriteMac.Size;
|
|
}
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x0600924B RID: 37451 RVA: 0x00206DA4 File Offset: 0x00204FA4
|
|
[Token(Token = "0x600924B")]
|
|
[Address(RVA = "0x1E8F070", Offset = "0x1E8DA70", VA = "0x181E8F070", Slot = "11")]
|
|
public virtual byte[] DecodeCiphertext(long seqNo, byte type, byte[] ciphertext, int offset, int len)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600924B)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Tls.TlsBlockCipher::DecodeCiphertext(System.Int64,System.Byte,System.Byte[],System.Int32,System.Int32)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_AE:
|
|
stloc:TlsFatalAlert(var_24_B5, newobj:TlsFatalAlert(TlsFatalAlert::.ctor, ldloc:uint64[exp:uint8](var_25)))
|
|
}
|
|
|
|
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: 0x0600924C RID: 37452 RVA: 0x00206E68 File Offset: 0x00205068
|
|
[Token(Token = "0x600924C")]
|
|
[Address(RVA = "0x1E8EE10", Offset = "0x1E8D810", VA = "0x181E8EE10", Slot = "12")]
|
|
protected virtual int CheckPaddingConstantTime(byte[] buf, int off, int len, int blockSize, int macSize)
|
|
{
|
|
int num;
|
|
do
|
|
{
|
|
num = 0;
|
|
byte b2;
|
|
byte b = b2 + 1;
|
|
int num2 = 0;
|
|
bool flag;
|
|
if (flag)
|
|
{
|
|
}
|
|
int length = buf.Length;
|
|
num2 -= (int)b;
|
|
num2++;
|
|
}
|
|
while (num == 0);
|
|
return 0;
|
|
}
|
|
|
|
// Token: 0x0600924D RID: 37453 RVA: 0x00206EA4 File Offset: 0x002050A4
|
|
[Token(Token = "0x600924D")]
|
|
[Address(RVA = "0x1E8EFC0", Offset = "0x1E8D9C0", VA = "0x181E8EFC0", Slot = "13")]
|
|
protected virtual int ChooseExtraPadBlocks(SecureRandom r, int max)
|
|
{
|
|
int num;
|
|
return Math.Min(num, max);
|
|
}
|
|
|
|
// Token: 0x0600924E RID: 37454 RVA: 0x00206EC0 File Offset: 0x002050C0
|
|
[Token(Token = "0x600924E")]
|
|
[Address(RVA = "0x1E8FB10", Offset = "0x1E8E510", VA = "0x181E8FB10", Slot = "14")]
|
|
protected virtual int LowestBitSet(int x)
|
|
{
|
|
if (x != 0)
|
|
{
|
|
int num = 0;
|
|
if (x == 1)
|
|
{
|
|
num++;
|
|
while (x == 1)
|
|
{
|
|
}
|
|
return num;
|
|
}
|
|
}
|
|
return 32;
|
|
}
|
|
|
|
// Token: 0x040061A5 RID: 24997
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x40061A5")]
|
|
protected readonly TlsContext context;
|
|
|
|
// Token: 0x040061A6 RID: 24998
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x40061A6")]
|
|
protected readonly byte[] randomData;
|
|
|
|
// Token: 0x040061A7 RID: 24999
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x40061A7")]
|
|
protected readonly bool useExplicitIV;
|
|
|
|
// Token: 0x040061A8 RID: 25000
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x21")]
|
|
[Token(Token = "0x40061A8")]
|
|
protected readonly bool encryptThenMac;
|
|
|
|
// Token: 0x040061A9 RID: 25001
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x40061A9")]
|
|
protected readonly IBlockCipher encryptCipher;
|
|
|
|
// Token: 0x040061AA RID: 25002
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x30")]
|
|
[Token(Token = "0x40061AA")]
|
|
protected readonly IBlockCipher decryptCipher;
|
|
|
|
// Token: 0x040061AB RID: 25003
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x38")]
|
|
[Token(Token = "0x40061AB")]
|
|
protected readonly TlsMac mWriteMac;
|
|
|
|
// Token: 0x040061AC RID: 25004
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x40")]
|
|
[Token(Token = "0x40061AC")]
|
|
protected readonly TlsMac mReadMac;
|
|
|
|
// Token: 0x040061AD RID: 25005
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x48")]
|
|
[Token(Token = "0x40061AD")]
|
|
private byte[] explicitIV;
|
|
}
|
|
}
|