David Riley | ff5960f | 2015-03-12 16:26:37 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
David Riley | 0a8ae16 | 2015-11-04 15:44:26 -0800 | [diff] [blame] | 3 | # |
| 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 Riley | ff5960f | 2015-03-12 16:26:37 -0700 | [diff] [blame] | 19 | usage() |
| 20 | { |
Furquan Shaikh | d37d702 | 2015-08-07 12:25:37 -0700 | [diff] [blame] | 21 | echo usage: $0 futility input.img key.vbpubk key.vbprivk subkey.vbprivk output.keyblock output.img |
David Riley | ff5960f | 2015-03-12 16:26:37 -0700 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | cleanup() |
| 25 | { |
| 26 | rm -f ${EMPTY} |
| 27 | } |
| 28 | |
Furquan Shaikh | d37d702 | 2015-08-07 12:25:37 -0700 | [diff] [blame] | 29 | if [ "$#" -ne 7 ]; then |
David Riley | ff5960f | 2015-03-12 16:26:37 -0700 | [diff] [blame] | 30 | echo ERROR: invalid number of arguments |
| 31 | usage |
| 32 | exit 1 |
| 33 | fi |
| 34 | |
| 35 | futility=$1 |
| 36 | input=$2 |
| 37 | pubkey=$3 |
| 38 | privkey=$4 |
Furquan Shaikh | d37d702 | 2015-08-07 12:25:37 -0700 | [diff] [blame] | 39 | subkey=$5 |
| 40 | keyblock=$6 |
| 41 | output=$7 |
David Riley | ff5960f | 2015-03-12 16:26:37 -0700 | [diff] [blame] | 42 | |
| 43 | EMPTY=$(mktemp /tmp/tmp.XXXXXXXX) |
| 44 | trap cleanup EXIT |
| 45 | echo " " > ${EMPTY} |
| 46 | |
| 47 | echo signing ${input} with ${privkey} to generate ${output} |
Furquan Shaikh | d37d702 | 2015-08-07 12:25:37 -0700 | [diff] [blame] | 48 | ${futility} vbutil_keyblock --pack ${keyblock} --datapubkey ${pubkey} --signprivate ${subkey} --flags 0x7 |
David Riley | ff5960f | 2015-03-12 16:26:37 -0700 | [diff] [blame] | 49 | if [ $? -ne 0 ]; then |
| 50 | echo ERROR: unable to generate keyblock |
| 51 | exit $? |
| 52 | fi |
| 53 | |
| 54 | ${futility} vbutil_kernel --pack ${output} --keyblock ${keyblock} --signprivate ${privkey} --version 1 --vmlinuz ${input} --config ${EMPTY} --arch arm --bootloader ${EMPTY} --flags 0x1 |
| 55 | if [ $? -ne 0 ]; then |
| 56 | echo ERROR: unable to sign image |
| 57 | exit $? |
| 58 | fi |
| 59 | |