2019-11-18 18:31:06 -07:00
|
|
|
|
using LibHac.Crypto;
|
2019-11-09 00:32:13 -07:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
2021-11-14 12:08:57 -07:00
|
|
|
|
namespace LibHac.Tests.CryptoTests;
|
|
|
|
|
|
|
|
|
|
public class AesCtrTests
|
2019-11-09 00:32:13 -07:00
|
|
|
|
{
|
2021-11-14 12:08:57 -07:00
|
|
|
|
public static TheoryData<EncryptionTestVector> TestVectors = RspReader.ReadEncryptionTestVectors(true, "CTR128.rsp");
|
2019-11-09 00:32:13 -07:00
|
|
|
|
|
2021-11-14 12:08:57 -07:00
|
|
|
|
[Theory]
|
|
|
|
|
[MemberData(nameof(TestVectors))]
|
|
|
|
|
public static void Transform(EncryptionTestVector tv)
|
|
|
|
|
{
|
|
|
|
|
Common.CipherTestCore(tv.PlainText, tv.CipherText, Aes.CreateCtrEncryptor(tv.Key, tv.Iv, true));
|
|
|
|
|
}
|
2019-11-09 00:32:13 -07:00
|
|
|
|
|
2021-11-14 12:08:57 -07:00
|
|
|
|
[AesIntrinsicsRequiredTheory]
|
|
|
|
|
[MemberData(nameof(TestVectors))]
|
|
|
|
|
public static void TransformIntrinsics(EncryptionTestVector tv)
|
|
|
|
|
{
|
|
|
|
|
Common.CipherTestCore(tv.PlainText, tv.CipherText, Aes.CreateCtrEncryptor(tv.Key, tv.Iv));
|
2019-11-09 00:32:13 -07:00
|
|
|
|
}
|
2022-11-11 18:21:07 -07:00
|
|
|
|
}
|