summaryrefslogtreecommitdiff
path: root/include/rsa.h
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2015-09-25 14:39:52 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-09-25 19:36:37 -0700
commit094a81f5deff3b8cf5342138afefef8d8f34f8ff (patch)
tree5e0624367d5b9b7ca1c25b877db217b999f8e80c /include/rsa.h
parente9000b22cb0e15df7d1389da30d78e7244086d0b (diff)
downloadchrome-ec-094a81f5deff3b8cf5342138afefef8d8f34f8ff.tar.gz
cleanup: Handle signed RW images a bit cleaner
For signed EC RW images (CONFIG_RWSIG), there's no point in embedding the public key or signature into the image itself since it will just be replaced by the signer (either as the next step in the build process, or after the fact for MP releases). This takes that out and just points to where the pubkey and signature will be placed. BUG=none BRANCH=none TEST=make buildall I also checked the signatures with futility show -t build/*/ec.bin They still look good, and the one signed image I booted (Cr50) works as before. Change-Id: Ib39b7c508914851f81a1bebb2450e08ef0def76c Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/302630 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include/rsa.h')
-rw-r--r--include/rsa.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/include/rsa.h b/include/rsa.h
index ab45695910..2fb896c652 100644
--- a/include/rsa.h
+++ b/include/rsa.h
@@ -12,7 +12,7 @@
#define CONFIG_RSA_KEY_SIZE 2048 /* default to 2048-bit key length */
#endif
-#define RSANUMBYTES ((CONFIG_RSA_KEY_SIZE)/8)
+#define RSANUMBYTES ((CONFIG_RSA_KEY_SIZE) / 8)
#define RSANUMWORDS (RSANUMBYTES / sizeof(uint32_t))
#ifdef CONFIG_RSA /* reserve space for public key only if used */
@@ -53,4 +53,32 @@ void check_rw_signature(void);
#endif /* !__ASSEMBLER__ */
+/*
+ * The signer puts the public key and signature into the RO and RW images
+ * (respectively) at known locations after the complete image is assembled. But
+ * since we compile the RO & RW images separately, the other image's addresses
+ * can't be computed by the linker. So we just hardcode the addresses here.
+ * 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
+#define CONFIG_RO_PUBKEY_SIZE RSA_PUBLIC_KEY_SIZE
+#endif
+#ifndef CONFIG_RO_PUBKEY_ADDR
+#define CONFIG_RO_PUBKEY_ADDR (CONFIG_PROGRAM_MEMORY_BASE \
+ + (CONFIG_FLASH_SIZE / 2) \
+ - CONFIG_RO_PUBKEY_SIZE)
+#endif
+
+/* The signature goes at the end of the second half of flash */
+#ifndef CONFIG_RW_SIG_SIZE
+#define CONFIG_RW_SIG_SIZE RSANUMBYTES
+#endif
+#ifndef CONFIG_RW_SIG_ADDR
+#define CONFIG_RW_SIG_ADDR (CONFIG_PROGRAM_MEMORY_BASE \
+ + CONFIG_FLASH_SIZE \
+ - CONFIG_RW_SIG_SIZE)
+#endif
+
#endif /* __CROS_EC_RSA_H */