@@ -81,6 +81,17 @@ BOOT_LOG_MODULE_DECLARE(mcuboot);
81
81
#define ARRAY_SIZE ZCBOR_ARRAY_SIZE
82
82
#endif
83
83
84
+ #if defined(MCUBOOT_SHA512 )
85
+ #define IMAGE_HASH_SIZE (64)
86
+ #define IMAGE_SHA_TLV IMAGE_TLV_SHA512
87
+ #elif defined(MCUBOOT_SIGN_EC384 )
88
+ #define IMAGE_HASH_SIZE (48)
89
+ #define IMAGE_SHA_TLV IMAGE_TLV_SHA384
90
+ #else
91
+ #define IMAGE_HASH_SIZE (32)
92
+ #define IMAGE_SHA_TLV IMAGE_TLV_SHA256
93
+ #endif
94
+
84
95
#ifndef MCUBOOT_SERIAL_MAX_RECEIVE_SIZE
85
96
#define MCUBOOT_SERIAL_MAX_RECEIVE_SIZE 512
86
97
#endif
@@ -91,7 +102,7 @@ BOOT_LOG_MODULE_DECLARE(mcuboot);
91
102
#define BOOT_SERIAL_IMAGE_STATE_SIZE_MAX 0
92
103
#endif
93
104
#ifdef MCUBOOT_SERIAL_IMG_GRP_HASH
94
- #define BOOT_SERIAL_HASH_SIZE_MAX 36
105
+ #define BOOT_SERIAL_HASH_SIZE_MAX (IMAGE_HASH_SIZE + 4)
95
106
#else
96
107
#define BOOT_SERIAL_HASH_SIZE_MAX 0
97
108
#endif
@@ -263,7 +274,7 @@ bs_list(char *buf, int len)
263
274
const struct flash_area * fap ;
264
275
uint8_t image_index ;
265
276
#ifdef MCUBOOT_SERIAL_IMG_GRP_HASH
266
- uint8_t hash [32 ];
277
+ uint8_t hash [IMAGE_HASH_SIZE ];
267
278
#endif
268
279
269
280
zcbor_map_start_encode (cbor_state , 1 );
@@ -336,7 +347,7 @@ bs_list(char *buf, int len)
336
347
}
337
348
338
349
#ifdef MCUBOOT_SERIAL_IMG_GRP_HASH
339
- /* Retrieve SHA256 hash of image for identification */
350
+ /* Retrieve hash of image for identification */
340
351
rc = boot_serial_get_hash (& hdr , fap , hash );
341
352
#endif
342
353
@@ -440,7 +451,7 @@ bs_set(char *buf, int len)
440
451
*/
441
452
uint8_t image_index = 0 ;
442
453
size_t decoded = 0 ;
443
- uint8_t hash [32 ];
454
+ uint8_t hash [IMAGE_HASH_SIZE ];
444
455
bool confirm ;
445
456
struct zcbor_string img_hash ;
446
457
bool ok ;
@@ -523,7 +534,7 @@ bs_set(char *buf, int len)
523
534
}
524
535
}
525
536
526
- /* Retrieve SHA256 hash of image for identification */
537
+ /* Retrieve hash of image for identification */
527
538
rc = boot_serial_get_hash (& hdr , fap , hash );
528
539
flash_area_close (fap );
529
540
@@ -1467,9 +1478,9 @@ static int boot_serial_get_hash(const struct image_header *hdr,
1467
1478
break ;
1468
1479
}
1469
1480
1470
- if (type == IMAGE_TLV_SHA256 ) {
1481
+ if (type == IMAGE_SHA_TLV ) {
1471
1482
/* Get the image's hash value from the manifest section. */
1472
- if (len != 32 ) {
1483
+ if (len != IMAGE_HASH_SIZE ) {
1473
1484
return -1 ;
1474
1485
}
1475
1486
0 commit comments