OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
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 # Script to resign a firmware image using a different set of keys | 7 # Script to resign a firmware image using a different set of keys |
8 # for use on signing servers. | 8 # for use on signing servers. |
9 # | 9 # |
10 # arguments: src_fd, dst_fd, firmware_datakey, and firmware_keyblock | 10 # arguments: src_fd, dst_fd, firmware_datakey, and firmware_keyblock |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 VERSION=$6 | 74 VERSION=$6 |
75 | 75 |
76 if [ -z $VERSION ]; then | 76 if [ -z $VERSION ]; then |
77 VERSION=1 | 77 VERSION=1 |
78 fi | 78 fi |
79 echo "Using firmware version: $VERSION" | 79 echo "Using firmware version: $VERSION" |
80 | 80 |
81 # Parse offsets and size of firmware data and vblocks | 81 # Parse offsets and size of firmware data and vblocks |
82 for i in "A" "B" | 82 for i in "A" "B" |
83 do | 83 do |
84 match_str="$i Key" | 84 line=$(mosys -f -k eeprom map $1 | grep "$i Key") || |
85 line=$(mosys -f -k eeprom map $1 | grep "$match_str") | 85 line=$(mosys -f -k eeprom map $1 | grep "VBLOCK_$i") || |
| 86 { echo "Couldn't parse vblock section $i from mosys output"; |
| 87 exit 1; } |
| 88 |
86 offset="$(echo $line | sed -e 's/.*area_offset=\"\([a-f0-9x]*\)\".*/\1/')" | 89 offset="$(echo $line | sed -e 's/.*area_offset=\"\([a-f0-9x]*\)\".*/\1/')" |
87 eval fw${i}_vblock_offset=$((offset)) | 90 eval fw${i}_vblock_offset=$((offset)) |
88 size="$(echo $line | sed -e 's/.*area_size=\"\([a-f0-9x]*\)\".*/\1/')" | 91 size="$(echo $line | sed -e 's/.*area_size=\"\([a-f0-9x]*\)\".*/\1/')" |
89 eval fw${i}_vblock_size=$((size)) | 92 eval fw${i}_vblock_size=$((size)) |
90 | 93 |
91 match_str="$i Data" | 94 line=$(mosys -f -k eeprom map $1 | grep "$i Data") || |
92 line=$(mosys -f -k eeprom map $1 | grep "$match_str") | 95 line=$(mosys -f -k eeprom map $1 | grep "FW_MAIN_$i") || |
| 96 { echo "Couldn't parse Firmware $i section from mosys output"; |
| 97 exit 1; } |
| 98 |
93 offset="$(echo $line | sed -e 's/.*area_offset=\"\([a-f0-9x]*\)\".*/\1/')" | 99 offset="$(echo $line | sed -e 's/.*area_offset=\"\([a-f0-9x]*\)\".*/\1/')" |
94 eval fw${i}_offset=$((offset)) | 100 eval fw${i}_offset=$((offset)) |
95 size="$(echo $line | sed -e 's/.*area_size=\"\([a-f0-9x]*\)\".*/\1/')" | 101 size="$(echo $line | sed -e 's/.*area_size=\"\([a-f0-9x]*\)\".*/\1/')" |
96 eval fw${i}_size=$((size)) | 102 eval fw${i}_size=$((size)) |
97 done | 103 done |
98 | 104 |
99 temp_fwimage=$(make_temp_file) | 105 temp_fwimage=$(make_temp_file) |
100 temp_out_vb=$(make_temp_file) | 106 temp_out_vb=$(make_temp_file) |
101 | 107 |
102 # Extract out Firmware A data and generate signature using the right keys | 108 # Extract out Firmware A data and generate signature using the right keys |
(...skipping 24 matching lines...) Expand all Loading... |
127 --signprivate "${FIRMWARE_DATAKEY}" \ | 133 --signprivate "${FIRMWARE_DATAKEY}" \ |
128 --version "${VERSION}" \ | 134 --version "${VERSION}" \ |
129 --fv "${temp_fwimage}" \ | 135 --fv "${temp_fwimage}" \ |
130 --kernelkey "${KERNEL_SUBKEY}" | 136 --kernelkey "${KERNEL_SUBKEY}" |
131 | 137 |
132 # Destination image has already been created. | 138 # Destination image has already been created. |
133 dd if="${temp_out_vb}" of="${DST_FD}" seek="${fwB_vblock_offset}" bs=1 \ | 139 dd if="${temp_out_vb}" of="${DST_FD}" seek="${fwB_vblock_offset}" bs=1 \ |
134 count="${fwB_vblock_size}" conv=notrunc | 140 count="${fwB_vblock_size}" conv=notrunc |
135 | 141 |
136 echo "New signed image was output to ${DST_FD}" | 142 echo "New signed image was output to ${DST_FD}" |
OLD | NEW |