5 #include "sw/device/lib/crypto/drivers/otbn.h"
6 #include "sw/device/lib/crypto/impl/integrity.h"
7 #include "sw/device/lib/crypto/impl/keyblob.h"
12 #include "sw/device/lib/testing/entropy_testutils.h"
13 #include "sw/device/lib/testing/test_framework/check.h"
18 kP384PublicKeyWords = 768 / 32,
20 kP384SignatureWords = 768 / 32,
22 kP384PrivateKeyBytes = 384 / 8,
26 static const char kMessage[] =
"test message";
29 .version = kOtcryptoLibVersion1,
30 .key_mode = kOtcryptoKeyModeEcdsaP384,
31 .key_length = kP384PrivateKeyBytes,
33 .security_level = kOtcryptoKeySecurityLevelLow,
38 uint32_t keyblob[keyblob_num_words(kPrivateKeyConfig)];
40 .config = kPrivateKeyConfig,
41 .keyblob_length =
sizeof(keyblob),
46 uint32_t pk[kP384PublicKeyWords] = {0};
48 .key_mode = kOtcryptoKeyModeEcdsaP384,
49 .key_length =
sizeof(pk),
59 .len =
sizeof(kMessage) - 1,
60 .data = (
unsigned char *)&kMessage,
62 uint32_t msg_digest_data[kSha384DigestWords];
64 .data = msg_digest_data,
66 .mode = kOtcryptoHashModeSha384,
71 uint32_t sig[kP384SignatureWords] = {0};
76 &private_key, msg_digest,
82 &public_key, msg_digest,
84 verification_result));
89 OTTF_DEFINE_TEST_CONFIG();
92 CHECK_STATUS_OK(entropy_testutils_auto_mode_init());
95 status_t err = sign_then_verify_test(&verificationResult);
96 if (!status_ok(err)) {
98 LOG_INFO(
"OTBN error bits: 0x%08x", otbn_err_bits_get());
99 LOG_INFO(
"OTBN instruction count: 0x%08x", otbn_instruction_count_get());
101 CHECK_STATUS_OK(err);
107 LOG_ERROR(
"Signature failed to pass verification!");