Skip to content

Commit 7b871c6

Browse files
authored
Merge pull request #684 from danielinux/minor_build_fixes
Minor build fixes
2 parents 25bee84 + c352808 commit 7b871c6

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ nvm-image: $(PRIVATE_KEY) whnvmtool
429429
@echo "NVM images generated: $(WH_NVM_BIN) and $(WH_NVM_HEX)"
430430
endif
431431

432-
test-app/image_v1_signed.bin: $(BOOT_IMG)
432+
test-app/image_v1_signed.bin: $(BOOT_IMG) keytools_check
433433
@echo "\t[SIGN] $(BOOT_IMG)"
434434
@echo "\tSECONDARY_SIGN_OPTIONS=$(SECONDARY_SIGN_OPTIONS)"
435435
@echo "\tSECONDARY_PRIVATE_KEY=$(SECONDARY_PRIVATE_KEY)"

hal/stm32h5.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@
3434
#include "otp_keystore.h"
3535
#endif
3636

37+
#if defined(WOLFCRYPT_TZ_PSA)
3738
#if defined(WOLFBOOT_HASH_SHA256)
3839
#include <wolfssl/wolfcrypt/sha256.h>
39-
#elif defined(WOLFBOOT_HASH_SHA384) || defined(WOLFBOOT_HASH_SHA3_384)
40+
#elif defined(WOLFBOOT_HASH_SHA384)
4041
#include <wolfssl/wolfcrypt/sha512.h>
42+
#elif defined(WOLFBOOT_HASH_SHA3_384)
43+
#include <wolfssl/wolfcrypt/sha3.h>
44+
#endif
4145
#endif
4246

4347
#define PLL_SRC_HSE 1
@@ -177,12 +181,16 @@ __attribute__((weak)) int stm32h5_obkeys_read_uds(uint8_t *out, size_t out_len)
177181
}
178182
#endif
179183

184+
#if defined(WOLFCRYPT_TZ_PSA)
180185
static int uds_from_uid(uint8_t *out, size_t out_len)
181186
{
182187
uint8_t uid[12];
183188
#if defined(WOLFBOOT_HASH_SHA256)
184189
uint8_t digest[SHA256_DIGEST_SIZE];
185190
wc_Sha256 hash;
191+
#elif defined(WOLFBOOT_HASH_SHA3_384)
192+
uint8_t digest[SHA3_384_DIGEST_SIZE];
193+
wc_Sha3 hash;
186194
#else
187195
uint8_t digest[SHA384_DIGEST_SIZE];
188196
wc_Sha384 hash;
@@ -207,6 +215,11 @@ static int uds_from_uid(uint8_t *out, size_t out_len)
207215
wc_Sha256Update(&hash, uid, sizeof(uid));
208216
wc_Sha256Final(&hash, digest);
209217
copy_len = sizeof(digest);
218+
#elif defined(WOLFBOOT_HASH_SHA3_384)
219+
wc_InitSha3_384(&hash, NULL, INVALID_DEVID);
220+
wc_Sha3_384_Update(&hash, uid, sizeof(uid));
221+
wc_Sha3_384_Final(&hash, digest);
222+
copy_len = sizeof(digest);
210223
#else
211224
wc_InitSha384(&hash);
212225
wc_Sha384Update(&hash, uid, sizeof(uid));
@@ -270,6 +283,7 @@ int hal_uds_derive_key(uint8_t *out, size_t out_len)
270283
return -1;
271284
#endif
272285
}
286+
#endif /* WOLFCRYPT_TZ_PSA */
273287

274288
int hal_attestation_get_lifecycle(uint32_t *lifecycle)
275289
{

hal/stm32l5.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424
#include <image.h>
2525
#include <string.h>
2626

27+
#if defined(WOLFCRYPT_TZ_PSA)
2728
#if defined(WOLFBOOT_HASH_SHA256)
2829
#include <wolfssl/wolfcrypt/sha256.h>
2930
#elif defined(WOLFBOOT_HASH_SHA384)
3031
#include <wolfssl/wolfcrypt/sha512.h>
3132
#elif defined(WOLFBOOT_HASH_SHA3_384)
3233
#include <wolfssl/wolfcrypt/sha3.h>
3334
#endif
35+
#endif
3436

3537
#include "hal.h"
3638
#include "hal/stm32l5.h"
@@ -117,6 +119,7 @@ int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
117119
#define STM32L5_UID1 (*(volatile uint32_t *)(STM32L5_UID_BASE + 0x4))
118120
#define STM32L5_UID2 (*(volatile uint32_t *)(STM32L5_UID_BASE + 0x8))
119121

122+
#if defined(WOLFCRYPT_TZ_PSA)
120123
static int uds_from_uid(uint8_t *out, size_t out_len)
121124
{
122125
uint8_t uid[12];
@@ -185,6 +188,7 @@ int hal_uds_derive_key(uint8_t *out, size_t out_len)
185188
return -1;
186189
#endif
187190
}
191+
#endif /* WOLFCRYPT_TZ_PSA */
188192

189193
int hal_attestation_get_lifecycle(uint32_t *lifecycle)
190194
{

0 commit comments

Comments
 (0)