summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@google.com>2017-01-09 11:53:40 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-02-22 03:29:28 -0800
commit30cc21b9329fa36904b164b330fa6754dff1a4fe (patch)
tree9088743ecdd7182815c3e52488ba8a7217ddb812
parent70b1752c313513f03ac94b695297f51afec4edb2 (diff)
downloadchrome-ec-30cc21b9329fa36904b164b330fa6754dff1a4fe.tar.gz
rwsig: Put key/signature at the end of RO/RW sections
Current code puts key at the end of the first half of flash, which may not match the actual RO section size (e.g., it might be PSTATE, not RO). This makes sure the key to be at the end of RO section, and signature at the end of RW section, no matter the actual layout being used. However, the (deprecated) usbpd1 image type assumes that flash is equally split between RO and RW, so we do not change that. BRANCH=none BUG=chrome-os-partner:61671 TEST=make BOARD=hammer -j && deploy TEST=make BOARD=hoho -j && \ futility show --type usbpd1 build/hoho/ec.bin Change-Id: Ia02e927f9128d6ec3d0b780c28312e0d18835d72 Reviewed-on: https://chromium-review.googlesource.com/426100 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--include/rsa.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/include/rsa.h b/include/rsa.h
index ca3b227aae..5999159817 100644
--- a/include/rsa.h
+++ b/include/rsa.h
@@ -39,6 +39,7 @@
#ifndef __ASSEMBLER__
#include "common.h"
+#include "util.h"
#ifdef CONFIG_RWSIG_TYPE_RWSIG
/* RSA public key definition, VBoot2 packing */
@@ -74,7 +75,6 @@ void check_rw_signature(void);
* These can be overridden in board.h files if desired.
*/
-/* The pubkey goes at the end of the first half of flash */
#ifndef CONFIG_RO_PUBKEY_SIZE
#ifdef CONFIG_RWSIG_TYPE_RWSIG
/*
@@ -90,12 +90,23 @@ void check_rw_signature(void);
#endif
#endif /* ! CONFIG_RO_PUBKEY_SIZE */
#ifndef CONFIG_RO_PUBKEY_ADDR
+#ifdef CONFIG_RWSIG_TYPE_RWSIG
+/* The pubkey goes at the end of the RO region */
+#define CONFIG_RO_PUBKEY_ADDR (CONFIG_PROGRAM_MEMORY_BASE \
+ + CONFIG_RO_MEM_OFF \
+ + CONFIG_RO_SIZE \
+ - CONFIG_RO_PUBKEY_SIZE)
+#else
+/*
+ * usbpd1 type assumes pubkey location at the end of first half of flash,
+ * which might actually be in the PSTATE region.
+ */
#define CONFIG_RO_PUBKEY_ADDR (CONFIG_PROGRAM_MEMORY_BASE \
+ (CONFIG_FLASH_SIZE / 2) \
- CONFIG_RO_PUBKEY_SIZE)
#endif
+#endif /* CONFIG_RO_PUBKEY_ADDR */
-/* The signature goes at the end of the second half of flash */
#ifndef CONFIG_RW_SIG_SIZE
#ifdef CONFIG_RWSIG_TYPE_RWSIG
/*
@@ -108,9 +119,11 @@ void check_rw_signature(void);
#endif
#endif /* ! CONFIG_RW_SIG_SIZE */
#ifndef CONFIG_RW_SIG_ADDR
+/* The signature goes at the end of the RW region */
#define CONFIG_RW_SIG_ADDR (CONFIG_PROGRAM_MEMORY_BASE \
- + CONFIG_FLASH_SIZE \
+ + CONFIG_RW_MEM_OFF \
+ + CONFIG_RW_SIZE \
- CONFIG_RW_SIG_SIZE)
-#endif
+#endif /* !CONFIG_RW_SIG_ADDR */
#endif /* __CROS_EC_RSA_H */