277 lines
9.7 KiB
C#
277 lines
9.7 KiB
C#
using System;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Tls
|
|
{
|
|
// Token: 0x02001B62 RID: 7010
|
|
[Token(Token = "0x2001B62")]
|
|
public class TlsBlockCipher : TlsCipher
|
|
{
|
|
// Token: 0x17001B9C RID: 7068
|
|
// (get) Token: 0x0600AE20 RID: 44576 RVA: 0x0025E168 File Offset: 0x0025C368
|
|
[Token(Token = "0x17001B9C")]
|
|
public virtual TlsMac WriteMac
|
|
{
|
|
[Token(Token = "0x600AE20")]
|
|
[Address(RVA = "0x3F63D0", Offset = "0x3F51D0", VA = "0x1803F63D0", Slot = "7")]
|
|
get
|
|
{
|
|
return this.mWriteMac;
|
|
}
|
|
}
|
|
|
|
// Token: 0x17001B9D RID: 7069
|
|
// (get) Token: 0x0600AE21 RID: 44577 RVA: 0x0025E17C File Offset: 0x0025C37C
|
|
[Token(Token = "0x17001B9D")]
|
|
public virtual TlsMac ReadMac
|
|
{
|
|
[Token(Token = "0x600AE21")]
|
|
[Address(RVA = "0x408890", Offset = "0x407690", VA = "0x180408890", Slot = "8")]
|
|
get
|
|
{
|
|
return this.mReadMac;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600AE22 RID: 44578 RVA: 0x0025E190 File Offset: 0x0025C390
|
|
[Token(Token = "0x600AE22")]
|
|
[Address(RVA = "0x197DD90", Offset = "0x197CB90", VA = "0x18197DD90")]
|
|
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: 0x0600AE23 RID: 44579 RVA: 0x0025E298 File Offset: 0x0025C498
|
|
[Token(Token = "0x600AE23")]
|
|
[Address(RVA = "0x197DCB0", Offset = "0x197CAB0", VA = "0x18197DCB0", 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: 0x0600AE24 RID: 44580 RVA: 0x0025E2D0 File Offset: 0x0025C4D0
|
|
[Token(Token = "0x600AE24")]
|
|
[Address(RVA = "0x197D7D0", Offset = "0x197C5D0", VA = "0x18197D7D0", 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;
|
|
}
|
|
bool flag;
|
|
bool flag2;
|
|
if (!flag && !flag2)
|
|
{
|
|
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: 0x0600AE25 RID: 44581 RVA: 0x0025E3D4 File Offset: 0x0025C5D4
|
|
[Token(Token = "0x600AE25")]
|
|
[Address(RVA = "0x197D310", Offset = "0x197C110", VA = "0x18197D310", Slot = "11")]
|
|
public virtual byte[] DecodeCiphertext(long seqNo, byte type, byte[] ciphertext, int offset, int len)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600AE25)
|
|
|
|
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: 0x0600AE26 RID: 44582 RVA: 0x0025E498 File Offset: 0x0025C698
|
|
[Token(Token = "0x600AE26")]
|
|
[Address(RVA = "0x197D0B0", Offset = "0x197BEB0", VA = "0x18197D0B0", 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: 0x0600AE27 RID: 44583 RVA: 0x0025E4D4 File Offset: 0x0025C6D4
|
|
[Token(Token = "0x600AE27")]
|
|
[Address(RVA = "0x197D260", Offset = "0x197C060", VA = "0x18197D260", Slot = "13")]
|
|
protected virtual int ChooseExtraPadBlocks(SecureRandom r, int max)
|
|
{
|
|
int num;
|
|
return Math.Min(num, max);
|
|
}
|
|
|
|
// Token: 0x0600AE28 RID: 44584 RVA: 0x0025E4F0 File Offset: 0x0025C6F0
|
|
[Token(Token = "0x600AE28")]
|
|
[Address(RVA = "0x197DD70", Offset = "0x197CB70", VA = "0x18197DD70", 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: 0x04006FE8 RID: 28648
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x4006FE8")]
|
|
protected readonly TlsContext context;
|
|
|
|
// Token: 0x04006FE9 RID: 28649
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x4006FE9")]
|
|
protected readonly byte[] randomData;
|
|
|
|
// Token: 0x04006FEA RID: 28650
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4006FEA")]
|
|
protected readonly bool useExplicitIV;
|
|
|
|
// Token: 0x04006FEB RID: 28651
|
|
[FieldOffset(Offset = "0x21")]
|
|
[Token(Token = "0x4006FEB")]
|
|
protected readonly bool encryptThenMac;
|
|
|
|
// Token: 0x04006FEC RID: 28652
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x4006FEC")]
|
|
protected readonly IBlockCipher encryptCipher;
|
|
|
|
// Token: 0x04006FED RID: 28653
|
|
[FieldOffset(Offset = "0x30")]
|
|
[Token(Token = "0x4006FED")]
|
|
protected readonly IBlockCipher decryptCipher;
|
|
|
|
// Token: 0x04006FEE RID: 28654
|
|
[FieldOffset(Offset = "0x38")]
|
|
[Token(Token = "0x4006FEE")]
|
|
protected readonly TlsMac mWriteMac;
|
|
|
|
// Token: 0x04006FEF RID: 28655
|
|
[FieldOffset(Offset = "0x40")]
|
|
[Token(Token = "0x4006FEF")]
|
|
protected readonly TlsMac mReadMac;
|
|
|
|
// Token: 0x04006FF0 RID: 28656
|
|
[FieldOffset(Offset = "0x48")]
|
|
[Token(Token = "0x4006FF0")]
|
|
private byte[] explicitIV;
|
|
}
|
|
}
|