Skip to content

Commit e134cd0

Browse files
committed
[cryptotest] Remove leading 0 in modulo
The wycheproof testvector seem to have a leading 0. This means that a 512-byte modulo for RSA-4096 is actually 513-byte. Currently, the test framework fails because it expects a 512-byte value. Remove this leading 0. Signed-off-by: Pascal Nasahl <[email protected]>
1 parent 06f44d0 commit e134cd0

File tree

1 file changed

+7
-1
lines changed
  • sw/host/tests/crypto/rsa_kat/src

1 file changed

+7
-1
lines changed

sw/host/tests/crypto/rsa_kat/src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ fn run_rsa_testcase(
8787
};
8888

8989
// Convert the inputs into the expected format for the CL.
90-
let n: Vec<_> = test_case.n.iter().copied().rev().collect();
90+
let mut n: Vec<_> = test_case.n.iter().copied().rev().collect();
91+
// n in the wycheproof vectors seem to start with a leading 0.
92+
if n.len() * u8::BITS as usize != test_case.security_level {
93+
// Remove it.
94+
assert_eq!(n.pop(), Some(0));
95+
}
96+
assert_eq!(n.len() * u8::BITS as usize, test_case.security_level);
9197

9298
CryptotestCommand::Rsa.send(spi_console)?;
9399
let _operation = &match test_case.operation.as_str() {

0 commit comments

Comments
 (0)