make aead128 test as a public api test

This commit is contained in:
blackshirt 2025-09-10 12:27:26 +00:00
parent 2923c01722
commit 9be323da3f

View file

@ -2,9 +2,8 @@
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
//
module ascon
import encoding.hex
import x.crypto.ascon
// This test materials was taken and adapted into v from references implementation of Ascon-aead128
// especially for the known answer test data, but, its not all fully-taken, just randomly choosen item.
@ -27,14 +26,14 @@ fn test_ascon_aead128_enc_dec() ! {
ad := hex.decode(item.ad)!
ct := hex.decode(item.ct)!
out := encrypt(key, nonce, ad, pt)!
out := ascon.encrypt(key, nonce, ad, pt)!
assert out == ct
msg := decrypt(key, nonce, ad, ct)!
msg := ascon.decrypt(key, nonce, ad, ct)!
assert msg == pt
// Work with object-based Cipher
mut c := new_aead128(key)!
mut c := ascon.new_aead128(key)!
// Lets encrypt the message
exp_ct := c.encrypt(msg, nonce, ad)!
assert exp_ct == ct