blob: cfffe685a0ba89e4f51f145c89555d2e3eff30dd [file] [log] [blame]
David Rileyff5960f2015-03-12 16:26:37 -07001#!/bin/sh
2
David Riley0a8ae162015-11-04 15:44:26 -08003#
4# Copyright (C) 2015 The Android Open-Source Project
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
David Rileyff5960f2015-03-12 16:26:37 -070019usage()
20{
Furquan Shaikhd37d7022015-08-07 12:25:37 -070021 echo usage: $0 futility input.img key.vbpubk key.vbprivk subkey.vbprivk output.keyblock output.img
David Rileyff5960f2015-03-12 16:26:37 -070022}
23
24cleanup()
25{
26 rm -f ${EMPTY}
27}
28
Furquan Shaikhd37d7022015-08-07 12:25:37 -070029if [ "$#" -ne 7 ]; then
David Rileyff5960f2015-03-12 16:26:37 -070030 echo ERROR: invalid number of arguments
31 usage
32 exit 1
33fi
34
35futility=$1
36input=$2
37pubkey=$3
38privkey=$4
Furquan Shaikhd37d7022015-08-07 12:25:37 -070039subkey=$5
40keyblock=$6
41output=$7
David Rileyff5960f2015-03-12 16:26:37 -070042
43EMPTY=$(mktemp /tmp/tmp.XXXXXXXX)
44trap cleanup EXIT
45echo " " > ${EMPTY}
46
47echo signing ${input} with ${privkey} to generate ${output}
Furquan Shaikhd37d7022015-08-07 12:25:37 -070048${futility} vbutil_keyblock --pack ${keyblock} --datapubkey ${pubkey} --signprivate ${subkey} --flags 0x7
David Rileyff5960f2015-03-12 16:26:37 -070049if [ $? -ne 0 ]; then
50 echo ERROR: unable to generate keyblock
51 exit $?
52fi
53
54${futility} vbutil_kernel --pack ${output} --keyblock ${keyblock} --signprivate ${privkey} --version 1 --vmlinuz ${input} --config ${EMPTY} --arch arm --bootloader ${EMPTY} --flags 0x1
55if [ $? -ne 0 ]; then
56 echo ERROR: unable to sign image
57 exit $?
58fi
59