This commit is contained in:
niko
2026-06-04 11:42:34 +02:00
parent f39ba70a9f
commit e720b98cd1
7488 changed files with 2493818 additions and 0 deletions
@@ -0,0 +1,65 @@
using System;
using System.Security.Cryptography;
namespace ExitGames.Client.Photon.EncryptorManaged
{
// Token: 0x0200003A RID: 58
public class CryptoBase : IDisposable
{
// Token: 0x060002B8 RID: 696 RVA: 0x00013CD8 File Offset: 0x00011ED8
~CryptoBase()
{
this.Dispose(false);
}
// Token: 0x060002B9 RID: 697 RVA: 0x00013D0C File Offset: 0x00011F0C
public void Init(byte[] encryptionSecret, byte[] hmacSecret)
{
this.encryptor = new AesManaged
{
Key = encryptionSecret
};
this.encryptor.GenerateIV();
this.hmacsha256 = new HMACSHA256(hmacSecret);
}
// Token: 0x060002BA RID: 698 RVA: 0x00013D3A File Offset: 0x00011F3A
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
// Token: 0x060002BB RID: 699 RVA: 0x00013D4C File Offset: 0x00011F4C
private void Dispose(bool dispose)
{
bool flag = this.encryptor != null;
if (flag)
{
this.encryptor.Clear();
this.encryptor = null;
}
bool flag2 = this.hmacsha256 != null;
if (flag2)
{
this.hmacsha256.Clear();
this.hmacsha256 = null;
}
}
// Token: 0x0400017E RID: 382
public const int BLOCK_SIZE = 16;
// Token: 0x0400017F RID: 383
public const int IV_SIZE = 16;
// Token: 0x04000180 RID: 384
public const int HMAC_SIZE = 32;
// Token: 0x04000181 RID: 385
protected Aes encryptor;
// Token: 0x04000182 RID: 386
protected HMACSHA256 hmacsha256;
}
}
@@ -0,0 +1,67 @@
using System;
using System.IO;
using System.Security.Cryptography;
namespace ExitGames.Client.Photon.EncryptorManaged
{
// Token: 0x0200003C RID: 60
public class Decryptor : CryptoBase
{
// Token: 0x060002C3 RID: 707 RVA: 0x00013F10 File Offset: 0x00012110
public byte[] DecryptBufferWithIV(byte[] data, int offset, int len, out int outLen)
{
Buffer.BlockCopy(data, offset, this.IV, 0, 16);
this.encryptor.IV = this.IV;
byte[] array;
using (ICryptoTransform cryptoTransform = this.encryptor.CreateDecryptor())
{
using (MemoryStream memoryStream = new MemoryStream(data, offset + 16, len - 16))
{
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Read))
{
using (MemoryStream memoryStream2 = new MemoryStream(len - 16))
{
int num;
do
{
num = cryptoStream.Read(this.readBuffer, 0, 16);
bool flag = num != 0;
if (flag)
{
memoryStream2.Write(this.readBuffer, 0, num);
}
}
while (num != 0);
outLen = (int)memoryStream2.Length;
array = memoryStream2.ToArray();
}
}
}
}
return array;
}
// Token: 0x060002C4 RID: 708 RVA: 0x00014024 File Offset: 0x00012224
public bool CheckHMAC(byte[] data, int len)
{
this.hmacsha256.ComputeHash(data, 0, len - 32);
byte[] hash = this.hmacsha256.Hash;
bool flag = true;
int num = 0;
while (num < 4 && flag)
{
int num2 = len - 32 + num * 8;
int num3 = num * 8;
flag = data[num2] == hash[num3] && data[num2 + 1] == hash[num3 + 1] && data[num2 + 2] == hash[num3 + 2] && data[num2 + 3] == hash[num3 + 3] && data[num2 + 4] == hash[num3 + 4] && data[num2 + 5] == hash[num3 + 5] && data[num2 + 6] == hash[num3 + 6] && data[num2 + 7] == hash[num3 + 7];
num++;
}
return flag;
}
// Token: 0x04000184 RID: 388
private readonly byte[] IV = new byte[16];
// Token: 0x04000185 RID: 389
private readonly byte[] readBuffer = new byte[16];
}
}
@@ -0,0 +1,57 @@
using System;
using System.IO;
using System.Security.Cryptography;
namespace ExitGames.Client.Photon.EncryptorManaged
{
// Token: 0x0200003B RID: 59
public class Encryptor : CryptoBase
{
// Token: 0x060002BD RID: 701 RVA: 0x00013DA0 File Offset: 0x00011FA0
public void Encrypt(byte[] data, int len, byte[] output, ref int offset)
{
using (ICryptoTransform cryptoTransform = this.encryptor.CreateEncryptor())
{
using (MemoryStream memoryStream = new MemoryStream(output, offset, output.Length - offset))
{
byte[] iv = this.encryptor.IV;
memoryStream.Write(iv, 0, iv.Length);
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Write))
{
cryptoStream.Write(data, 0, len);
cryptoStream.FlushFinalBlock();
this.encryptor.GenerateIV();
offset += (int)memoryStream.Position;
}
}
}
}
// Token: 0x060002BE RID: 702 RVA: 0x00013E6C File Offset: 0x0001206C
public void HMAC(byte[] data, int offset, int count)
{
this.hmacsha256.TransformBlock(data, offset, count, data, offset);
}
// Token: 0x060002BF RID: 703 RVA: 0x00013E80 File Offset: 0x00012080
public byte[] FinishHMAC()
{
this.hmacsha256.TransformFinalBlock(Encryptor.zeroBytes, 0, 0);
byte[] hash = this.hmacsha256.Hash;
this.hmacsha256.Initialize();
return hash;
}
// Token: 0x060002C0 RID: 704 RVA: 0x00013EC0 File Offset: 0x000120C0
public byte[] FinishHMAC(byte[] data, int offset, int count)
{
this.hmacsha256.TransformFinalBlock(data, offset, count);
byte[] hash = this.hmacsha256.Hash;
this.hmacsha256.Initialize();
return hash;
}
// Token: 0x04000183 RID: 387
private static readonly byte[] zeroBytes = new byte[0];
}
}