]> git.sur5r.net Git - u-boot/blobdiff - test/vboot/vboot_test.sh
spi: Rename SPI_TX_BP|QPP to SPI_TX_BYTE|QUAD
[u-boot] / test / vboot / vboot_test.sh
index 3e2856ed1ff92c2198cea4d24ab54e8fcf6853ab..6d7abb82bd72b85a861e3524a7b92c34e853817a 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Copyright (c) 2013, Google Inc.
 #
@@ -14,7 +14,7 @@ set -e
 run_uboot() {
        echo -n "Test Verified Boot Run: $1: "
        ${uboot} -d sandbox-u-boot.dtb >${tmp} -c '
-sb load host 0 100 test.fit;
+sb load hostfs - 100 test.fit;
 fdt addr 100;
 bootm 100;
 reset'
@@ -47,14 +47,23 @@ O=$(readlink -f ${O})
 dtc="-I dts -O dtb -p 2000"
 uboot="${O}/u-boot"
 mkimage="${O}/tools/mkimage"
+fit_check_sign="${O}/tools/fit_check_sign"
 keys="${dir}/dev-keys"
 echo ${mkimage} -D "${dtc}"
 
 echo "Build keys"
 mkdir -p ${keys}
 
+PUBLIC_EXPONENT=${1}
+
+if [ -z "${PUBLIC_EXPONENT}" ]; then
+       PUBLIC_EXPONENT=65537
+fi
+
 # Create an RSA key pair
-openssl genrsa -F4 -out ${keys}/dev.key 2048 2>/dev/null
+openssl genpkey -algorithm RSA -out ${keys}/dev.key \
+    -pkeyopt rsa_keygen_bits:2048 \
+    -pkeyopt rsa_keygen_pubexp:${PUBLIC_EXPONENT} 2>/dev/null
 
 # Create a certificate containing the public key
 openssl req -batch -new -x509 -key ${keys}/dev.key -out ${keys}/dev.crt
@@ -99,6 +108,25 @@ function do_test {
 
        run_uboot "signed config" "dev+"
 
+       echo check signed config on the host
+       if ! ${fit_check_sign} -f test.fit -k sandbox-u-boot.dtb >${tmp}; then
+               echo
+               echo "Verified boot key check on host failed, output follows:"
+               cat ${tmp}
+               false
+       else
+               if ! grep -q "dev+" ${tmp}; then
+                       echo
+                       echo "Verified boot key check failed, output follows:"
+                       cat ${tmp}
+                       false
+               else
+                       echo "OK"
+               fi
+       fi
+
+       run_uboot "signed config" "dev+"
+
        # Increment the first byte of the signature, which should cause failure
        sig=$(fdtget -t bx test.fit /configurations/conf@1/signature@1 value)
        newbyte=$(printf %x $((0x${sig:0:2} + 1)))