386 lines
16 KiB
C#
386 lines
16 KiB
C#
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: 0x02001D13 RID: 7443
|
|
[Token(Token = "0x2001D13")]
|
|
public class CcmBlockCipher : IAeadBlockCipher
|
|
{
|
|
// Token: 0x0600B7F5 RID: 47093 RVA: 0x0027C678 File Offset: 0x0027A878
|
|
[Token(Token = "0x600B7F5")]
|
|
[Address(RVA = "0x25B4140", Offset = "0x25B3140", VA = "0x1825B4140")]
|
|
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: 0x0600B7F6 RID: 47094 RVA: 0x0027C6D4 File Offset: 0x0027A8D4
|
|
[Token(Token = "0x600B7F6")]
|
|
[Address(RVA = "0x411530", Offset = "0x410530", VA = "0x180411530", Slot = "17")]
|
|
public virtual IBlockCipher GetUnderlyingCipher()
|
|
{
|
|
return this.cipher;
|
|
}
|
|
|
|
// Token: 0x0600B7F7 RID: 47095 RVA: 0x0027C6E8 File Offset: 0x0027A8E8
|
|
[Token(Token = "0x600B7F7")]
|
|
[Address(RVA = "0x25B33E0", Offset = "0x25B23E0", VA = "0x1825B33E0", Slot = "18")]
|
|
public virtual void Init(bool forEncryption, ICipherParameters parameters)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B7F7)
|
|
|
|
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: 0x17001D14 RID: 7444
|
|
// (get) Token: 0x0600B7F8 RID: 47096 RVA: 0x0027C778 File Offset: 0x0027A978
|
|
[Token(Token = "0x17001D14")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x600B7F8")]
|
|
[Address(RVA = "0x25B42D0", Offset = "0x25B32D0", VA = "0x1825B42D0", Slot = "19")]
|
|
get
|
|
{
|
|
IBlockCipher blockCipher = this.cipher;
|
|
return 0 + "/CCM";
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B7F9 RID: 47097 RVA: 0x0027C7A0 File Offset: 0x0027A9A0
|
|
[Token(Token = "0x600B7F9")]
|
|
[Address(RVA = "0x25B3260", Offset = "0x25B2260", VA = "0x1825B3260", Slot = "20")]
|
|
public virtual int GetBlockSize()
|
|
{
|
|
IBlockCipher blockCipher = this.cipher;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600B7FA RID: 47098 RVA: 0x0027C7BC File Offset: 0x0027A9BC
|
|
[Token(Token = "0x600B7FA")]
|
|
[Address(RVA = "0x25B3670", Offset = "0x25B2670", VA = "0x1825B3670", Slot = "21")]
|
|
public virtual void ProcessAadByte(byte input)
|
|
{
|
|
((IDisposable)this.associatedText).Dispose();
|
|
}
|
|
|
|
// Token: 0x0600B7FB RID: 47099 RVA: 0x0027C7DC File Offset: 0x0027A9DC
|
|
[Token(Token = "0x600B7FB")]
|
|
[Address(RVA = "0x25B36A0", Offset = "0x25B26A0", VA = "0x1825B36A0", Slot = "22")]
|
|
public virtual void ProcessAadBytes(byte[] inBytes, int inOff, int len)
|
|
{
|
|
int num = this.associatedText.Read(inBytes, inOff, len);
|
|
}
|
|
|
|
// Token: 0x0600B7FC RID: 47100 RVA: 0x0027C800 File Offset: 0x0027AA00
|
|
[Token(Token = "0x600B7FC")]
|
|
[Address(RVA = "0x25B36D0", Offset = "0x25B26D0", VA = "0x1825B36D0", Slot = "23")]
|
|
public virtual int ProcessByte(byte input, byte[] outBytes, int outOff)
|
|
{
|
|
MemoryStream memoryStream = this.data;
|
|
return 0;
|
|
}
|
|
|
|
// Token: 0x0600B7FD RID: 47101 RVA: 0x0027C81C File Offset: 0x0027AA1C
|
|
[Token(Token = "0x600B7FD")]
|
|
[Address(RVA = "0x25B3700", Offset = "0x25B2700", VA = "0x1825B3700", 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: 0x0600B7FE RID: 47102 RVA: 0x0027C84C File Offset: 0x0027AA4C
|
|
[Token(Token = "0x600B7FE")]
|
|
[Address(RVA = "0x25B3150", Offset = "0x25B2150", VA = "0x1825B3150", Slot = "25")]
|
|
public virtual int DoFinal(byte[] outBytes, int outOff)
|
|
{
|
|
MemoryStream memoryStream = this.data;
|
|
long length = this.data.Length;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600B7FF RID: 47103 RVA: 0x0027C874 File Offset: 0x0027AA74
|
|
[Token(Token = "0x600B7FF")]
|
|
[Address(RVA = "0x25B4080", Offset = "0x25B3080", VA = "0x1825B4080", Slot = "26")]
|
|
public virtual void Reset()
|
|
{
|
|
IBlockCipher blockCipher = this.cipher;
|
|
MemoryStream memoryStream = this.associatedText;
|
|
((IDisposable)this.data).Dispose();
|
|
}
|
|
|
|
// Token: 0x0600B800 RID: 47104 RVA: 0x0027C8A0 File Offset: 0x0027AAA0
|
|
[Token(Token = "0x600B800")]
|
|
[Address(RVA = "0x25B32B0", Offset = "0x25B22B0", VA = "0x1825B32B0", Slot = "27")]
|
|
public virtual byte[] GetMac()
|
|
{
|
|
byte[] array = this.macBlock;
|
|
int num = this.macSize;
|
|
int num2 = 0;
|
|
return Arrays.CopyOfRange(array, num2, num);
|
|
}
|
|
|
|
// Token: 0x0600B801 RID: 47105 RVA: 0x0027C8C8 File Offset: 0x0027AAC8
|
|
[Token(Token = "0x600B801")]
|
|
[Address(RVA = "0x4242C0", Offset = "0x4232C0", VA = "0x1804242C0", Slot = "28")]
|
|
public virtual int GetUpdateOutputSize(int len)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
// Token: 0x0600B802 RID: 47106 RVA: 0x0027C8D8 File Offset: 0x0027AAD8
|
|
[Token(Token = "0x600B802")]
|
|
[Address(RVA = "0x25B3320", Offset = "0x25B2320", VA = "0x1825B3320", 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: 0x0600B803 RID: 47107 RVA: 0x0027C918 File Offset: 0x0027AB18
|
|
[Token(Token = "0x600B803")]
|
|
[Address(RVA = "0x25B3F90", Offset = "0x25B2F90", VA = "0x1825B3F90", 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: 0x0600B804 RID: 47108 RVA: 0x0027C954 File Offset: 0x0027AB54
|
|
[Token(Token = "0x600B804")]
|
|
[Address(RVA = "0x25B37A0", Offset = "0x25B27A0", VA = "0x1825B37A0", Slot = "31")]
|
|
public virtual int ProcessPacket(byte[] input, int inOff, int inLen, byte[] output, int outOff)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B804)
|
|
|
|
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: 0x0600B805 RID: 47109 RVA: 0x0027CA8C File Offset: 0x0027AC8C
|
|
[Token(Token = "0x600B805")]
|
|
[Address(RVA = "0x25B2C40", Offset = "0x25B1C40", VA = "0x1825B2C40")]
|
|
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: 0x0600B806 RID: 47110 RVA: 0x0027CC1C File Offset: 0x0027AE1C
|
|
[Token(Token = "0x600B806")]
|
|
[Address(RVA = "0x25B3210", Offset = "0x25B2210", VA = "0x1825B3210")]
|
|
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: 0x0600B807 RID: 47111 RVA: 0x0027CC54 File Offset: 0x0027AE54
|
|
[Token(Token = "0x600B807")]
|
|
[Address(RVA = "0x25B3390", Offset = "0x25B2390", VA = "0x1825B3390")]
|
|
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: 0x0400740D RID: 29709
|
|
[Token(Token = "0x400740D")]
|
|
private static readonly int BlockSize;
|
|
|
|
// Token: 0x0400740E RID: 29710
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x400740E")]
|
|
private readonly IBlockCipher cipher;
|
|
|
|
// Token: 0x0400740F RID: 29711
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x400740F")]
|
|
private readonly byte[] macBlock;
|
|
|
|
// Token: 0x04007410 RID: 29712
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4007410")]
|
|
private bool forEncryption;
|
|
|
|
// Token: 0x04007411 RID: 29713
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x4007411")]
|
|
private byte[] nonce;
|
|
|
|
// Token: 0x04007412 RID: 29714
|
|
[FieldOffset(Offset = "0x30")]
|
|
[Token(Token = "0x4007412")]
|
|
private byte[] initialAssociatedText;
|
|
|
|
// Token: 0x04007413 RID: 29715
|
|
[FieldOffset(Offset = "0x38")]
|
|
[Token(Token = "0x4007413")]
|
|
private int macSize;
|
|
|
|
// Token: 0x04007414 RID: 29716
|
|
[FieldOffset(Offset = "0x40")]
|
|
[Token(Token = "0x4007414")]
|
|
private ICipherParameters keyParam;
|
|
|
|
// Token: 0x04007415 RID: 29717
|
|
[FieldOffset(Offset = "0x48")]
|
|
[Token(Token = "0x4007415")]
|
|
private readonly MemoryStream associatedText;
|
|
|
|
// Token: 0x04007416 RID: 29718
|
|
[FieldOffset(Offset = "0x50")]
|
|
[Token(Token = "0x4007416")]
|
|
private readonly MemoryStream data;
|
|
}
|
|
}
|