Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: scripts/image_signing/resign_image.sh

Issue 3083025: Make signing script re-sign Firmware AU payload, and update rootfs hash. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: review fixes Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 # Standalone version of cros_resign_image.sh script from 7 # Standalone version of cros_resign_image.sh script from
8 # chromeos/src/scripts/bin/ for use on signing servers. 8 # chromeos/src/scripts/bin/ for use on signing servers.
9 9
10 # Both the cgpt tool and vbutil_kernel should be in the system path. 10 # Both the cgpt tool and vbutil_kernel should be in the system path.
11 11
12 # Load common constants and variables.
13 . "$(dirname "$0")/common.sh"
14
12 # Abort on error 15 # Abort on error
13 set -e 16 set -e
14 17
15 # Check arguments 18 # Check arguments
16 if [ $# -ne 4 ] ; then 19 if [ $# -ne 4 ] ; then
17 echo "usage: $0 src_bin dst_bin kernel_datakey kernel_keyblock" 20 echo "usage: $0 src_bin dst_bin kernel_datakey kernel_keyblock"
18 exit 1 21 exit 1
19 fi 22 fi
20 23
21 # Make sure the tools we need are available. 24 # Make sure the tools we need are available.
22 type -P cgpt &>/dev/null || \ 25 type -P cgpt &>/dev/null || \
23 { echo "cgpt tool not found."; exit 1; } 26 { echo "cgpt tool not found."; exit 1; }
24 type -P vbutil_kernel &>/dev/null || \ 27 type -P vbutil_kernel &>/dev/null || \
25 { echo "vbutil_kernel tool not found."; exit 1; } 28 { echo "vbutil_kernel tool not found."; exit 1; }
26 29
27 sector_size=512 # sector size in bytes 30 sector_size=512 # sector size in bytes
28 num_sectors_vb=128 # number of sectors in kernel verification blob 31 num_sectors_vb=128 # number of sectors in kernel verification blob
29 src_bin=$1 32 src_bin=$1
30 dst_bin=$2 33 dst_bin=$2
31 kernel_datakey=$3 34 kernel_datakey=$3
32 kernel_keyblock=$4 35 kernel_keyblock=$4
33 36
34 koffset="$(cgpt show -b -i 2 $1)" 37 koffset="$(cgpt show -b -i 2 $1)"
35 ksize="$(cgpt show -s -i 2 $1)" 38 ksize="$(cgpt show -s -i 2 $1)"
36 39
37 echo "Re-signing image ${src_bin} and outputting ${dst_bin}" 40 echo "Re-signing image ${src_bin} and outputting ${dst_bin}"
38 temp_kimage=$(mktemp) 41 temp_kimage=$(make_temp_file)
39 trap "rm -f ${temp_kimage}" EXIT 42 temp_out_vb=$(make_temp_file)
40 temp_out_vb=$(mktemp)
41 trap "rm -f ${temp_out_vb}" EXIT
42 43
43 # Grab the kernel image in preparation for resigning 44 # Grab the kernel image in preparation for resigning
44 dd if="${src_bin}" of="${temp_kimage}" skip=$koffset bs=$sector_size \ 45 dd if="${src_bin}" of="${temp_kimage}" skip=$koffset bs=$sector_size \
45 count=$ksize 46 count=$ksize
46 vbutil_kernel \ 47 vbutil_kernel \
47 --repack "${temp_out_vb}" \ 48 --repack "${temp_out_vb}" \
48 --vblockonly \ 49 --vblockonly \
49 --keyblock "${kernel_keyblock}" \ 50 --keyblock "${kernel_keyblock}" \
50 --signprivate "${kernel_datakey}" \ 51 --signprivate "${kernel_datakey}" \
51 --oldblob "${temp_kimage}" 52 --oldblob "${temp_kimage}"
52 53
53 # Create a copy of the input image and put in the new vblock 54 # Create a copy of the input image and put in the new vblock
54 cp "${src_bin}" "${dst_bin}" 55 cp "${src_bin}" "${dst_bin}"
55 dd if="${temp_out_vb}" of="${dst_bin}" seek=$koffset bs=$sector_size \ 56 dd if="${temp_out_vb}" of="${dst_bin}" seek=$koffset bs=$sector_size \
56 count=$num_sectors_vb conv=notrunc 57 count=$num_sectors_vb conv=notrunc
57 58
58 echo "New signed image was output to ${dst_bin}" 59 echo "New signed image was output to ${dst_bin}"
59 60
OLDNEW
« no previous file with comments | « scripts/image_signing/resign_firmwarefd.sh ('k') | scripts/image_signing/sign_official_build.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698