OLD | NEW |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Run verified boot firmware and kernel verification tests. | 7 # Run verified boot firmware and kernel verification tests. |
8 | 8 |
9 # Load common constants and variables. | 9 # Load common constants and variables. |
10 . "$(dirname "$0")/common.sh" | 10 . "$(dirname "$0")/common.sh" |
11 | 11 |
12 return_code=0 | 12 return_code=0 |
13 | 13 |
14 function test_firmware_verification { | 14 function test_firmware_verification { |
15 algorithmcounter=0 | 15 algorithmcounter=0 |
16 for keylen in ${key_lengths[@]} | 16 for keylen in ${key_lengths[@]} |
17 do | 17 do |
18 for hashalgo in ${hash_algos[@]} | 18 for hashalgo in ${hash_algos[@]} |
19 do | 19 do |
20 echo -e "For Root key ${COL_YELLOW}RSA-$keylen/$hashalgo${COL_STOP}:" | 20 echo -e "For Root key ${COL_YELLOW}RSA-$keylen/$hashalgo${COL_STOP}:" |
21 cd ${UTIL_DIR} && ${TEST_DIR}/firmware_image_tests $algorithmcounter \ | 21 ${TEST_DIR}/firmware_image_tests $algorithmcounter \ |
22 ${TESTKEY_DIR}/key_rsa8192.pem \ | 22 ${TESTKEY_DIR}/key_rsa8192.pem \ |
23 ${TESTKEY_DIR}/key_rsa8192.keyb \ | 23 ${TESTKEY_DIR}/key_rsa8192.keyb \ |
24 ${TESTKEY_DIR}/key_rsa${keylen}.pem \ | 24 ${TESTKEY_DIR}/key_rsa${keylen}.pem \ |
25 ${TESTKEY_DIR}/key_rsa${keylen}.keyb | 25 ${TESTKEY_DIR}/key_rsa${keylen}.keyb |
26 if [ $? -ne 0 ] | 26 if [ $? -ne 0 ] |
27 then | 27 then |
28 return_code=255 | 28 return_code=255 |
29 fi | 29 fi |
30 let algorithmcounter=algorithmcounter+1 | 30 let algorithmcounter=algorithmcounter+1 |
31 done | 31 done |
32 done | 32 done |
33 cd ${TEST_DIR} && ${TEST_DIR}/big_firmware_tests | |
petkov
2010/03/30 22:40:06
Another way to write this might be:
cd ${TEST_DIR
| |
34 if [ $? -ne 0 ] | |
35 then | |
36 return_code=255 | |
37 fi | |
33 } | 38 } |
34 | 39 |
35 function test_kernel_verification { | 40 function test_kernel_verification { |
36 # Test for various combinations of firmware signing algorithm and | 41 # Test for various combinations of firmware signing algorithm and |
37 # kernel signing algorithm | 42 # kernel signing algorithm |
38 firmware_algorithmcounter=0 | 43 firmware_algorithmcounter=0 |
39 kernel_algorithmcounter=0 | 44 kernel_algorithmcounter=0 |
40 for firmware_keylen in ${key_lengths[@]} | 45 for firmware_keylen in ${key_lengths[@]} |
41 do | 46 do |
42 for firmware_hashalgo in ${hash_algos[@]} | 47 for firmware_hashalgo in ${hash_algos[@]} |
43 do | 48 do |
44 let kernel_algorithmcounter=0 | 49 let kernel_algorithmcounter=0 |
45 for kernel_keylen in ${key_lengths[@]} | 50 for kernel_keylen in ${key_lengths[@]} |
46 do | 51 do |
47 for kernel_hashalgo in ${hash_algos[@]} | 52 for kernel_hashalgo in ${hash_algos[@]} |
48 do | 53 do |
49 echo -e "For ${COL_YELLOW}Firmware signing algorithm \ | 54 echo -e "For ${COL_YELLOW}Firmware signing algorithm \ |
50 RSA-${firmware_keylen}/${firmware_hashalgo}${COL_STOP} \ | 55 RSA-${firmware_keylen}/${firmware_hashalgo}${COL_STOP} \ |
51 and ${COL_YELLOW}Kernel signing algorithm RSA-${kernel_keylen}/\ | 56 and ${COL_YELLOW}Kernel signing algorithm RSA-${kernel_keylen}/\ |
52 ${kernel_hashalgo}${COL_STOP}" | 57 ${kernel_hashalgo}${COL_STOP}" |
53 cd ${UTIL_DIR} && ${TEST_DIR}/kernel_image_tests \ | 58 ${TEST_DIR}/kernel_image_tests \ |
54 $firmware_algorithmcounter $kernel_algorithmcounter \ | 59 $firmware_algorithmcounter $kernel_algorithmcounter \ |
55 ${TESTKEY_DIR}/key_rsa${firmware_keylen}.pem \ | 60 ${TESTKEY_DIR}/key_rsa${firmware_keylen}.pem \ |
56 ${TESTKEY_DIR}/key_rsa${firmware_keylen}.keyb \ | 61 ${TESTKEY_DIR}/key_rsa${firmware_keylen}.keyb \ |
57 ${TESTKEY_DIR}/key_rsa${kernel_keylen}.pem \ | 62 ${TESTKEY_DIR}/key_rsa${kernel_keylen}.pem \ |
58 ${TESTKEY_DIR}/key_rsa${kernel_keylen}.keyb | 63 ${TESTKEY_DIR}/key_rsa${kernel_keylen}.keyb |
59 if [ $? -ne 0 ] | 64 if [ $? -ne 0 ] |
60 then | 65 then |
61 return_code=255 | 66 return_code=255 |
62 fi | 67 fi |
63 let kernel_algorithmcounter=kernel_algorithmcounter+1 | 68 let kernel_algorithmcounter=kernel_algorithmcounter+1 |
64 done | 69 done |
65 done | 70 done |
66 let firmware_algorithmcounter=firmware_algorithmcounter+1 | 71 let firmware_algorithmcounter=firmware_algorithmcounter+1 |
67 done | 72 done |
68 done | 73 done |
74 cd ${TEST_DIR} && ${TEST_DIR}/big_kernel_tests | |
75 if [ $? -ne 0 ] | |
76 then | |
77 return_code=255 | |
78 fi | |
69 } | 79 } |
70 | 80 |
71 check_test_keys | 81 check_test_keys |
72 echo | 82 echo |
73 echo "Testing high-level firmware image verification..." | 83 echo "Testing high-level firmware image verification..." |
74 test_firmware_verification | 84 test_firmware_verification |
75 | 85 |
76 echo | 86 echo |
77 echo "Testing high-level kernel image verification..." | 87 echo "Testing high-level kernel image verification..." |
78 test_kernel_verification | 88 test_kernel_verification |
79 | 89 |
80 exit $return_code | 90 exit $return_code |
OLD | NEW |