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

Insufficient PRNG testing #78

Open
veorq opened this issue Jul 24, 2021 · 0 comments · May be fixed by #89
Open

Insufficient PRNG testing #78

veorq opened this issue Jul 24, 2021 · 0 comments · May be fixed by #89

Comments

@veorq
Copy link

veorq commented Jul 24, 2021

Here I'd recommend to test not only the output length but also its content (by checking that the result is identical to the expected one):

sphinx/src/crypto/mod.rs

Lines 62 to 76 in b168f70

#[cfg(test)]
mod generating_pseudorandom_bytes {
use super::*;
// TODO: 10,000 is the wrong number, @aniap what is correct here?
#[test]
fn it_generates_output_of_size_10000() {
let key: [u8; STREAM_CIPHER_KEY_SIZE] =
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
let iv: [u8; STREAM_CIPHER_KEY_SIZE] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let rand_bytes = generate_pseudorandom_bytes(&key, &iv, 10000);
assert_eq!(10000, rand_bytes.len());
}
}

Also, it's usually better to use input values other than all-zero (or all-some-constant) to detect potential endianness and byte ordering issues.

@veorq veorq changed the title Insufficient testing Insufficient PRNG testing Jul 24, 2021
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 a pull request may close this issue.

1 participant