Skip to content

Commit

Permalink
Update Ascon-128a_KAT.js
Browse files Browse the repository at this point in the history
  • Loading branch information
motarekk authored Oct 3, 2023
1 parent 5454546 commit a65c9c6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions KATs/Ascon-128a_KAT.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ function ascon_128a_KAT(){
try {
var ct_to_test = ascon_aead(key, nonce, ad, pt, operation, variant).toUpperCase();
} catch (error) {
console.log("failed test: "+ascon_128a_kats[i].Count);
console.log(`Error in test case ${ascon_128a_kats[i].Count}: ${error}`);
}

if(ct == ct_to_test){
passed += 1;
} else {
failed += 1;
console.log(`failed test: ${ascon_128a_kats[i].Count}`);
}
}

var print_encryption_KAT_result = "(encryption):\npassed: "+passed+"\nfailed: "+failed;
var print_encryption_KAT_result = `(encryption):\npassed: ${passed}\nfailed: ${failed}`;
console.log(print_encryption_KAT_result);


Expand All @@ -53,13 +54,14 @@ function ascon_128a_KAT(){
try {
var pt_to_test = ascon_aead(key, nonce, ad, ct.toLowerCase(), operation, variant).toUpperCase();
} catch (error) {
console.log("failed test: "+ascon_128a_kats[i].Count);
console.log(`Error in test case ${ascon_128a_kats[i].Count}: ${error}`)
}

if(pt == pt_to_test){
passed += 1;
} else {
failed += 1;
console.log(`failed test: ${ascon_128a_kats[i].Count}`);
}
}

Expand All @@ -68,8 +70,8 @@ function ascon_128a_KAT(){
note = "\n\nnote: you can view the failed tests in the console";
}

var print_decryption_KAT_result = "\n(decryption):\npassed: "+passed+"\nfailed: "+failed;
var print_decryption_KAT_result = `\n(decryption):\npassed: ${passed}\nfailed: ${failed}`;
console.log(print_decryption_KAT_result);

return print_title+"\n"+print_encryption_KAT_result+"\n"+print_decryption_KAT_result+note;
}
}

0 comments on commit a65c9c6

Please sign in to comment.