aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/auth/mbedtls
diff options
context:
space:
mode:
authorJuan Castillo <juan.castillo@arm.com>2016-01-22 11:05:57 +0000
committerJuan Castillo <juan.castillo@arm.com>2016-03-31 13:29:17 +0100
commit48279d52a7e339e88b5088ce5a276bf169c71754 (patch)
tree0230f81728e549206dfedfdb953d1415621d8da4 /drivers/auth/mbedtls
parent96103d5af671b566cf523b0a5a1bb4fe4ef9bb64 (diff)
downloadplatform_external_arm-trusted-firmware-48279d52a7e339e88b5088ce5a276bf169c71754.tar.gz
platform_external_arm-trusted-firmware-48279d52a7e339e88b5088ce5a276bf169c71754.tar.bz2
platform_external_arm-trusted-firmware-48279d52a7e339e88b5088ce5a276bf169c71754.zip
TBB: add non-volatile counter support
This patch adds support for non-volatile counter authentication to the Authentication Module. This method consists of matching the counter values provided in the certificates with the ones stored in the platform. If the value from the certificate is lower than the platform, the boot process is aborted. This mechanism protects the system against rollback. The TBBR CoT has been updated to include this method as part of the authentication process. Two counters are used: one for the trusted world images and another for the non trusted world images. ** NEW PLATFORM APIs (mandatory when TBB is enabled) ** int plat_get_nv_ctr(void *cookie, unsigned int *nv_ctr); This API returns the non-volatile counter value stored in the platform. The cookie in the first argument may be used to select the counter in case the platform provides more than one (i.e. TBSA compliant platforms must provide trusted and non-trusted counters). This cookie is specified in the CoT. int plat_set_nv_ctr(void *cookie, unsigned int nv_ctr); This API sets a new counter value. The cookie may be used to select the counter to be updated. An implementation of these new APIs for ARM platforms is also provided. The values are obtained from the Trusted Non-Volatile Counters peripheral. The cookie is used to pass the extension OID. This OID may be interpreted by the platform to know which counter must return. On Juno, The trusted and non-trusted counter values have been tied to 31 and 223, respectively, and cannot be modified. ** IMPORTANT ** THIS PATCH BREAKS THE BUILD WHEN TRUSTED_BOARD_BOOT IS ENABLED. THE NEW PLATFORM APIs INTRODUCED IN THIS PATCH MUST BE IMPLEMENTED IN ORDER TO SUCCESSFULLY BUILD TF. Change-Id: Ic943b76b25f2a37f490eaaab6d87b4a8b3cbc89a
Diffstat (limited to 'drivers/auth/mbedtls')
-rw-r--r--drivers/auth/mbedtls/mbedtls_x509_parser.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/auth/mbedtls/mbedtls_x509_parser.c b/drivers/auth/mbedtls/mbedtls_x509_parser.c
index 52e697193..1a6a9a75e 100644
--- a/drivers/auth/mbedtls/mbedtls_x509_parser.c
+++ b/drivers/auth/mbedtls/mbedtls_x509_parser.c
@@ -405,6 +405,13 @@ static int check_integrity(void *img, unsigned int img_len)
/*
* Extract an authentication parameter from an X509v3 certificate
+ *
+ * This function returns a pointer to the extracted data and its length.
+ * Depending on the type of parameter, a pointer to the data stored in the
+ * certificate may be returned (i.e. an octet string containing a hash). Other
+ * data may need to be copied and formatted (i.e. integers). In the later case,
+ * a buffer of the correct type needs to be statically allocated, filled and
+ * returned.
*/
static int get_auth_param(const auth_param_type_desc_t *type_desc,
void *img, unsigned int img_len,
@@ -422,6 +429,7 @@ static int get_auth_param(const auth_param_type_desc_t *type_desc,
*param_len = (unsigned int)tbs.len;
break;
case AUTH_PARAM_HASH:
+ case AUTH_PARAM_NV_CTR:
/* All these parameters are included as X509v3 extensions */
rc = get_ext(type_desc->cookie, param, param_len);
break;