diff --git a/wrapper/rust/wolfssl-wolfcrypt/tests/test_blake2.rs b/wrapper/rust/wolfssl-wolfcrypt/tests/test_blake2.rs index 4b8bff27fe..4f7126d14d 100644 --- a/wrapper/rust/wolfssl-wolfcrypt/tests/test_blake2.rs +++ b/wrapper/rust/wolfssl-wolfcrypt/tests/test_blake2.rs @@ -1,5 +1,7 @@ #[cfg(any(blake2b, blake2s))] use wolfssl_wolfcrypt::blake2::*; +#[cfg(any(blake2b, blake2s))] +use wolfssl_wolfcrypt::sys; #[test] #[cfg(blake2b)] @@ -50,6 +52,15 @@ fn test_blake2b() { } } +#[test] +#[cfg(blake2b)] +fn test_blake2b_finalize_empty_buffer() { + let mut blake2b = BLAKE2b::new(64).expect("Error with new()"); + let mut hash: [u8; 0] = []; + let rc = blake2b.finalize(&mut hash).expect_err("finalize() should fail"); + assert_eq!(rc, sys::wolfCrypt_ErrorCodes_BUFFER_E); +} + #[test] #[cfg(blake2b_hmac)] fn test_blake2b_hmac() { @@ -151,6 +162,15 @@ fn test_blake2s() { } } +#[test] +#[cfg(blake2s)] +fn test_blake2s_finalize_empty_buffer() { + let mut blake2s = BLAKE2s::new(32).expect("Error with new()"); + let mut hash: [u8; 0] = []; + let rc = blake2s.finalize(&mut hash).expect_err("finalize() should fail"); + assert_eq!(rc, sys::wolfCrypt_ErrorCodes_BUFFER_E); +} + #[test] #[cfg(blake2s_hmac)] fn test_blake2s_hmac() {