Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sw/device/tests/crypto/cryptotest/json/rsa_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ extern "C" {

#define RSA_CMD_MAX_MESSAGE_BYTES 512
#define RSA_CMD_MAX_N_BYTES 512
#define RSA_CMD_MAX_SIGNATURE_BYTES 512
// There are some error test cases that send larger signatures than 512 bytes.
// The cryptolib should detect this and abort with an error.
// Accomodate for these additional bytes.
#define RSA_CMD_MAX_SIGNATURE_BYTES 514

// clang-format off

Expand Down
8 changes: 7 additions & 1 deletion sw/host/tests/crypto/rsa_kat/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ fn run_rsa_testcase(
};

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

CryptotestCommand::Rsa.send(spi_console)?;
let _operation = &match test_case.operation.as_str() {
Expand Down
Loading