Skip to content

Commit

Permalink
update test code
Browse files Browse the repository at this point in the history
  • Loading branch information
keks committed Feb 1, 2024
1 parent c30ce82 commit 5959b1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 9 additions & 3 deletions tests/aesgcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use libcrux::{
aead::{
decrypt, encrypt, Aes128Key, Aes256Key,
Algorithm::{Aes128Gcm, Aes256Gcm},
EncryptError, Iv, Key,
EncryptError, InvalidArgumentError, Iv, Key,
},
aes_ni_support,
};
Expand All @@ -34,7 +34,10 @@ fn aesgcm_self_test() {
let tag = match encrypt(&key, &mut msg, iv, aad) {
Ok(t) => t,
Err(e) => {
if matches!(e, EncryptError::UnsupportedAlgorithm) {
if matches!(
e,
EncryptError::InvalidArgument(InvalidArgumentError::UnsupportedAlgorithm)
) {
eprintln!("AES not supported on this architecture.");
return;
} else {
Expand Down Expand Up @@ -83,7 +86,10 @@ fn aesgcm_self_test_rand() {
let tag = match encrypt(&key, &mut msg, iv, aad) {
Ok(t) => t,
Err(e) => {
if matches!(e, EncryptError::UnsupportedAlgorithm) {
if matches!(
e,
EncryptError::InvalidArgument(InvalidArgumentError::UnsupportedAlgorithm)
) {
eprintln!("AES not supported on this architecture.");
return;
} else {
Expand Down
9 changes: 7 additions & 2 deletions tests/chachapoly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use libcrux::{
aead::{
self, decrypt, encrypt,
Algorithm::{self, Chacha20Poly1305},
Chacha20Key, EncryptError, Iv, Key, Tag,
Chacha20Key, EncryptError, InvalidArgumentError, Iv, Key, Tag,
},
aes_ni_support,
};
Expand Down Expand Up @@ -176,7 +176,12 @@ fn wycheproof() {
let tag = match aead::encrypt(&aead_key, &mut msg_ctxt, Iv(nonce), &aad) {
Ok(v) => v,
Err(e) => {
if matches!(e, EncryptError::UnsupportedAlgorithm) {
if matches!(
e,
EncryptError::InvalidArgument(
InvalidArgumentError::UnsupportedAlgorithm
)
) {
eprintln!("AES not supported on this architecture.");
*skipped_tests += 1;
continue;
Expand Down

0 comments on commit 5959b1b

Please sign in to comment.