mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
make aead128 test as a public api test
This commit is contained in:
parent
2923c01722
commit
9be323da3f
1 changed files with 4 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue