1 #!/bin/sh 2 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 19 usage() 20 { 21 echo usage: $0 futility input.img key.vbpubk key.vbprivk subkey.vbprivk output.keyblock output.img 22 } 23 24 cleanup() 25 { 26 rm -f ${EMPTY} 27 } 28 29 if [ "$#" -ne 7 ]; then 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 39 subkey=$5 40 keyblock=$6 41 output=$7 42 43 EMPTY=$(mktemp /tmp/tmp.XXXXXXXX) 44 trap cleanup EXIT 45 echo " " > ${EMPTY} 46 47 echo signing ${input} with ${privkey} to generate ${output} 48 ${futility} vbutil_keyblock --pack ${keyblock} --datapubkey ${pubkey} --signprivate ${subkey} --flags 0x7 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 60