summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes-recipe/uboot-sign.bbclass60
1 files changed, 51 insertions, 9 deletions
diff --git a/meta/classes-recipe/uboot-sign.bbclass b/meta/classes-recipe/uboot-sign.bbclass
index 96c47ab016..5c579a9fb0 100644
--- a/meta/classes-recipe/uboot-sign.bbclass
+++ b/meta/classes-recipe/uboot-sign.bbclass
@@ -101,27 +101,69 @@ concat_dtb() {
101 binary="$2" 101 binary="$2"
102 102
103 if [ -e "${UBOOT_DTB_BINARY}" ]; then 103 if [ -e "${UBOOT_DTB_BINARY}" ]; then
104 # Re-sign the kernel in order to add the keys to our dtb
105 UBOOT_MKIMAGE_MODE="auto-conf"
106 # Signing individual images is not recommended as that 104 # Signing individual images is not recommended as that
107 # makes fitImage susceptible to mix-and-match attack. 105 # makes fitImage susceptible to mix-and-match attack.
106 #
107 # OE FIT_SIGN_INDIVIDUAL is implemented in an unusual manner,
108 # where the resulting signed fitImage contains both signed
109 # images and signed configurations. This is redundant. In
110 # order to prevent mix-and-match attack, it is sufficient
111 # to sign configurations. The FIT_SIGN_INDIVIDUAL = "1"
112 # support is kept to avoid breakage of existing layers, but
113 # it is highly recommended to avoid FIT_SIGN_INDIVIDUAL = "1",
114 # i.e. set FIT_SIGN_INDIVIDUAL = "0" .
108 if [ "${FIT_SIGN_INDIVIDUAL}" = "1" ] ; then 115 if [ "${FIT_SIGN_INDIVIDUAL}" = "1" ] ; then
109 UBOOT_MKIMAGE_MODE="auto" 116 # Sign dummy image images in order to
117 # add the image signing keys to our dtb
118 ${UBOOT_MKIMAGE_SIGN} \
119 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
120 -f auto \
121 -k "${UBOOT_SIGN_KEYDIR}" \
122 -o "${FIT_HASH_ALG},${FIT_SIGN_ALG}" \
123 -g "${UBOOT_SIGN_IMG_KEYNAME}" \
124 -K "${UBOOT_DTB_BINARY}" \
125 -d /dev/null \
126 -r ${B}/unused.itb \
127 ${UBOOT_MKIMAGE_SIGN_ARGS}
110 fi 128 fi
129
130 # Sign dummy image configurations in order to
131 # add the configuration signing keys to our dtb
111 ${UBOOT_MKIMAGE_SIGN} \ 132 ${UBOOT_MKIMAGE_SIGN} \
112 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \ 133 ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' if len('${UBOOT_MKIMAGE_DTCOPTS}') else ''} \
113 -f $UBOOT_MKIMAGE_MODE \ 134 -f auto-conf \
114 -k "${UBOOT_SIGN_KEYDIR}" \ 135 -k "${UBOOT_SIGN_KEYDIR}" \
115 -o "${FIT_HASH_ALG},${FIT_SIGN_ALG}" \ 136 -o "${FIT_HASH_ALG},${FIT_SIGN_ALG}" \
116 -g "${UBOOT_SIGN_IMG_KEYNAME}" \ 137 -g "${UBOOT_SIGN_KEYNAME}" \
117 -K "${UBOOT_DTB_BINARY}" \ 138 -K "${UBOOT_DTB_BINARY}" \
118 -d /dev/null \ 139 -d /dev/null \
119 -r ${B}/unused.itb \ 140 -r ${B}/unused.itb \
120 ${UBOOT_MKIMAGE_SIGN_ARGS} 141 ${UBOOT_MKIMAGE_SIGN_ARGS}
121 # Verify the kernel image and u-boot dtb 142
122 ${UBOOT_FIT_CHECK_SIGN} \ 143 # Verify the dummy fitImage signature against u-boot.dtb
123 -k "${UBOOT_DTB_BINARY}" \ 144 # augmented using public key material.
124 -f ${B}/unused.itb 145 #
146 # This only works for FIT_SIGN_INDIVIDUAL = "0", because
147 # mkimage -f auto-conf does not support -F to extend the
148 # existing unused.itb , and instead rewrites unused.itb
149 # from scratch.
150 #
151 # Using two separate unused.itb for mkimage -f auto and
152 # mkimage -f auto-conf invocation above would not help, as
153 # the signature verification process below checks whether
154 # all keys inserted into u-boot.dtb /signature node pass
155 # the verification. Separate unused.itb would each miss one
156 # of the signatures.
157 #
158 # The FIT_SIGN_INDIVIDUAL = "1" support is kept to avoid
159 # breakage of existing layers, but it is highly recommended
160 # to not use FIT_SIGN_INDIVIDUAL = "1", i.e. set
161 # FIT_SIGN_INDIVIDUAL = "0" .
162 if [ "${FIT_SIGN_INDIVIDUAL}" != "1" ] ; then
163 ${UBOOT_FIT_CHECK_SIGN} \
164 -k "${UBOOT_DTB_BINARY}" \
165 -f ${B}/unused.itb
166 fi
125 cp ${UBOOT_DTB_BINARY} ${UBOOT_DTB_SIGNED} 167 cp ${UBOOT_DTB_BINARY} ${UBOOT_DTB_SIGNED}
126 fi 168 fi
127 169