Files
Jan2021-Cpp2Il-Dump/Assembly-CSharp/BestHTTP/SecureProtocol/Org/BouncyCastle/Crypto/Modes/CcmBlockCipher.cs
T
2026-04-08 23:40:05 +02:00

388 lines
16 KiB
C#

using System;
using System.IO;
using System.Runtime.InteropServices;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Macs;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Modes
{
// Token: 0x02001656 RID: 5718
[Token(Token = "0x2001656")]
[StructLayout(3)]
public class CcmBlockCipher : IAeadBlockCipher
{
// Token: 0x0600984D RID: 38989 RVA: 0x0021BE64 File Offset: 0x0021A064
[Token(Token = "0x600984D")]
[Address(RVA = "0x20E7090", Offset = "0x20E5A90", VA = "0x1820E7090")]
public CcmBlockCipher(IBlockCipher cipher)
{
MemoryStream memoryStream = new MemoryStream();
this.associatedText = memoryStream;
MemoryStream memoryStream2 = new MemoryStream();
this.data = memoryStream2;
base..ctor();
this.cipher = cipher;
byte[] array = new byte[CcmBlockCipher.BlockSize];
this.macBlock = array;
}
// Token: 0x0600984E RID: 38990 RVA: 0x0021BEC4 File Offset: 0x0021A0C4
[Token(Token = "0x600984E")]
[Address(RVA = "0x3C39A0", Offset = "0x3C23A0", VA = "0x1803C39A0", Slot = "17")]
public virtual IBlockCipher GetUnderlyingCipher()
{
return this.cipher;
}
// Token: 0x0600984F RID: 38991 RVA: 0x0021BED8 File Offset: 0x0021A0D8
[Token(Token = "0x600984F")]
[Address(RVA = "0x20E6330", Offset = "0x20E4D30", VA = "0x1820E6330", Slot = "18")]
public virtual void Init(bool forEncryption, ICipherParameters parameters)
{
/*
An exception occurred when decompiling this method (0600984F)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Modes.CcmBlockCipher::Init(System.Boolean,BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.ICipherParameters)
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_78:
stloc:ArgumentException(var_11_82, newobj:ArgumentException(ArgumentException::.ctor, ldstr:string("invalid parameters passed to CCM")))
}
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: 0x17001876 RID: 6262
// (get) Token: 0x06009850 RID: 38992 RVA: 0x0021BF68 File Offset: 0x0021A168
[Token(Token = "0x17001876")]
public virtual string AlgorithmName
{
[Token(Token = "0x6009850")]
[Address(RVA = "0x20E7220", Offset = "0x20E5C20", VA = "0x1820E7220", Slot = "19")]
get
{
IBlockCipher blockCipher = this.cipher;
return 0 + "/CCM";
}
}
// Token: 0x06009851 RID: 38993 RVA: 0x0021BF90 File Offset: 0x0021A190
[Token(Token = "0x6009851")]
[Address(RVA = "0x20E61B0", Offset = "0x20E4BB0", VA = "0x1820E61B0", Slot = "20")]
public virtual int GetBlockSize()
{
IBlockCipher blockCipher = this.cipher;
throw new NullReferenceException();
}
// Token: 0x06009852 RID: 38994 RVA: 0x0021BFAC File Offset: 0x0021A1AC
[Token(Token = "0x6009852")]
[Address(RVA = "0x20E65C0", Offset = "0x20E4FC0", VA = "0x1820E65C0", Slot = "21")]
public virtual void ProcessAadByte(byte input)
{
((IDisposable)this.associatedText).Dispose();
}
// Token: 0x06009853 RID: 38995 RVA: 0x0021BFCC File Offset: 0x0021A1CC
[Token(Token = "0x6009853")]
[Address(RVA = "0x20E65F0", Offset = "0x20E4FF0", VA = "0x1820E65F0", Slot = "22")]
public virtual void ProcessAadBytes(byte[] inBytes, int inOff, int len)
{
int num = this.associatedText.Read(inBytes, inOff, len);
}
// Token: 0x06009854 RID: 38996 RVA: 0x0021BFF0 File Offset: 0x0021A1F0
[Token(Token = "0x6009854")]
[Address(RVA = "0x20E6620", Offset = "0x20E5020", VA = "0x1820E6620", Slot = "23")]
public virtual int ProcessByte(byte input, byte[] outBytes, int outOff)
{
MemoryStream memoryStream = this.data;
return 0;
}
// Token: 0x06009855 RID: 38997 RVA: 0x0021C00C File Offset: 0x0021A20C
[Token(Token = "0x6009855")]
[Address(RVA = "0x20E6650", Offset = "0x20E5050", VA = "0x1820E6650", Slot = "24")]
public virtual int ProcessBytes(byte[] inBytes, int inOff, int inLen, byte[] outBytes, int outOff)
{
Check.DataLength(inBytes, inOff, inOff, "Input buffer too short");
int num = this.data.ReadByte();
return 0;
}
// Token: 0x06009856 RID: 38998 RVA: 0x0021C03C File Offset: 0x0021A23C
[Token(Token = "0x6009856")]
[Address(RVA = "0x20E60A0", Offset = "0x20E4AA0", VA = "0x1820E60A0", Slot = "25")]
public virtual int DoFinal(byte[] outBytes, int outOff)
{
MemoryStream memoryStream = this.data;
long length = this.data.Length;
throw new NullReferenceException();
}
// Token: 0x06009857 RID: 38999 RVA: 0x0021C064 File Offset: 0x0021A264
[Token(Token = "0x6009857")]
[Address(RVA = "0x20E6FD0", Offset = "0x20E59D0", VA = "0x1820E6FD0", Slot = "26")]
public virtual void Reset()
{
IBlockCipher blockCipher = this.cipher;
MemoryStream memoryStream = this.associatedText;
((IDisposable)this.data).Dispose();
}
// Token: 0x06009858 RID: 39000 RVA: 0x0021C090 File Offset: 0x0021A290
[Token(Token = "0x6009858")]
[Address(RVA = "0x20E6200", Offset = "0x20E4C00", VA = "0x1820E6200", Slot = "27")]
public virtual byte[] GetMac()
{
byte[] array = this.macBlock;
int num = this.macSize;
int num2 = 0;
return Arrays.CopyOfRange(array, num2, num);
}
// Token: 0x06009859 RID: 39001 RVA: 0x0021C0B8 File Offset: 0x0021A2B8
[Token(Token = "0x6009859")]
[Address(RVA = "0x3F8880", Offset = "0x3F7280", VA = "0x1803F8880", Slot = "28")]
public virtual int GetUpdateOutputSize(int len)
{
return 0;
}
// Token: 0x0600985A RID: 39002 RVA: 0x0021C0C8 File Offset: 0x0021A2C8
[Token(Token = "0x600985A")]
[Address(RVA = "0x20E6270", Offset = "0x20E4C70", VA = "0x1820E6270", Slot = "29")]
public virtual int GetOutputSize(int len)
{
bool flag = this.data.CanWrite;
int num = this.macSize;
flag = (flag ? 1 : 0) + len != 0;
if (!this.forEncryption)
{
if ((flag ? 1 : 0) < num)
{
return 0;
}
flag = (flag ? 1 : 0) - num != 0;
}
flag = (flag ? 1 : 0) + num != 0;
throw new NullReferenceException();
}
// Token: 0x0600985B RID: 39003 RVA: 0x0021C108 File Offset: 0x0021A308
[Token(Token = "0x600985B")]
[Address(RVA = "0x20E6EE0", Offset = "0x20E58E0", VA = "0x1820E6EE0", Slot = "30")]
public virtual byte[] ProcessPacket(byte[] input, int inOff, int inLen)
{
int num = this.macSize;
if (!this.forEncryption)
{
}
byte[] array = new byte[input];
byte[] array2 = this.ProcessPacket(input, inOff, inLen);
return array;
}
// Token: 0x0600985C RID: 39004 RVA: 0x0021C144 File Offset: 0x0021A344
[Token(Token = "0x600985C")]
[Address(RVA = "0x20E66F0", Offset = "0x20E50F0", VA = "0x1820E66F0", Slot = "31")]
public virtual int ProcessPacket(byte[] input, int inOff, int inLen, byte[] output, int outOff)
{
/*
An exception occurred when decompiling this method (0600985C)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Int32 BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Modes.CcmBlockCipher::ProcessPacket(System.Byte[],System.Int32,System.Int32,System.Byte[],System.Int32)
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_11D:
stloc:InvalidCipherTextException(var_24_127, newobj:InvalidCipherTextException(InvalidCipherTextException::.ctor, ldstr:string("mac check in CCM failed")))
}
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: 0x0600985D RID: 39005 RVA: 0x0021C27C File Offset: 0x0021A47C
[Token(Token = "0x600985D")]
[Address(RVA = "0x20E5B90", Offset = "0x20E4590", VA = "0x1820E5B90")]
private int CalculateMac(byte[] data, int dataOff, int dataLen, byte[] macBlock)
{
int num;
CbcBlockCipherMac cbcBlockCipherMac = new CbcBlockCipherMac(this.cipher, dataOff, num);
num = 0;
byte[] array = new byte[16];
bool flag = this.associatedText.CanWrite;
byte[] array2 = this.initialAssociatedText;
if (array2 == 0)
{
}
int length = array2.Length;
flag = (flag ? 1 : 0) + length != 0;
if (flag > false)
{
}
uint num2;
flag = (flag ? 1U : 0U) - num2 != 0U;
flag = flag - typeof(IMac).TypeHandle != null;
array[0] = (flag ? 1 : 0);
byte[] array3 = this.nonce;
uint num3;
array[0] = (byte)num3;
byte[] array4 = this.nonce;
int length2 = array4.Length;
int num4 = 0;
uint num5;
Array.Copy(array4, num4, array, (int)num5, length2);
if (dataLen > 0)
{
int num6 = array.Length;
num6 -= (int)num5;
num5 += (uint)1;
}
int length3 = array.Length;
bool flag2 = this.associatedText.CanWrite;
byte[] array5 = this.initialAssociatedText;
int num7 = 0;
if (array5 == 0)
{
}
flag2 = (flag2 ? 1 : 0) + num7 != 0;
if (flag2 > false)
{
bool canWrite = this.associatedText.CanWrite;
if (this.initialAssociatedText == 0)
{
}
byte[] array6 = this.initialAssociatedText;
if (array6 != 0)
{
int length4 = array6.Length;
}
long length5 = this.associatedText.Length;
MemoryStream memoryStream = this.associatedText;
MemoryStream memoryStream2 = this.associatedText;
long length6 = memoryStream2.Length;
int num8 = 0;
if (memoryStream2 < 0)
{
}
uint num9;
if (length6 < (long)num9)
{
num9 = (uint)((long)num9 - length6);
if (num8 < cbcBlockCipherMac)
{
num8 += num8;
num8++;
}
while (num8 != cbcBlockCipherMac)
{
}
}
}
int num10 = 0;
num10 += 3;
num10 += 19;
throw new NullReferenceException();
}
// Token: 0x0600985E RID: 39006 RVA: 0x0021C40C File Offset: 0x0021A60C
[Token(Token = "0x600985E")]
[Address(RVA = "0x20E6160", Offset = "0x20E4B60", VA = "0x1820E6160")]
private int GetAssociatedTextLength()
{
bool flag = this.associatedText.CanWrite;
byte[] array = this.initialAssociatedText;
if (array == 0)
{
flag = flag + array != null;
}
int length = array.Length;
flag = (flag ? 1 : 0) + length != 0;
throw new NullReferenceException();
}
// Token: 0x0600985F RID: 39007 RVA: 0x0021C444 File Offset: 0x0021A644
[Token(Token = "0x600985F")]
[Address(RVA = "0x20E62E0", Offset = "0x20E4CE0", VA = "0x1820E62E0")]
private bool HasAssociatedText()
{
bool flag = this.associatedText.CanWrite;
byte[] array = this.initialAssociatedText;
if (array == 0)
{
flag = flag + array != null;
return flag > false;
}
int length = array.Length;
flag = (flag ? 1 : 0) + length != 0;
return flag > false;
}
// Token: 0x04006411 RID: 25617
[Token(Token = "0x4006411")]
private static readonly int BlockSize;
// Token: 0x04006412 RID: 25618
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
[Token(Token = "0x4006412")]
private readonly IBlockCipher cipher;
// Token: 0x04006413 RID: 25619
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
[Token(Token = "0x4006413")]
private readonly byte[] macBlock;
// Token: 0x04006414 RID: 25620
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
[Token(Token = "0x4006414")]
private bool forEncryption;
// Token: 0x04006415 RID: 25621
[global::Cpp2IlInjected.FieldOffset(Offset = "0x28")]
[Token(Token = "0x4006415")]
private byte[] nonce;
// Token: 0x04006416 RID: 25622
[global::Cpp2IlInjected.FieldOffset(Offset = "0x30")]
[Token(Token = "0x4006416")]
private byte[] initialAssociatedText;
// Token: 0x04006417 RID: 25623
[global::Cpp2IlInjected.FieldOffset(Offset = "0x38")]
[Token(Token = "0x4006417")]
private int macSize;
// Token: 0x04006418 RID: 25624
[global::Cpp2IlInjected.FieldOffset(Offset = "0x40")]
[Token(Token = "0x4006418")]
private ICipherParameters keyParam;
// Token: 0x04006419 RID: 25625
[global::Cpp2IlInjected.FieldOffset(Offset = "0x48")]
[Token(Token = "0x4006419")]
private readonly MemoryStream associatedText;
// Token: 0x0400641A RID: 25626
[global::Cpp2IlInjected.FieldOffset(Offset = "0x50")]
[Token(Token = "0x400641A")]
private readonly MemoryStream data;
}
}