Fix get_key_id(), secure boot on Optimus Prime
In the commit copied below, we added the board ids for Optimus Prime and
Sideswipe Prime but forgot to update MAX_BOARD_ID accordingly.
Remove MAX_BOARD_ID. Use ARRAY_SIZE(board_id_to_key_index) instead to
avoid uncontrolled redundancy.
commit 8fe43d12824527f7ed4205d00643c447b7e47479
Author: Daniel Mentz <danielmentz@google.com>
Date: Thu Jul 30 14:04:16 2015 -0700
Add board ids for Optimus Prime and Sideswipe Prime
Define board ids for Optimus Prime and Sideswipe Prime. Map these board
ids to the Optimus public rsa key for secure boot purposes. Define
signatures (OPTIMUS_PRIME_BOARD_ID_OTP) to be stored in the OTP memory.
Change-Id: If4af71693c664d35b4253eca01dc39fd9ebff079
diff --git a/lib/rsa/rsa_public_keys.c b/lib/rsa/rsa_public_keys.c
index 8c67996..2c325b0 100644
--- a/lib/rsa/rsa_public_keys.c
+++ b/lib/rsa/rsa_public_keys.c
@@ -3,8 +3,6 @@
#include <rsa_public_key.h>
#include <board_id.h>
-#define MAX_BOARD_ID SPACECAST_BOARD_ID
-
static int board_id_to_key_index[] = {
0, /* OPTIMUS_BOARD_ID */
0, /* SIDESWIPE_BOARD_ID */
@@ -254,7 +252,8 @@
#endif
static int get_key_id(int board_id) {
- if ((board_id < 0) || (board_id > MAX_BOARD_ID)) {
+ if ((board_id < 0) ||
+ (board_id >= ARRAY_SIZE(board_id_to_key_index))) {
printf("Invalid board ID: %d\n", board_id);
return -1;
}