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

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

Issue 2925011: Add a script for standalone signing of Chrome OS images. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: Created 10 years, 5 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
« no previous file with comments | « firmware/version.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 # Standalone version of cros_resign_image.sh script from
8 # from chromeos/src/scripts/bin/ for use on signing servers.
9
10 # Both the cgpt tool and vbutil_kernel should be in the system path.
11
vb 2010/07/14 19:20:29 this script is oblivious to any of the errors whic
12 # Check arguments
13 if [ $# -ne 4 ] ; then
14 echo "usage: $0 src_bin dst_bin kernel_datakey kernel_keyblock"
15 exit 1
16 fi
17
18 # Make sure the tools we need are available.
19 type -P cgpt &>/dev/null || \
20 { echo "cgpt tool not found."; exit 1; }
21 type -P vbutil_kernel &>/dev/null || \
22 { echo "vbutil_kernel tool not found."; exit 1; }
23
24 sector_size=512 # sector size in bytes
25 num_sectors_vb=128 # number of sectors in kernel verification blob
26 src_bin=$1
27 dst_bin=$2
28 datakey=$3
29 keyblock=$4
30
31 koffset="$(cgpt show -b -i 2 $1)"
32 ksize="$(cgpt show -s -i 2 $1)"
33
34 echo "Re-signing image ${src_bin} and outputting ${dst_bin}"
35 temp_kimage=$(mktemp)
36 trap "rm -f ${temp_kimage}" EXIT
37 temp_out_vb=$(mktemp)
38 trap "rm -f ${temp_out_vb}" EXIT
39
40 # Grab the kernel image in preparation for resigning
41 dd if="${src_bin}" of="${temp_kimage}" skip=$koffset bs=$sector_size \
42 count=$ksize
43 vbutil_kernel \
44 --repack "${temp_out_vb}" \
45 --vblockonly \
46 --keyblock "${kernel_keyblock}" \
47 --signprivate "${kernel_datakey}" \
48 --oldblob "${temp_kimage}"
49
50 # Create a copy of the input image and put in the new vblock
51 cp "${src_bin}" "${dst_bin}"
52 dd if="${temp_out_vb}" of="${dst_bin}" seek=$koffset bs=$sector_size \
53 count=$num_sectors_vb conv=notrunc
54
55 echo "New signed image was output to ${dst_bin}"
56
57 # Clean up temporary files
58 rm -f ${temp_kimage}
vb 2010/07/14 19:20:29 aren't these taken care of by the traps in lines 3
59 rm -f ${temp_out_vb}
OLDNEW
« no previous file with comments | « firmware/version.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698