209 lines
7.2 KiB
C#
209 lines
7.2 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Macs;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Utilities;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
|
using Cpp2IlInjected;
|
|
using Hjg.Pngcs;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Tls
|
|
{
|
|
// Token: 0x0200152D RID: 5421
|
|
[Token(Token = "0x200152D")]
|
|
[StructLayout(3)]
|
|
public class Chacha20Poly1305 : TlsCipher
|
|
{
|
|
// Token: 0x06009051 RID: 36945 RVA: 0x00200138 File Offset: 0x001FE338
|
|
[Token(Token = "0x6009051")]
|
|
[Address(RVA = "0x1E78260", Offset = "0x1E76C60", VA = "0x181E78260")]
|
|
public Chacha20Poly1305(TlsContext context)
|
|
{
|
|
do
|
|
{
|
|
base..ctor();
|
|
}
|
|
while (!TlsUtilities.IsTlsV12(context));
|
|
this.context = context;
|
|
byte[] array = TlsUtilities.CalculateKeyBlock(context, 88);
|
|
int num;
|
|
KeyParameter keyParameter = new KeyParameter(array, num, 32);
|
|
num = 0;
|
|
KeyParameter keyParameter2 = new KeyParameter(array, 32, 32);
|
|
byte[] array2 = Arrays.CopyOfRange(array, 64, 76);
|
|
byte[] array3 = Arrays.CopyOfRange(array, 76, 88);
|
|
ChaCha7539Engine chaCha7539Engine = new ChaCha7539Engine();
|
|
this.encryptCipher = chaCha7539Engine;
|
|
ChaCha7539Engine chaCha7539Engine2 = new ChaCha7539Engine();
|
|
this.decryptCipher = chaCha7539Engine2;
|
|
if (chaCha7539Engine2 == 0)
|
|
{
|
|
}
|
|
this.encryptIV = array3;
|
|
this.decryptIV = array2;
|
|
ChaCha7539Engine chaCha7539Engine3 = this.encryptCipher;
|
|
byte[] array4 = this.encryptIV;
|
|
ParametersWithIV parametersWithIV = new ParametersWithIV(keyParameter2, array4);
|
|
chaCha7539Engine3.Reset();
|
|
ChaCha7539Engine chaCha7539Engine4 = this.decryptCipher;
|
|
byte[] array5 = this.decryptIV;
|
|
ParametersWithIV parametersWithIV2 = new ParametersWithIV(keyParameter, array5);
|
|
string algorithmName = ((IStreamCipher)chaCha7539Engine4).AlgorithmName;
|
|
}
|
|
|
|
// Token: 0x06009052 RID: 36946 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x6009052")]
|
|
[Address(RVA = "0x1E77F50", Offset = "0x1E76950", VA = "0x181E77F50", Slot = "7")]
|
|
public virtual int GetPlaintextLimit(int ciphertextLimit)
|
|
{
|
|
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
|
|
}
|
|
|
|
// Token: 0x06009053 RID: 36947 RVA: 0x00200210 File Offset: 0x001FE410
|
|
[Token(Token = "0x6009053")]
|
|
[Address(RVA = "0x1E77B80", Offset = "0x1E76580", VA = "0x181E77B80", Slot = "8")]
|
|
public virtual byte[] EncodePlaintext(long seqNo, byte type, byte[] plaintext, int offset, int len)
|
|
{
|
|
byte[] array = this.encryptIV;
|
|
byte[] array2 = new byte[this.encryptCipher];
|
|
this.encryptCipher.AdvanceCounter();
|
|
return array2;
|
|
}
|
|
|
|
// Token: 0x06009054 RID: 36948 RVA: 0x00200244 File Offset: 0x001FE444
|
|
[Token(Token = "0x6009054")]
|
|
[Address(RVA = "0x1E77970", Offset = "0x1E76370", VA = "0x181E77970", Slot = "9")]
|
|
public virtual byte[] DecodeCiphertext(long seqNo, byte type, byte[] ciphertext, int offset, int len)
|
|
{
|
|
bool flag;
|
|
do
|
|
{
|
|
byte[] array = this.decryptIV;
|
|
}
|
|
while (!flag);
|
|
byte[] array3;
|
|
byte[] array2 = new byte[array3];
|
|
this.decryptCipher.AdvanceCounter();
|
|
return array2;
|
|
}
|
|
|
|
// Token: 0x06009055 RID: 36949 RVA: 0x00200274 File Offset: 0x001FE474
|
|
[Token(Token = "0x6009055")]
|
|
[Address(RVA = "0x1E77F60", Offset = "0x1E76960", VA = "0x181E77F60", Slot = "10")]
|
|
protected virtual KeyParameter InitRecord(IStreamCipher cipher, bool forEncryption, long seqNo, byte[] iv)
|
|
{
|
|
int num = 0;
|
|
KeyParameter keyParameter;
|
|
if (num < keyParameter)
|
|
{
|
|
num += num;
|
|
num++;
|
|
}
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009056 RID: 36950 RVA: 0x00200294 File Offset: 0x001FE494
|
|
[Token(Token = "0x6009056")]
|
|
[Address(RVA = "0x1E77740", Offset = "0x1E76140", VA = "0x181E77740", Slot = "11")]
|
|
protected virtual byte[] CalculateNonce(long seqNo, byte[] iv)
|
|
{
|
|
byte[] array = new byte[12];
|
|
TlsUtilities.WriteUint64(seqNo, array, 4);
|
|
int num = 0;
|
|
num++;
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x06009057 RID: 36951 RVA: 0x002002C0 File Offset: 0x001FE4C0
|
|
[Token(Token = "0x6009057")]
|
|
[Address(RVA = "0x1E77CF0", Offset = "0x1E766F0", VA = "0x181E77CF0", Slot = "12")]
|
|
protected virtual KeyParameter GenerateRecordMacKey(IStreamCipher cipher)
|
|
{
|
|
byte[] array = new byte[64];
|
|
int num = 0;
|
|
num += num;
|
|
num++;
|
|
int num2;
|
|
uint num3;
|
|
KeyParameter keyParameter = new KeyParameter(array, num2, (int)num3);
|
|
num2 = 0;
|
|
int num4 = 0;
|
|
Arrays.Fill(array, (byte)num4);
|
|
return keyParameter;
|
|
}
|
|
|
|
// Token: 0x06009058 RID: 36952 RVA: 0x00200308 File Offset: 0x001FE508
|
|
[Token(Token = "0x6009058")]
|
|
[Address(RVA = "0x1E77820", Offset = "0x1E76220", VA = "0x181E77820", Slot = "13")]
|
|
protected virtual byte[] CalculateRecordMac(KeyParameter macKey, byte[] additionalData, byte[] buf, int off, int len)
|
|
{
|
|
Poly1305 poly = new Poly1305();
|
|
int length = additionalData.Length;
|
|
return MacUtilities.DoFinal(poly);
|
|
}
|
|
|
|
// Token: 0x06009059 RID: 36953 RVA: 0x00200330 File Offset: 0x001FE530
|
|
[Token(Token = "0x6009059")]
|
|
[Address(RVA = "0x1E780A0", Offset = "0x1E76AA0", VA = "0x181E780A0", Slot = "14")]
|
|
protected virtual void UpdateRecordMacLength(IMac mac, int len)
|
|
{
|
|
int length = Pack.UInt64_To_LE((ulong)len).Length;
|
|
}
|
|
|
|
// Token: 0x0600905A RID: 36954 RVA: 0x00200350 File Offset: 0x001FE550
|
|
[Token(Token = "0x600905A")]
|
|
[Address(RVA = "0x1E78120", Offset = "0x1E76B20", VA = "0x181E78120", Slot = "15")]
|
|
protected virtual void UpdateRecordMacText(IMac mac, byte[] buf, int off, int len)
|
|
{
|
|
if (mac < 0)
|
|
{
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600905B RID: 36955 RVA: 0x00200368 File Offset: 0x001FE568
|
|
[Token(Token = "0x600905B")]
|
|
[Address(RVA = "0x1E77E50", Offset = "0x1E76850", VA = "0x181E77E50", Slot = "16")]
|
|
protected virtual byte[] GetAdditionalData(long seqNo, byte type, int len)
|
|
{
|
|
byte[] array = new byte[13];
|
|
int num = 0;
|
|
TlsUtilities.WriteUint64(seqNo, array, num);
|
|
TlsUtilities.WriteUint8(type, array, 8);
|
|
TlsContext tlsContext = this.context;
|
|
PngHelperInternal.WriteInt2tobytes(len, array, 11);
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x04005ED4 RID: 24276
|
|
[Token(Token = "0x4005ED4")]
|
|
private static readonly byte[] Zeroes = new byte[15];
|
|
|
|
// Token: 0x04005ED5 RID: 24277
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x4005ED5")]
|
|
protected readonly TlsContext context;
|
|
|
|
// Token: 0x04005ED6 RID: 24278
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x4005ED6")]
|
|
protected readonly ChaCha7539Engine encryptCipher;
|
|
|
|
// Token: 0x04005ED7 RID: 24279
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4005ED7")]
|
|
protected readonly ChaCha7539Engine decryptCipher;
|
|
|
|
// Token: 0x04005ED8 RID: 24280
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x4005ED8")]
|
|
protected readonly byte[] encryptIV;
|
|
|
|
// Token: 0x04005ED9 RID: 24281
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x30")]
|
|
[Token(Token = "0x4005ED9")]
|
|
protected readonly byte[] decryptIV;
|
|
}
|
|
}
|