OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
| 7 # Run verified boot firmware and kernel verification tests. |
| 8 |
| 9 return_code=0 |
| 10 hash_algos=( sha1 sha256 sha512 ) |
| 11 key_lengths=( 1024 2048 4096 8192 ) |
| 12 TEST_FILE=test_file |
| 13 TEST_FILE_SIZE=1000000 |
| 14 |
| 15 COL_RED='\E[31;1m' |
| 16 COL_GREEN='\E[32;1m' |
| 17 COL_YELLOW='\E[33;1m' |
| 18 COL_BLUE='\E[34;1m' |
| 19 COL_STOP='\E[0;m' |
| 20 |
| 21 function test_firmware_verification { |
| 22 algorithmcounter=0 |
| 23 for keylen in ${key_lengths[@]} |
| 24 do |
| 25 for hashalgo in ${hash_algos[@]} |
| 26 do |
| 27 echo -e "For Root key ${COL_YELLOW}RSA-$keylen/$hashalgo${COL_STOP}:" |
| 28 cd ${UTIL_DIR} && ${TEST_DIR}/firmware_image_tests $algorithmcounter \ |
| 29 ${TEST_DIR}/testkeys/key_rsa8192.pem \ |
| 30 ${TEST_DIR}/testkeys/key_rsa8192.keyb \ |
| 31 ${TEST_DIR}/testkeys/key_rsa${keylen}.pem \ |
| 32 ${TEST_DIR}/testkeys/key_rsa${keylen}.keyb |
| 33 if [ $? -ne 0 ] |
| 34 then |
| 35 return_code=255 |
| 36 fi |
| 37 let algorithmcounter=algorithmcounter+1 |
| 38 done |
| 39 done |
| 40 } |
| 41 |
| 42 function test_kernel_verification { |
| 43 # Test for various combinations of firmware signing algorithm and |
| 44 # kernel signing algorithm |
| 45 firmware_algorithmcounter=0 |
| 46 kernel_algorithmcounter=0 |
| 47 for firmware_keylen in ${key_lengths[@]} |
| 48 do |
| 49 for firmware_hashalgo in ${hash_algos[@]} |
| 50 do |
| 51 let kernel_algorithmcounter=0 |
| 52 for kernel_keylen in ${key_lengths[@]} |
| 53 do |
| 54 for kernel_hashalgo in ${hash_algos[@]} |
| 55 do |
| 56 echo -e "For ${COL_YELLOW}Firmware signing algorithm \ |
| 57 RSA-${firmware_keylen}/${firmware_hashalgo}${COL_STOP} \ |
| 58 and ${COL_YELLOW}Kernel signing algorithm RSA-${kernel_keylen}/\ |
| 59 ${kernel_hashalgo}${COL_STOP}" |
| 60 cd ${UTIL_DIR} && ${TEST_DIR}/kernel_image_tests \ |
| 61 $firmware_algorithmcounter $kernel_algorithmcounter \ |
| 62 ${TEST_DIR}/testkeys/key_rsa${firmware_keylen}.pem \ |
| 63 ${TEST_DIR}/testkeys/key_rsa${firmware_keylen}.keyb \ |
| 64 ${TEST_DIR}/testkeys/key_rsa${kernel_keylen}.pem \ |
| 65 ${TEST_DIR}/testkeys/key_rsa${kernel_keylen}.keyb |
| 66 if [ $? -ne 0 ] |
| 67 then |
| 68 return_code=255 |
| 69 fi |
| 70 let kernel_algorithmcounter=kernel_algorithmcounter+1 |
| 71 done |
| 72 done |
| 73 let firmware_algorithmcounter=firmware_algorithmcounter+1 |
| 74 done |
| 75 done |
| 76 } |
| 77 |
| 78 # Determine script directory. |
| 79 if [[ $0 == '/'* ]]; |
| 80 then |
| 81 SCRIPT_DIR="`dirname $0`" |
| 82 elif [[ $0 == './'* ]]; |
| 83 then |
| 84 SCRIPT_DIR="`pwd`" |
| 85 else |
| 86 SCRIPT_DIR="`pwd`"/"`dirname $0`" |
| 87 fi |
| 88 UTIL_DIR=`dirname ${SCRIPT_DIR}`/utils |
| 89 KEY_DIR=${SCRIPT_DIR}/testkeys |
| 90 TEST_DIR=${SCRIPT_DIR}/ |
| 91 |
| 92 echo |
| 93 echo "Testing high-level firmware image verification..." |
| 94 test_firmware_verification |
| 95 |
| 96 echo |
| 97 echo "Testing high-level kernel image verification..." |
| 98 test_kernel_verification |
| 99 |
| 100 exit $return_code |
OLD | NEW |