Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aead: tweak dev module and add DummyAead tests #1802

Merged
merged 8 commits into from
Mar 21, 2025
Merged

Conversation

newpavlov
Copy link
Member

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

@newpavlov newpavlov requested a review from tarcieri March 21, 2025 13:52
@tarcieri
Copy link
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
Member Author

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.


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),
Copy link
Member Author

@newpavlov newpavlov Mar 21, 2025

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);

@newpavlov newpavlov changed the title aead: tweak dev module aead: tweak dev module and add DummyAead tests Mar 21, 2025
@newpavlov newpavlov merged commit a8d6711 into master Mar 21, 2025
10 checks passed
@newpavlov newpavlov deleted the aead/dev_tweak branch March 21, 2025 16:07
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();
Copy link
Member

@baloo baloo Mar 21, 2025

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
Member Author

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 free to 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