Change Subaru AES backend to BouncyCastle

AesManaged (.net) does not work on wasm
This commit is contained in:
JinGen Lim 2023-05-30 14:33:47 +08:00
parent d334b3d58e
commit c4f693d6e7
1 changed files with 12 additions and 2 deletions

View File

@ -1,8 +1,12 @@
using System;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Modes;
using Org.BouncyCastle.Crypto.Parameters;
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
namespace UnlockECU
{
/// <summary>
@ -18,7 +22,7 @@ namespace UnlockECU
{
return false;
}
/*
using (AesManaged aes = new AesManaged())
{
aes.Mode = CipherMode.ECB;
@ -30,6 +34,12 @@ namespace UnlockECU
ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
encryptor.TransformBlock(inSeed, 0, inSeed.Length, outKey, 0);
}
*/
var aes = new CbcBlockCipher(new AesEngine());
var aesParams = new ParametersWithIV(new KeyParameter(GetParameterBytearray(parameters, "K")), new byte[16]);
aes.Init(true, aesParams);
aes.ProcessBlock(inSeed, 0, outKey, 0);
return true;
}