Skip to content

Commit 71a0dbc

Browse files
committed
pkg/cryptoauthlib: fix modules.h and printf format
- Add missing modules.h include for IS_USED macro in atca.h - Fix printf format specifiers in psa_atca_se_driver.c: use %zu for size_t parameters instead of %d to prevent warnings on native platform Signed-off-by: Gilles DOFFE <[email protected]>
1 parent e395e04 commit 71a0dbc

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

pkg/cryptoauthlib/include/atca.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*
2020
*/
2121

22+
#include "modules.h"
2223
#include "periph/i2c.h"
2324
#include "cryptoauthlib.h"
2425

pkg/cryptoauthlib/psa_atca_driver/psa_atca_se_driver.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ psa_status_t atca_cipher_set_iv(void *op_context,
214214
atca_aes_cbc_ctx_t *ctx = &((psa_se_cipher_context_t *)op_context)->drv_ctx.atca_aes_cbc;
215215

216216
if (iv_length != ATCA_MAX_IV_LEN) {
217-
DEBUG("ATCA Cipher Set IV: Invalid IV length: Expected %d, was %d\n", \
217+
DEBUG("ATCA Cipher Set IV: Invalid IV length: Expected %d, was %zu\n", \
218218
ATCA_MAX_IV_LEN, iv_length);
219219
return PSA_ERROR_INVALID_ARGUMENT;
220220
}
@@ -295,7 +295,7 @@ psa_status_t atca_cipher_ecb(psa_drv_se_context_t *drv_context,
295295
}
296296

297297
if (input_size % AES_128_BLOCK_SIZE != 0) {
298-
DEBUG("ATCA Cipher ECB: Input must be multiple of 16, was %d.\n", input_size);
298+
DEBUG("ATCA Cipher ECB: Input must be multiple of 16, was %zu.\n", input_size);
299299
return PSA_ERROR_INVALID_ARGUMENT;
300300
}
301301

@@ -452,7 +452,7 @@ psa_status_t atca_generate_key(psa_drv_se_context_t *drv_context,
452452
}
453453

454454
if (pubkey_size > PSA_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(attributes->type, attributes->bits)) {
455-
DEBUG("ATCA Generate Key: Pubkey size not supported. Expected %d, was %d.\n", \
455+
DEBUG("ATCA Generate Key: Pubkey size not supported. Expected %zu, was %zu.\n", \
456456
PSA_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(attributes->type, attributes->bits), pubkey_size);
457457
return PSA_ERROR_NOT_SUPPORTED;
458458
}
@@ -494,7 +494,7 @@ psa_status_t atca_export_public_key(psa_drv_se_context_t *drv_context,
494494
ATCADevice dev = (ATCADevice)drv_context->transient_data;
495495

496496
if (data_size < ECC_P256_PUB_KEY_SIZE) {
497-
DEBUG("ATCA Export public key: Buffer too small, expected %d, was %d\n", \
497+
DEBUG("ATCA Export public key: Buffer too small, expected %d, was %zu\n", \
498498
ECC_P256_PUB_KEY_SIZE, data_size);
499499
return PSA_ERROR_BUFFER_TOO_SMALL;
500500
}
@@ -542,8 +542,8 @@ psa_status_t atca_sign(psa_drv_se_context_t *drv_context,
542542

543543
if ((signature_size != ECC_P256_PUB_KEY_SIZE) || \
544544
(hash_length != PSA_HASH_LENGTH(PSA_ALG_SHA_256))) {
545-
DEBUG("ATCA Sign: Invalid signature or hash size. Expected Sig: %d |\
546-
Hash %d, were Sig: %d | Hash: %d\n",\
545+
DEBUG("ATCA Sign: Invalid signature or hash size. Expected Sig: %d | " \
546+
"Hash %d, were Sig: %zu | Hash: %zu\n",\
547547
ECC_P256_PUB_KEY_SIZE, PSA_HASH_LENGTH(PSA_ALG_SHA_256),\
548548
signature_size, hash_length);
549549
return PSA_ERROR_INVALID_ARGUMENT;
@@ -581,8 +581,8 @@ psa_status_t atca_verify(psa_drv_se_context_t *drv_context,
581581

582582
if ((signature_length != ECC_P256_PUB_KEY_SIZE) || \
583583
(hash_length != PSA_HASH_LENGTH(PSA_ALG_SHA_256))) {
584-
DEBUG("ATCA Sign: Invalid signature or hash size. Expected Sig: %d |\
585-
Hash %d, were Sig: %d | Hash: %d\n",\
584+
DEBUG("ATCA Sign: Invalid signature or hash size. Expected Sig: %d | " \
585+
"Hash %d, were Sig: %zu | Hash: %zu\n",\
586586
ECC_P256_PUB_KEY_SIZE, PSA_HASH_LENGTH(PSA_ALG_SHA_256),\
587587
signature_length, hash_length);
588588
return PSA_ERROR_INVALID_ARGUMENT;
@@ -616,7 +616,7 @@ psa_status_t atca_generate_mac(psa_drv_se_context_t *drv_context,
616616
}
617617

618618
if (mac_size < PSA_HASH_LENGTH(PSA_ALG_SHA_256)) {
619-
DEBUG("ATCA Generate Mac: Buffer too small, expected %d, was %d\n", \
619+
DEBUG("ATCA Generate Mac: Buffer too small, expected %d, was %zu\n", \
620620
PSA_HASH_LENGTH(PSA_ALG_SHA_256), mac_size);
621621
return PSA_ERROR_BUFFER_TOO_SMALL;
622622
}

0 commit comments

Comments
 (0)