Files
niko c12fbe3fc6 m
2026-04-12 16:51:38 +02:00

272 lines
9.6 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: 0x02001C42 RID: 7234
[Token(Token = "0x2001C42")]
public class TlsBlockCipher : TlsCipher
{
// Token: 0x17001C39 RID: 7225
// (get) Token: 0x0600B1EE RID: 45550 RVA: 0x0026720C File Offset: 0x0026540C
[Token(Token = "0x17001C39")]
public virtual TlsMac WriteMac
{
[Token(Token = "0x600B1EE")]
[Address(RVA = "0x41CEF0", Offset = "0x41BEF0", VA = "0x18041CEF0", Slot = "7")]
get
{
return this.mWriteMac;
}
}
// Token: 0x17001C3A RID: 7226
// (get) Token: 0x0600B1EF RID: 45551 RVA: 0x00267220 File Offset: 0x00265420
[Token(Token = "0x17001C3A")]
public virtual TlsMac ReadMac
{
[Token(Token = "0x600B1EF")]
[Address(RVA = "0x417680", Offset = "0x416680", VA = "0x180417680", Slot = "8")]
get
{
return this.mReadMac;
}
}
// Token: 0x0600B1F0 RID: 45552 RVA: 0x00267234 File Offset: 0x00265434
[Token(Token = "0x600B1F0")]
[Address(RVA = "0x49BF20", Offset = "0x49AF20", VA = "0x18049BF20")]
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: 0x0600B1F1 RID: 45553 RVA: 0x0026733C File Offset: 0x0026553C
[Token(Token = "0x600B1F1")]
[Address(RVA = "0x49BE40", Offset = "0x49AE40", VA = "0x18049BE40", 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: 0x0600B1F2 RID: 45554 RVA: 0x00267374 File Offset: 0x00265574
[Token(Token = "0x600B1F2")]
[Address(RVA = "0x49B920", Offset = "0x49A920", VA = "0x18049B920", 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: 0x0600B1F3 RID: 45555 RVA: 0x00267470 File Offset: 0x00265670
[Token(Token = "0x600B1F3")]
[Address(RVA = "0x49B460", Offset = "0x49A460", VA = "0x18049B460", Slot = "11")]
public virtual byte[] DecodeCiphertext(long seqNo, byte type, byte[] ciphertext, int offset, int len)
{
/*
An exception occurred when decompiling this method (0600B1F3)
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: 0x0600B1F4 RID: 45556 RVA: 0x00267534 File Offset: 0x00265734
[Token(Token = "0x600B1F4")]
[Address(RVA = "0x49B200", Offset = "0x49A200", VA = "0x18049B200", 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: 0x0600B1F5 RID: 45557 RVA: 0x00267570 File Offset: 0x00265770
[Token(Token = "0x600B1F5")]
[Address(RVA = "0x49B3B0", Offset = "0x49A3B0", VA = "0x18049B3B0", Slot = "13")]
protected virtual int ChooseExtraPadBlocks(SecureRandom r, int max)
{
int num;
return Math.Min(num, max);
}
// Token: 0x0600B1F6 RID: 45558 RVA: 0x0026758C File Offset: 0x0026578C
[Token(Token = "0x600B1F6")]
[Address(RVA = "0x49BF00", Offset = "0x49AF00", VA = "0x18049BF00", 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: 0x040071A1 RID: 29089
[FieldOffset(Offset = "0x10")]
[Token(Token = "0x40071A1")]
protected readonly TlsContext context;
// Token: 0x040071A2 RID: 29090
[FieldOffset(Offset = "0x18")]
[Token(Token = "0x40071A2")]
protected readonly byte[] randomData;
// Token: 0x040071A3 RID: 29091
[FieldOffset(Offset = "0x20")]
[Token(Token = "0x40071A3")]
protected readonly bool useExplicitIV;
// Token: 0x040071A4 RID: 29092
[FieldOffset(Offset = "0x21")]
[Token(Token = "0x40071A4")]
protected readonly bool encryptThenMac;
// Token: 0x040071A5 RID: 29093
[FieldOffset(Offset = "0x28")]
[Token(Token = "0x40071A5")]
protected readonly IBlockCipher encryptCipher;
// Token: 0x040071A6 RID: 29094
[FieldOffset(Offset = "0x30")]
[Token(Token = "0x40071A6")]
protected readonly IBlockCipher decryptCipher;
// Token: 0x040071A7 RID: 29095
[FieldOffset(Offset = "0x38")]
[Token(Token = "0x40071A7")]
protected readonly TlsMac mWriteMac;
// Token: 0x040071A8 RID: 29096
[FieldOffset(Offset = "0x40")]
[Token(Token = "0x40071A8")]
protected readonly TlsMac mReadMac;
// Token: 0x040071A9 RID: 29097
[FieldOffset(Offset = "0x48")]
[Token(Token = "0x40071A9")]
private byte[] explicitIV;
}
}