58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
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];
|
|
}
|
|
}
|