Skip to content

Commit

Permalink
adapt tests for pure Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
wysiwys committed Feb 10, 2025
1 parent 12e0aae commit 76f380a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/sha2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use libcrux_traits::Digest as _;
// #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn sha256_kat_streaming() {
let mut digest = libcrux::digest::Sha2_256::new();
let mut digest = libcrux_sha2::Sha256::new();
let mut d = [0u8; 32];
digest.update(b"libcrux sha2 256 tests");
digest.finish(&mut d);
Expand All @@ -17,15 +17,15 @@ fn sha256_kat_streaming() {
// #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
fn sha256_kat_oneshot() {
let d = libcrux::digest::sha2_256(b"libcrux sha2 256 tests");
let d = libcrux_sha2::sha256(b"libcrux sha2 256 tests");

let expected = "8683520e19e5b33db33c8fb90918c0c96fcdfd9a17c695ce0f0ea2eaa0c95956";
assert_eq!(hex::encode(d), expected);
}

#[test]
fn sha2_clone() {
let mut hasher_224 = libcrux::digest::Sha2_224::new();
fn shaclone() {
let mut hasher_224 = libcrux_sha2::Sha224::new();
hasher_224.update(b"test 224");
let mut hasher224_2 = hasher_224.clone();
hasher_224.update(b"more 224");
Expand All @@ -36,9 +36,9 @@ fn sha2_clone() {
hasher224_2.finish(&mut digest_2);

assert_eq!(digest, digest_2);
assert_eq!(digest, libcrux::digest::sha2_224(b"test 224more 224"));
assert_eq!(digest, libcrux_sha2::sha224(b"test 224more 224"));

let mut hasher_256 = libcrux::digest::Sha2_256::new();
let mut hasher_256 = libcrux_sha2::Sha256::new();
hasher_256.update(b"test 256");
let mut hasher256_2 = hasher_256.clone();
hasher_256.update(b"more 256");
Expand All @@ -49,9 +49,9 @@ fn sha2_clone() {
hasher256_2.finish(&mut digest_2);

assert_eq!(digest, digest_2);
assert_eq!(digest, libcrux::digest::sha2_256(b"test 256more 256"));
assert_eq!(digest, libcrux_sha2::sha256(b"test 256more 256"));

let mut hasher_384 = libcrux::digest::Sha2_384::new();
let mut hasher_384 = libcrux_sha2::Sha384::new();
hasher_384.update(b"test 384");
let mut hasher384_2 = hasher_384.clone();
hasher_384.update(b"more 384");
Expand All @@ -62,9 +62,9 @@ fn sha2_clone() {
hasher384_2.finish(&mut digest_2);

assert_eq!(digest, digest_2);
assert_eq!(digest, libcrux::digest::sha2_384(b"test 384more 384"));
assert_eq!(digest, libcrux_sha2::sha384(b"test 384more 384"));

let mut hasher_512 = libcrux::digest::Sha2_512::new();
let mut hasher_512 = libcrux_sha2::Sha512::new();
hasher_512.update(b"test 512");
let mut hasher512_2 = hasher_512.clone();
hasher_512.update(b"more 512");
Expand All @@ -75,5 +75,5 @@ fn sha2_clone() {
hasher512_2.finish(&mut digest_2);

assert_eq!(digest, digest_2);
assert_eq!(digest, libcrux::digest::sha2_512(b"test 512more 512"));
assert_eq!(digest, libcrux_sha2::sha512(b"test 512more 512"));
}

0 comments on commit 76f380a

Please sign in to comment.