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.CBC, key=key)
ct = encrypt(plaintext, cipher; iv=iv)
pt = decrypt(ct, cipher)
ct8 = encrypt(plaintext8, cipher)
pt8 = decrypt(ct8, cipher)

ciphertext = [0xbd, 0x13, 0x20, 0x4f, 0x67, 0xd8, 0x16, 0x7f, 
			  0x20, 0x21, 0x1c, 0x99, 0xb0, 0xa7, 0xcc, 0x05,
			  0x06, 0xd5, 0xc7, 0x03, 0xea, 0xfb, 0x01, 0xa7,
			  0xd0, 0x47, 0x3b, 0x5c, 0xc9, 0x99, 0xaa, 0xa2,
			  0x1e, 0x01, 0x7b, 0x76, 0x6e, 0x52, 0x98, 0x5f, 
			  0x5e, 0xf7, 0xf0, 0xbd, 0xc5, 0x72, 0xb7, 0x2e]

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

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