using AES, Test

k = [0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c]
key = AES128Key(k)

plaintext = "The quick brown fox jumps over the lazy dog."
plaintext8 = "The quick brown fox jumps over the 😴 dog."
iv = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f]

cipher = AESCipher(;key_length=128, mode=AES.CTR, key=key)
ct = encrypt(plaintext, cipher; iv=iv)
pt = decrypt(ct, cipher)

cipher = AESCipher(;key_length=128, mode=AES.CTR, key=key)
ct8 = encrypt(plaintext8, cipher; iv=iv)
pt8 = decrypt(ct8, cipher)

ciphertext = [0x04, 0x96, 0x02, 0xec, 0xe8, 0x18, 0x5b, 0xd5,
              0xb1, 0x29, 0x55, 0x9b, 0xf4, 0xd8, 0x82, 0x40,
              0xc9, 0x4e, 0xf6, 0x6e, 0xed, 0x96, 0xfe, 0xda,
              0xa9, 0x11, 0x24, 0x92, 0x1e, 0x85, 0x83, 0x2b,
              0xfe, 0x8f, 0xaf, 0xe5, 0x64, 0xf9, 0xe9, 0x62,
              0xdd, 0xa1, 0xe7, 0xb6]

@testset "ASCII" begin
    @test pt == transcode(UInt8,plaintext)
    @test ct.data == ciphertext
end

@testset "UTF-8" begin
    @test pt8 == transcode(UInt8,plaintext8)
end