2019-11-19 02:31:06 +01:00
|
|
|
|
using LibHac.Crypto;
|
2019-11-09 08:32:13 +01:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
namespace LibHac.Tests.CryptoTests;
|
|
|
|
|
|
|
|
|
|
public class AesCtrTests
|
2019-11-09 08:32:13 +01:00
|
|
|
|
{
|
2021-11-14 20:08:57 +01:00
|
|
|
|
public static TheoryData<EncryptionTestVector> TestVectors = RspReader.ReadEncryptionTestVectors(true, "CTR128.rsp");
|
2019-11-09 08:32:13 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01: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 08:32:13 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01: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 08:32:13 +01:00
|
|
|
|
}
|
|
|
|
|
}
|