-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new Wycheproof test vectors for (X)ChaCha20Poly1305, HMAC-SHA512 …
…and HKDF-HMAC-SHA512 (#116) * tests: Add updated wycheproof test vectors for ChaCha20Poly1305 and new ones for XChaCha20Poly1305 * tests: Add new Wycheproof test vectors for HMAC-SHA512 * tests: Add new Wycheproof test vectors for HKDF-HMAC-SHA512 * tests: Refactor HKDF test runner * tests: Refactor HMAC test runner * fmt * tests: Refactor Wycheproof tests runners
- Loading branch information
Showing
16 changed files
with
10,262 additions
and
2,026 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
pub mod custom_hkdf; | ||
pub mod custom_pbkdf2; | ||
pub mod other_hkdf; | ||
pub mod wycheproof_hkdf; | ||
|
||
extern crate orion; | ||
use self::orion::hazardous::{kdf::hkdf::*, mac::hmac}; | ||
|
||
pub fn hkdf_test_runner( | ||
excp_prk: Option<&[u8]>, | ||
excp_okm: &[u8], | ||
expected_prk: Option<&[u8]>, | ||
expected_okm: &[u8], | ||
salt: &[u8], | ||
ikm: &[u8], | ||
info: &[u8], | ||
okm_out: &mut [u8], | ||
) -> bool { | ||
if excp_prk.is_some() { | ||
okm_len: usize, | ||
valid_result: bool, | ||
) { | ||
if expected_prk.is_some() { | ||
let actual_prk = extract(salt, &ikm).unwrap(); | ||
assert!(actual_prk == hmac::Tag::from_slice(excp_prk.unwrap()).unwrap()); | ||
assert!(actual_prk == hmac::Tag::from_slice(expected_prk.unwrap()).unwrap()); | ||
} | ||
|
||
let mut okm_out = vec![0u8; okm_len]; | ||
|
||
// verify() also runs derive_key() | ||
verify(excp_okm, salt, ikm, Some(&info), &mut okm_out.to_vec()).is_ok() | ||
if valid_result { | ||
assert!(verify(expected_okm, salt, ikm, Some(&info), &mut okm_out).is_ok()); | ||
} else { | ||
assert!(verify(expected_okm, salt, ikm, Some(&info), &mut okm_out).is_err()); | ||
} | ||
} |
Oops, something went wrong.