Skip to content

Commit b3d6da0

Browse files
committed
[crypto/test] Use OTCRYPTO_MAKE_BUF before passing data to CL
Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
1 parent 00c2f8a commit b3d6da0

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

sw/device/tests/crypto/ed25519_functest.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,9 @@ static status_t hasheddsa_test(void) {
170170

171171
CHECK_STATUS_OK(otcrypto_ed25519_keygen(&private_key, &public_key));
172172

173-
otcrypto_const_byte_buf_t input_message = {
174-
.data = (const uint8_t *)kMessage,
175-
.len = ARRAYSIZE(kMessage),
176-
};
173+
otcrypto_const_byte_buf_t input_message =
174+
OTCRYPTO_MAKE_BUF(otcrypto_const_byte_buf_t, (const uint8_t *)kMessage,
175+
ARRAYSIZE(kMessage));
177176

178177
uint32_t signature_data[kEd25519SignatureWords];
179178
otcrypto_word32_buf_t signature = OTCRYPTO_MAKE_BUF(

sw/device/tests/crypto/hmac_functest.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,24 @@ static status_t run_test_vector(void) {
4545
.data = act_tag,
4646
.len = digest_len,
4747
};
48+
otcrypto_const_byte_buf_t msg_buf = otcrypto_make_const_byte_buf(
49+
current_test_vector->message.data, current_test_vector->message.len);
4850
switch (current_test_vector->test_operation) {
4951
case kHmacTestOperationSha256:
50-
TRY(otcrypto_sha2_256(&current_test_vector->message, &hash_digest));
52+
TRY(otcrypto_sha2_256(&msg_buf, &hash_digest));
5153
break;
5254
case kHmacTestOperationSha384:
53-
TRY(otcrypto_sha2_384(&current_test_vector->message, &hash_digest));
55+
TRY(otcrypto_sha2_384(&msg_buf, &hash_digest));
5456
break;
5557
case kHmacTestOperationSha512:
56-
TRY(otcrypto_sha2_512(&current_test_vector->message, &hash_digest));
58+
TRY(otcrypto_sha2_512(&msg_buf, &hash_digest));
5759
break;
5860
case kHmacTestOperationHmacSha256:
5961
OT_FALLTHROUGH_INTENDED;
6062
case kHmacTestOperationHmacSha384:
6163
OT_FALLTHROUGH_INTENDED;
6264
case kHmacTestOperationHmacSha512:
63-
TRY(otcrypto_hmac(&current_test_vector->key,
64-
&current_test_vector->message, &tag_buf));
65+
TRY(otcrypto_hmac(&current_test_vector->key, &msg_buf, &tag_buf));
6566
break;
6667
default:
6768
return INVALID_ARGUMENT();

0 commit comments

Comments
 (0)