rust/keystore: add invalid seed size test for encrypt_and_store_seed
What changed, and why it matters
This commit only adds a new automated test that checks the existing function `encrypt_and_store_seed` rejects a 31-byte seed (it requires 32 bytes). No production code was changed, and the test simply verifies an existing error path behaves correctly.
No security action needed; this is a benign test-only change. Routine review/merge is sufficient.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a single Rust unit test, test_encrypt_and_store_seed_invalid_size, in src/rust/bitbox02-rust/src/keystore.rs. It mocks memory, locks the keystore, calls encrypt_and_store_seed with a 31-byte zeroed seed and password “foo”, and asserts the returned error is Error::SeedSize. This is a negative test for an already-present validation check; no implementation logic was modified.
Changed components
src/rust/bitbox02-rust/src/keystore.rsInspect captured patch +10 / −0
diff --git a/src/rust/bitbox02-rust/src/keystore.rs b/src/rust/bitbox02-rust/src/keystore.rs
index c099df0..d360e46 100644
--- a/src/rust/bitbox02-rust/src/keystore.rs
+++ b/src/rust/bitbox02-rust/src/keystore.rs
@@ -692,6 +692,16 @@ mod tests {
);
}
+ #[test]
+ fn test_encrypt_and_store_seed_invalid_size() {
+ mock_memory();
+ lock();
+ assert!(matches!(
+ encrypt_and_store_seed(&[0; 31], "foo"),
+ Err(Error::SeedSize)
+ ));
+ }
+
#[test]
fn test_create_and_store_seed() {
let mock_salt_root =
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.