@@ -15,35 +15,27 @@ verify_image_sign_common() {
1515 no_check_time=" -noattr"
1616 fi
1717
18- # This command verifies the signing as a complete certificate chain root of trust and requires the DB Key to
19- # be a self-signed root, but the image signed with an intermediate embedded into the certificate.
2018 EFI_CERTS_DIR=/tmp/efi_certs
2119 RESULT=" CMS Verification Failure"
22- LOG=$( openssl cms -verify $no_check_time -noout -CAfile $EFI_CERTS_DIR /cert.pem -binary -in ${CMS_SIG_FILE} -content ${DATA_FILE} -inform pem 2>&1 > /dev/null )
23- VALIDATION_RES=$?
24- if [ $VALIDATION_RES -eq 0 ]; then
25- RESULT=" CMS Verified OK"
26- if [ -d " ${TMP_DIR} " ]; then rm -rf ${TMP_DIR} ; fi
27- echo " verification ok:$RESULT "
28- # No need to continue.
29- # Exit without error if any success signature verification.
30- return 0
31- fi
3220
33- # This is a backup signature verification method which does NOT trust the certificate embedded into the pkcs7
34- # signature (via the -nointern flag) and assumes the DB key directly signed the image (via the -certfile flag).
35- # Since the DB key is trusted, it doesn't need to be a root CA so we turn off root CA verification with the
36- # -noverify flag.
37- LOG=$( openssl cms -verify $no_check_time -noout -certfile $EFI_CERTS_DIR /cert.pem -binary -nointern -noverify -in ${CMS_SIG_FILE} -content ${DATA_FILE} -inform pem 2>&1 > /dev/null )
38- VALIDATION_RES=$?
39- if [ $VALIDATION_RES -eq 0 ]; then
40- RESULT=" CMS Verified OK"
41- if [ -d " ${TMP_DIR} " ]; then rm -rf ${TMP_DIR} ; fi
42- echo " verification ok:$RESULT "
43- # No need to continue.
44- # Exit without error if any success signature verification.
45- return 0
46- fi
21+ # Verify the signature in two ways:
22+ # 1. As a complete certificate chain root of trust which requires the DB Key to be a self-signed root, but the image
23+ # signed with an intermediate embedded into the certificate.
24+ # 2. Assuming the DB key directly signed the image without trusting the certificate embedded into the
25+ # pkcs7 signature (-nointern). Since the DB key is trusted, it doesn't need to be a root CA so we turn off root
26+ # CA verification with the -noverify flag.
27+ for variant in " -CAfile" " -nointern -noverify -certfile" ; do
28+ LOG=$( openssl cms -verify $no_check_time -noout ${variant} $EFI_CERTS_DIR /cert.pem -binary -in ${CMS_SIG_FILE} -content ${DATA_FILE} -inform pem 2>&1 > /dev/null )
29+ VALIDATION_RES=$?
30+ if [ $VALIDATION_RES -eq 0 ]; then
31+ RESULT=" CMS Verified OK"
32+ if [ -d " ${TMP_DIR} " ]; then rm -rf ${TMP_DIR} ; fi
33+ echo " verification ok:$RESULT "
34+ # No need to continue.
35+ # Exit without error if any success signature verification.
36+ return 0
37+ fi
38+ done
4739
4840 if [ -d " ${TMP_DIR} " ]; then rm -rf ${TMP_DIR} ; fi
4941 return 1
0 commit comments