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" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 echo -e "For ${COL_YELLOW}signing algorithm \ | 61 echo -e "For ${COL_YELLOW}signing algorithm \ |
62 RSA-${signing_keylen}/${signing_hashalgo}${COL_STOP} \ | 62 RSA-${signing_keylen}/${signing_hashalgo}${COL_STOP} \ |
63 and ${COL_YELLOW}data key algorithm RSA-${datakeylen}/\ | 63 and ${COL_YELLOW}data key algorithm RSA-${datakeylen}/\ |
64 ${datahashalgo}${COL_STOP}" | 64 ${datahashalgo}${COL_STOP}" |
65 # Remove old file | 65 # Remove old file |
66 keyblockfile="${TESTKEY_SCRATCH_DIR}/" | 66 keyblockfile="${TESTKEY_SCRATCH_DIR}/" |
67 keyblockfile+="sign${signing_algorithmcounter}_data" | 67 keyblockfile+="sign${signing_algorithmcounter}_data" |
68 keyblockfile+="${data_algorithmcounter}.keyblock" | 68 keyblockfile+="${data_algorithmcounter}.keyblock" |
69 rm -f ${keyblockfile} | 69 rm -f ${keyblockfile} |
70 | 70 |
71 # Wrap | 71 # Wrap private key |
72 ${UTIL_DIR}/vbutil_key \ | 72 ${UTIL_DIR}/vbutil_key \ |
73 --pack ${TESTKEY_SCRATCH_DIR}/key_alg${algorithmcounter}.vbprivk \ | 73 --pack ${TESTKEY_SCRATCH_DIR}/key_alg${algorithmcounter}.vbprivk \ |
74 --key ${TESTKEY_DIR}/key_rsa${signing_keylen}.pem \ | 74 --key ${TESTKEY_DIR}/key_rsa${signing_keylen}.pem \ |
75 --algorithm $signing_algorithmcounter | 75 --algorithm $signing_algorithmcounter |
76 if [ $? -ne 0 ] | 76 if [ $? -ne 0 ] |
77 then | 77 then |
| 78 echo -e "${COL_RED}Wrap vbprivk${COL_STOP}" |
78 return_code=255 | 79 return_code=255 |
79 fi | 80 fi |
80 | 81 |
| 82 # Wrap public key |
| 83 ${UTIL_DIR}/vbutil_key \ |
| 84 --pack ${TESTKEY_SCRATCH_DIR}/key_alg${algorithmcounter}.vbpubk \ |
| 85 --key ${TESTKEY_DIR}/key_rsa${signing_keylen}.keyb \ |
| 86 --algorithm $signing_algorithmcounter |
| 87 if [ $? -ne 0 ] |
| 88 then |
| 89 echo -e "${COL_RED}Wrap vbpubk${COL_STOP}" |
| 90 return_code=255 |
| 91 fi |
| 92 |
81 # Pack | 93 # Pack |
82 ${UTIL_DIR}/vbutil_keyblock --pack ${keyblockfile} \ | 94 ${UTIL_DIR}/vbutil_keyblock --pack ${keyblockfile} \ |
83 --datapubkey \ | 95 --datapubkey \ |
84 ${TESTKEY_SCRATCH_DIR}/key_alg${data_algorithmcounter}.vbpubk \ | 96 ${TESTKEY_SCRATCH_DIR}/key_alg${data_algorithmcounter}.vbpubk \ |
85 --signprivate \ | 97 --signprivate \ |
86 ${TESTKEY_SCRATCH_DIR}/key_alg${algorithmcounter}.vbprivk | 98 ${TESTKEY_SCRATCH_DIR}/key_alg${algorithmcounter}.vbprivk |
87 if [ $? -ne 0 ] | 99 if [ $? -ne 0 ] |
88 then | 100 then |
| 101 echo -e "${COL_RED}Pack${COL_STOP}" |
89 return_code=255 | 102 return_code=255 |
90 fi | 103 fi |
91 | 104 |
92 # Unpack | 105 # Unpack |
93 ${UTIL_DIR}/vbutil_keyblock --unpack ${keyblockfile} \ | 106 ${UTIL_DIR}/vbutil_keyblock --unpack ${keyblockfile} \ |
| 107 --datapubkey \ |
| 108 ${TESTKEY_SCRATCH_DIR}/key_alg${data_algorithmcounter}.vbpubk2 \ |
94 --signpubkey \ | 109 --signpubkey \ |
95 ${TESTKEY_SCRATCH_DIR}/key_alg${signing_algorithmcounter}.vbpubk | 110 ${TESTKEY_SCRATCH_DIR}/key_alg${algorithmcounter}.vbpubk |
96 # TODO: check data key against the packed one? | |
97 if [ $? -ne 0 ] | 111 if [ $? -ne 0 ] |
98 then | 112 then |
| 113 echo -e "${COL_RED}Unpack${COL_STOP}" |
99 return_code=255 | 114 return_code=255 |
100 fi | 115 fi |
101 | 116 |
| 117 # Check |
| 118 if ! cmp -s \ |
| 119 ${TESTKEY_SCRATCH_DIR}/key_alg${data_algorithmcounter}.vbpubk \ |
| 120 ${TESTKEY_SCRATCH_DIR}/key_alg${data_algorithmcounter}.vbpubk2 |
| 121 then |
| 122 echo -e "${COL_RED}Check${COL_STOP}" |
| 123 return_code=255 |
| 124 exit 1 |
| 125 fi |
| 126 |
102 let data_algorithmcounter=data_algorithmcounter+1 | 127 let data_algorithmcounter=data_algorithmcounter+1 |
103 done | 128 done |
104 done | 129 done |
105 let signing_algorithmcounter=signing_algorithmcounter+1 | 130 let signing_algorithmcounter=signing_algorithmcounter+1 |
106 done | 131 done |
107 done | 132 done |
108 } | 133 } |
109 | 134 |
110 | 135 |
111 check_test_keys | 136 check_test_keys |
112 | 137 |
113 echo | 138 echo |
114 echo "Testing vbutil_key..." | 139 echo "Testing vbutil_key..." |
115 test_vbutil_key | 140 test_vbutil_key |
116 | 141 |
117 echo | 142 echo |
118 echo "Testing vbutil_keyblock..." | 143 echo "Testing vbutil_keyblock..." |
119 test_vbutil_keyblock | 144 test_vbutil_keyblock |
120 | 145 |
121 | 146 |
122 exit $return_code | 147 exit $return_code |
123 | 148 |
OLD | NEW |