From cd1b5731d49ad9fe0f98eea4c70b647ba8dc79f3 Mon Sep 17 00:00:00 2001 From: Rajko Stojadinovic Date: Wed, 25 Apr 2018 18:43:10 +0200 Subject: [PATCH] Merge User and System BisPartition_t because they are the same key anyway --- fusee/fusee-secondary/src/key_derivation.c | 12 +++++------- fusee/fusee-secondary/src/key_derivation.h | 3 +-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/fusee/fusee-secondary/src/key_derivation.c b/fusee/fusee-secondary/src/key_derivation.c index c00fd781e..87889e3a9 100644 --- a/fusee/fusee-secondary/src/key_derivation.c +++ b/fusee/fusee-secondary/src/key_derivation.c @@ -196,17 +196,15 @@ void derive_bis_key(void *dst, BisPartition_t partition_id, u32 target_firmware) static const u8 bis_kek_source[0x10] = {0x34, 0xC1, 0xA0, 0xC4, 0x82, 0x58, 0xF8, 0xB4, 0xFA, 0x9E, 0x5E, 0x6A, 0xDA, 0xFC, 0x7E, 0x4F}; - const int key_source_idx = (partition_id > 2) ? 2 : partition_id; switch (partition_id) { case BisPartition_Calibration: - fusee_generate_specific_aes_key(dst, key_source_for_bis[key_source_idx][0], false, target_firmware); - fusee_generate_specific_aes_key(dst + 0x10, key_source_for_bis[key_source_idx][1], false, target_firmware); + fusee_generate_specific_aes_key(dst, key_source_for_bis[partition_id][0], false, target_firmware); + fusee_generate_specific_aes_key(dst + 0x10, key_source_for_bis[partition_id][1], false, target_firmware); break; case BisPartition_Safe: - case BisPartition_User: - case BisPartition_System: - fusee_generate_personalized_aes_key_for_bis(dst, bis_kek_source, key_source_for_bis[key_source_idx][0], target_firmware); - fusee_generate_personalized_aes_key_for_bis(dst + 0x10, bis_kek_source, key_source_for_bis[key_source_idx][1], target_firmware); + case BisPartition_UserSystem: + fusee_generate_personalized_aes_key_for_bis(dst, bis_kek_source, key_source_for_bis[partition_id][0], target_firmware); + fusee_generate_personalized_aes_key_for_bis(dst + 0x10, bis_kek_source, key_source_for_bis[partition_id][1], target_firmware); break; default: generic_panic(); diff --git a/fusee/fusee-secondary/src/key_derivation.h b/fusee/fusee-secondary/src/key_derivation.h index 244a83052..ddbc9f4c3 100644 --- a/fusee/fusee-secondary/src/key_derivation.h +++ b/fusee/fusee-secondary/src/key_derivation.h @@ -17,8 +17,7 @@ typedef enum { BisPartition_Calibration = 0, BisPartition_Safe = 1, - BisPartition_User = 2, - BisPartition_System = 3 + BisPartition_UserSystem = 2 } BisPartition_t; typedef struct {