summaryrefslogtreecommitdiff
path: root/common/bl_common.c
diff options
context:
space:
mode:
authorJuan Castillo <juan.castillo@arm.com>2015-05-19 11:54:12 +0100
committerJuan Castillo <juan.castillo@arm.com>2015-06-25 08:53:27 +0100
commit1779ba6b97fbff87290f164c7c78559329173e02 (patch)
tree366ee19673e8fbe3b36e676f77511c4f3e4e1268 /common/bl_common.c
parentccbf890e5e2fb75b4df30f50f06c505702a0e01c (diff)
downloadarm-trusted-firmware-1779ba6b97fbff87290f164c7c78559329173e02.tar.gz
TBB: switch to the new authentication framework
This patch modifies the Trusted Board Boot implementation to use the new authentication framework, making use of the authentication module, the cryto module and the image parser module to authenticate the images in the Chain of Trust. A new function 'load_auth_image()' has been implemented. When TBB is enabled, this function will call the authentication module to authenticate parent images following the CoT up to the root of trust to finally load and authenticate the requested image. The platform is responsible for picking up the right makefiles to build the corresponding cryptographic and image parser libraries. ARM platforms use the mbedTLS based libraries. The platform may also specify what key algorithm should be used to sign the certificates. This is done by declaring the 'KEY_ALG' variable in the platform makefile. FVP and Juno use ECDSA keys. On ARM platforms, BL2 and BL1-RW regions have been increased 4KB each to accommodate the ECDSA code. REMOVED BUILD OPTIONS: * 'AUTH_MOD' Change-Id: I47d436589fc213a39edf5f5297bbd955f15ae867
Diffstat (limited to 'common/bl_common.c')
-rw-r--r--common/bl_common.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/common/bl_common.c b/common/bl_common.c
index c8ec4e821..b8558a69d 100644
--- a/common/bl_common.c
+++ b/common/bl_common.c
@@ -31,6 +31,7 @@
#include <arch.h>
#include <arch_helpers.h>
#include <assert.h>
+#include <auth_mod.h>
#include <bl_common.h>
#include <debug.h>
#include <errno.h>
@@ -209,7 +210,7 @@ unsigned long image_size(unsigned int image_id)
******************************************************************************/
int load_image(meminfo_t *mem_layout,
unsigned int image_id,
- uint64_t image_base,
+ uintptr_t image_base,
image_info_t *image_data,
entry_point_info_t *entry_point_info)
{
@@ -308,3 +309,54 @@ exit:
return io_result;
}
+
+/*******************************************************************************
+ * Generic function to load and authenticate an image. The image is actually
+ * loaded by calling the 'load_image()' function. In addition, this function
+ * uses recursion to authenticate the parent images up to the root of trust.
+ ******************************************************************************/
+int load_auth_image(meminfo_t *mem_layout,
+ unsigned int image_id,
+ uintptr_t image_base,
+ image_info_t *image_data,
+ entry_point_info_t *entry_point_info)
+{
+ int rc;
+
+#if TRUSTED_BOARD_BOOT
+ unsigned int parent_id;
+
+ /* Use recursion to authenticate parent images */
+ rc = auth_mod_get_parent_id(image_id, &parent_id);
+ if (rc == 0) {
+ rc = load_auth_image(mem_layout, parent_id, image_base,
+ image_data, NULL);
+ if (rc != IO_SUCCESS) {
+ return rc;
+ }
+ }
+#endif /* TRUSTED_BOARD_BOOT */
+
+ /* Load the image */
+ rc = load_image(mem_layout, image_id, image_base, image_data,
+ entry_point_info);
+ if (rc != IO_SUCCESS) {
+ return rc;
+ }
+
+#if TRUSTED_BOARD_BOOT
+ /* Authenticate it */
+ rc = auth_mod_verify_img(image_id,
+ (void *)image_data->image_base,
+ image_data->image_size);
+ if (rc != 0) {
+ return IO_FAIL;
+ }
+
+ /* After working with data, invalidate the data cache */
+ inv_dcache_range(image_data->image_base,
+ (size_t)image_data->image_size);
+#endif /* TRUSTED_BOARD_BOOT */
+
+ return IO_SUCCESS;
+}