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

Replace assertions with debug assertions #578

Closed
StackOverflowExcept1on opened this issue Apr 30, 2024 · 1 comment
Closed

Replace assertions with debug assertions #578

StackOverflowExcept1on opened this issue Apr 30, 2024 · 1 comment

Comments

@StackOverflowExcept1on
Copy link

StackOverflowExcept1on commented Apr 30, 2024

I'm using blake2 in no_std environment and it's quite strange that panic can occur in the release build. This increases the size of the output binary file.

blake2/src/macros.rs:                assert!(key_size <= $bytes::to_usize());
blake2/src/macros.rs:                assert!(output_size <= $bytes::to_usize());
blake2/src/macros.rs:                assert!(salt.len() <= length);
blake2/src/macros.rs:                assert!(persona.len() <= length);
sha3/src/macros.rs:                assert!((0x01..=0x7F).contains(&domain_separation));

You can also consider compile time assertions:

const _: () = assert!(42 <= 1024); //ok
const _: () = assert!(42 > 1024); //compile error
@newpavlov
Copy link
Member

All those asserts check user-provided values. Their validity is important for algorithm correctness, so using debug asserts would be incorrect here.

@newpavlov newpavlov closed this as not planned Won't fix, can't repro, duplicate, stale May 3, 2024
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

No branches or pull requests

2 participants