Skip to content

aead: tweak dev module and add DummyAead tests - #1802

Merged
newpavlov merged 8 commits into
masterfrom
aead/dev_tweak
Mar 21, 2025
Merged

aead: tweak dev module and add DummyAead tests#1802
newpavlov merged 8 commits into
masterfrom
aead/dev_tweak

Conversation

@newpavlov

Copy link
Copy Markdown
Member

Tests the inout methods and moves test vector code outside of the macro.

@newpavlov
newpavlov requested a review from tarcieriMarch 21, 2025 13:52
@tarcieri

Copy link
Copy Markdown
Member

It would also be good to have tests for both cases of length mismatches in the input and output buffer (i.e. input smaller than output, output smaller than input), especially since those error cases didn't exist in the old API

@newpavlov

Copy link
Copy Markdown
MemberAuthor

What methods do you mean? InOutBuf guarantees that input and output buffers have the same length and we currently do not have buffer-to-buffer helper methods since you asked to leave them for later.

Comment threadaead/src/dev.rs

let res = match status {
[0] => $crate::dev::run_fail_test(&cipher, nonce, aad, ct),
[1] => $crate::dev::run_pass_test(&cipher, nonce, aad, pt, ct),

@newpavlovnewpavlovMar 21, 2025

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the failing test ignores plaintext. Maybe it's worth to introduce two separate macros for successful and failing tests? In other words, we would store passing and failing vectors in separate files:

aead::new_pass_test!(my_aead_pass,"my_aead_pass",MyAead);
aead::new_fail_test!(my_aead_fail,"my_aead_fail",MyAead);

@newpavlovnewpavlov changed the title aead: tweak dev moduleaead: tweak dev module and add DummyAead testsMar 21, 2025
@newpavlov
newpavlov merged commit a8d6711 into masterMar 21, 2025
@newpavlov
newpavlov deleted the aead/dev_tweak branch March 21, 2025 16:07
Comment threadaead/src/dev.rs
let tag: &Tag<C> = tag.try_into().expect("tag has correct length");

// Fill output buffer with "garbage" to test that its data does not get read during encryption
let mut buf: alloc::vec::Vec<u8> = (0..pt.len()).map(|i| i as u8).collect();

@baloobalooMar 21, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not every consumer use the aead::new_test (at least deoxys and ascon-aead does not) this is why the MockBuffer was made available in #1797

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can leave the ascon test as-is for now. We should migrate them to new_test either way. The current approach with the huge number of testing functions is slow and unwieldy.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@newpavlov@tarcieri@baloo