summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>2017-02-09 10:26:54 +0000
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>2017-02-16 15:15:23 +0000
commitfabd21ad36a4ae405fbc6a938151620cda8bc31e (patch)
treed1b7c572086e0f31256e08cba46bf6eab7889d72 /drivers
parent4d07e7821e19dc1ebc640f5264c2a769354c8b2d (diff)
Revert "tbbr: Use constant-time bcmp() to compare hashes"
This reverts commit b621fb503c76f3bdf06ed5ed1d3a995df8da9c50. Because of the Trusted Firmware design, timing-safe functions are not needed. Using them may be misleading as it could be interpreted as being a protection against private data leakage, which isn't the case here. For each image, the SHA-256 hash is calculated. Some padding is appended and the result is encrypted with a private key using RSA-2048. This is the signature of the image. The public key is stored along with BL1 in read-only memory and the encrypted hash is stored in the FIP. When authenticating an image, the TF decrypts the hash stored in the FIP and recalculates the hash of the image. If they don't match, the boot sequence won't continue. A constant-time comparison does not provide additional security as all the data involved in this process is already known to any attacker. There is no private data that can leaked through a timing attack when authenticating an image. `timingsafe_bcmp()` is kept in the codebase because it could be useful in the future. Change-Id: I44bdcd58faa586a050cc89447e38c142508c9888 Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/auth/mbedtls/mbedtls_crypto.c2
-rw-r--r--drivers/auth/mbedtls/mbedtls_x509_parser.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/drivers/auth/mbedtls/mbedtls_crypto.c b/drivers/auth/mbedtls/mbedtls_crypto.c
index 11d3ede4..1a96e8f8 100644
--- a/drivers/auth/mbedtls/mbedtls_crypto.c
+++ b/drivers/auth/mbedtls/mbedtls_crypto.c
@@ -217,7 +217,7 @@ static int verify_hash(void *data_ptr, unsigned int data_len,
}
/* Compare values */
- rc = timingsafe_bcmp(data_hash, hash, mbedtls_md_get_size(md_info));
+ rc = memcmp(data_hash, hash, mbedtls_md_get_size(md_info));
if (rc != 0) {
return CRYPTO_ERR_HASH;
}
diff --git a/drivers/auth/mbedtls/mbedtls_x509_parser.c b/drivers/auth/mbedtls/mbedtls_x509_parser.c
index f9485de3..73da9d1e 100644
--- a/drivers/auth/mbedtls/mbedtls_x509_parser.c
+++ b/drivers/auth/mbedtls/mbedtls_x509_parser.c
@@ -392,7 +392,7 @@ static int cert_parse(void *img, unsigned int img_len)
if (sig_alg1.len != sig_alg2.len) {
return IMG_PARSER_ERR_FORMAT;
}
- if (0 != timingsafe_bcmp(sig_alg1.p, sig_alg2.p, sig_alg1.len)) {
+ if (0 != memcmp(sig_alg1.p, sig_alg2.p, sig_alg1.len)) {
return IMG_PARSER_ERR_FORMAT;
}
memcpy(&sig_alg, &sig_alg1, sizeof(sig_alg));