aboutsummaryrefslogtreecommitdiff
path: root/libstb
diff options
context:
space:
mode:
authorDaniel Axtens <dja@axtens.net>2021-06-21 18:26:41 +1000
committerCédric Le Goater <clg@kaod.org>2021-12-09 11:09:02 +0100
commit1f4d12cf706de11eadc2e25da948340cefb595b3 (patch)
treeb202f8993acc5068756fe5ed483e7266106918ab /libstb
parent301b3f782e4114988c87e2417fbfd1a60de75e24 (diff)
downloadskiboot-1f4d12cf706de11eadc2e25da948340cefb595b3.zip
skiboot-1f4d12cf706de11eadc2e25da948340cefb595b3.tar.gz
skiboot-1f4d12cf706de11eadc2e25da948340cefb595b3.tar.bz2
secvar/pkcs7: fix a wrong sizeof()
This code isn't directly used by skiboot, but it is wrong and potentially insecure so I'm fixing it in case it's used in the future. We pass sizeof(hash) into mbedtls_pk_verify(). However, hash is a pointer, not an array, so rather than passing the length of the hash to verify we'll pass in 8, and only compare the first 8 bytes of the hash rather than all 32. Pass in 0 instead. That tells mbedtls to work out the length based on the hash type. We allocated enough memory for whatever hash type the PKCS#7 message declared so this will be safe. Signed-off-by: Daniel Axtens <dja@axtens.net> Signed-off-by: Cédric Le Goater <clg@kaod.org>
Diffstat (limited to 'libstb')
-rw-r--r--libstb/crypto/pkcs7/pkcs7.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libstb/crypto/pkcs7/pkcs7.c b/libstb/crypto/pkcs7/pkcs7.c
index a523a9d..2afa315 100644
--- a/libstb/crypto/pkcs7/pkcs7.c
+++ b/libstb/crypto/pkcs7/pkcs7.c
@@ -540,7 +540,7 @@ int mbedtls_pkcs7_signed_data_verify( mbedtls_pkcs7 *pkcs7,
mbedtls_md( md_info, data, datalen, hash );
- ret = mbedtls_pk_verify( &pk_cxt, md_alg, hash, sizeof(hash),
+ ret = mbedtls_pk_verify( &pk_cxt, md_alg, hash, 0,
pkcs7->signed_data.signers.sig.p,
pkcs7->signed_data.signers.sig.len );