blob: 30f30729866a4ecc4b761c6f3232b1f12d529071 [file] [log] [blame]
David Rileyff5960f2015-03-12 16:26:37 -07001#!/bin/sh
2
3usage()
4{
Furquan Shaikhd37d7022015-08-07 12:25:37 -07005 echo usage: $0 futility input.img key.vbpubk key.vbprivk subkey.vbprivk output.keyblock output.img
David Rileyff5960f2015-03-12 16:26:37 -07006}
7
8cleanup()
9{
10 rm -f ${EMPTY}
11}
12
Furquan Shaikhd37d7022015-08-07 12:25:37 -070013if [ "$#" -ne 7 ]; then
David Rileyff5960f2015-03-12 16:26:37 -070014 echo ERROR: invalid number of arguments
15 usage
16 exit 1
17fi
18
19futility=$1
20input=$2
21pubkey=$3
22privkey=$4
Furquan Shaikhd37d7022015-08-07 12:25:37 -070023subkey=$5
24keyblock=$6
25output=$7
David Rileyff5960f2015-03-12 16:26:37 -070026
27EMPTY=$(mktemp /tmp/tmp.XXXXXXXX)
28trap cleanup EXIT
29echo " " > ${EMPTY}
30
31echo signing ${input} with ${privkey} to generate ${output}
Furquan Shaikhd37d7022015-08-07 12:25:37 -070032${futility} vbutil_keyblock --pack ${keyblock} --datapubkey ${pubkey} --signprivate ${subkey} --flags 0x7
David Rileyff5960f2015-03-12 16:26:37 -070033if [ $? -ne 0 ]; then
34 echo ERROR: unable to generate keyblock
35 exit $?
36fi
37
38${futility} vbutil_kernel --pack ${output} --keyblock ${keyblock} --signprivate ${privkey} --version 1 --vmlinuz ${input} --config ${EMPTY} --arch arm --bootloader ${EMPTY} --flags 0x1
39if [ $? -ne 0 ]; then
40 echo ERROR: unable to sign image
41 exit $?
42fi
43