using System; using System.IO; using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Macs; using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities; using Cpp2IlInjected; namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Modes { // Token: 0x02001C33 RID: 7219 [Token(Token = "0x2001C33")] public class CcmBlockCipher : IAeadBlockCipher { // Token: 0x0600B427 RID: 46119 RVA: 0x00273480 File Offset: 0x00271680 [Token(Token = "0x600B427")] [Address(RVA = "0x1C1D1A0", Offset = "0x1C1BFA0", VA = "0x181C1D1A0")] 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: 0x0600B428 RID: 46120 RVA: 0x002734DC File Offset: 0x002716DC [Token(Token = "0x600B428")] [Address(RVA = "0x3F6E20", Offset = "0x3F5C20", VA = "0x1803F6E20", Slot = "17")] public virtual IBlockCipher GetUnderlyingCipher() { return this.cipher; } // Token: 0x0600B429 RID: 46121 RVA: 0x002734F0 File Offset: 0x002716F0 [Token(Token = "0x600B429")] [Address(RVA = "0x1C1C440", Offset = "0x1C1B240", VA = "0x181C1C440", Slot = "18")] public virtual void Init(bool forEncryption, ICipherParameters parameters) { /* An exception occurred when decompiling this method (0600B429) 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: 0x17001C77 RID: 7287 // (get) Token: 0x0600B42A RID: 46122 RVA: 0x00273580 File Offset: 0x00271780 [Token(Token = "0x17001C77")] public virtual string AlgorithmName { [Token(Token = "0x600B42A")] [Address(RVA = "0x1C1D330", Offset = "0x1C1C130", VA = "0x181C1D330", Slot = "19")] get { IBlockCipher blockCipher = this.cipher; return 0 + "/CCM"; } } // Token: 0x0600B42B RID: 46123 RVA: 0x002735A8 File Offset: 0x002717A8 [Token(Token = "0x600B42B")] [Address(RVA = "0x1C1C2C0", Offset = "0x1C1B0C0", VA = "0x181C1C2C0", Slot = "20")] public virtual int GetBlockSize() { IBlockCipher blockCipher = this.cipher; throw new NullReferenceException(); } // Token: 0x0600B42C RID: 46124 RVA: 0x002735C4 File Offset: 0x002717C4 [Token(Token = "0x600B42C")] [Address(RVA = "0x1C1C6D0", Offset = "0x1C1B4D0", VA = "0x181C1C6D0", Slot = "21")] public virtual void ProcessAadByte(byte input) { ((IDisposable)this.associatedText).Dispose(); } // Token: 0x0600B42D RID: 46125 RVA: 0x002735E4 File Offset: 0x002717E4 [Token(Token = "0x600B42D")] [Address(RVA = "0x1C1C700", Offset = "0x1C1B500", VA = "0x181C1C700", Slot = "22")] public virtual void ProcessAadBytes(byte[] inBytes, int inOff, int len) { int num = this.associatedText.Read(inBytes, inOff, len); } // Token: 0x0600B42E RID: 46126 RVA: 0x00273608 File Offset: 0x00271808 [Token(Token = "0x600B42E")] [Address(RVA = "0x1C1C730", Offset = "0x1C1B530", VA = "0x181C1C730", Slot = "23")] public virtual int ProcessByte(byte input, byte[] outBytes, int outOff) { MemoryStream memoryStream = this.data; return 0; } // Token: 0x0600B42F RID: 46127 RVA: 0x00273624 File Offset: 0x00271824 [Token(Token = "0x600B42F")] [Address(RVA = "0x1C1C760", Offset = "0x1C1B560", VA = "0x181C1C760", 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: 0x0600B430 RID: 46128 RVA: 0x00273654 File Offset: 0x00271854 [Token(Token = "0x600B430")] [Address(RVA = "0x1C1C1B0", Offset = "0x1C1AFB0", VA = "0x181C1C1B0", Slot = "25")] public virtual int DoFinal(byte[] outBytes, int outOff) { MemoryStream memoryStream = this.data; long length = this.data.Length; throw new NullReferenceException(); } // Token: 0x0600B431 RID: 46129 RVA: 0x0027367C File Offset: 0x0027187C [Token(Token = "0x600B431")] [Address(RVA = "0x1C1D0E0", Offset = "0x1C1BEE0", VA = "0x181C1D0E0", Slot = "26")] public virtual void Reset() { IBlockCipher blockCipher = this.cipher; MemoryStream memoryStream = this.associatedText; ((IDisposable)this.data).Dispose(); } // Token: 0x0600B432 RID: 46130 RVA: 0x002736A8 File Offset: 0x002718A8 [Token(Token = "0x600B432")] [Address(RVA = "0x1C1C310", Offset = "0x1C1B110", VA = "0x181C1C310", Slot = "27")] public virtual byte[] GetMac() { byte[] array = this.macBlock; int num = this.macSize; int num2 = 0; return Arrays.CopyOfRange(array, num2, num); } // Token: 0x0600B433 RID: 46131 RVA: 0x002736D0 File Offset: 0x002718D0 [Token(Token = "0x600B433")] [Address(RVA = "0x43E630", Offset = "0x43D430", VA = "0x18043E630", Slot = "28")] public virtual int GetUpdateOutputSize(int len) { return 0; } // Token: 0x0600B434 RID: 46132 RVA: 0x002736E0 File Offset: 0x002718E0 [Token(Token = "0x600B434")] [Address(RVA = "0x1C1C380", Offset = "0x1C1B180", VA = "0x181C1C380", 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: 0x0600B435 RID: 46133 RVA: 0x00273720 File Offset: 0x00271920 [Token(Token = "0x600B435")] [Address(RVA = "0x1C1CFF0", Offset = "0x1C1BDF0", VA = "0x181C1CFF0", 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: 0x0600B436 RID: 46134 RVA: 0x0027375C File Offset: 0x0027195C [Token(Token = "0x600B436")] [Address(RVA = "0x1C1C800", Offset = "0x1C1B600", VA = "0x181C1C800", Slot = "31")] public virtual int ProcessPacket(byte[] input, int inOff, int inLen, byte[] output, int outOff) { /* An exception occurred when decompiling this method (0600B436) 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: 0x0600B437 RID: 46135 RVA: 0x00273894 File Offset: 0x00271A94 [Token(Token = "0x600B437")] [Address(RVA = "0x1C1BCA0", Offset = "0x1C1AAA0", VA = "0x181C1BCA0")] 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: 0x0600B438 RID: 46136 RVA: 0x00273A24 File Offset: 0x00271C24 [Token(Token = "0x600B438")] [Address(RVA = "0x1C1C270", Offset = "0x1C1B070", VA = "0x181C1C270")] 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: 0x0600B439 RID: 46137 RVA: 0x00273A5C File Offset: 0x00271C5C [Token(Token = "0x600B439")] [Address(RVA = "0x1C1C3F0", Offset = "0x1C1B1F0", VA = "0x181C1C3F0")] 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: 0x04007254 RID: 29268 [Token(Token = "0x4007254")] private static readonly int BlockSize; // Token: 0x04007255 RID: 29269 [FieldOffset(Offset = "0x10")] [Token(Token = "0x4007255")] private readonly IBlockCipher cipher; // Token: 0x04007256 RID: 29270 [FieldOffset(Offset = "0x18")] [Token(Token = "0x4007256")] private readonly byte[] macBlock; // Token: 0x04007257 RID: 29271 [FieldOffset(Offset = "0x20")] [Token(Token = "0x4007257")] private bool forEncryption; // Token: 0x04007258 RID: 29272 [FieldOffset(Offset = "0x28")] [Token(Token = "0x4007258")] private byte[] nonce; // Token: 0x04007259 RID: 29273 [FieldOffset(Offset = "0x30")] [Token(Token = "0x4007259")] private byte[] initialAssociatedText; // Token: 0x0400725A RID: 29274 [FieldOffset(Offset = "0x38")] [Token(Token = "0x400725A")] private int macSize; // Token: 0x0400725B RID: 29275 [FieldOffset(Offset = "0x40")] [Token(Token = "0x400725B")] private ICipherParameters keyParam; // Token: 0x0400725C RID: 29276 [FieldOffset(Offset = "0x48")] [Token(Token = "0x400725C")] private readonly MemoryStream associatedText; // Token: 0x0400725D RID: 29277 [FieldOffset(Offset = "0x50")] [Token(Token = "0x400725D")] private readonly MemoryStream data; } }