1 #!/bin/bash 2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 3 # Use of this source code is governed by a BSD-style license that can be 4 # found in the LICENSE file. 5 6 # Script to increment kernel subkey and datakey for firmware updates. 7 # Used when revving versions for a firmware update. 8 9 # Load common constants and variables. 10 . "${0%/*}"/common.sh 11 12 # Abort on errors. 13 set -e 14 15 if [ $# -ne 1 ]; then 16 cat <<EOF 17 Usage: $0 <keyset directory> 18 19 Increments the kernel subkey, data key and firmware version in the 20 specified keyset. 21 EOF 22 exit 1 23 fi 24 25 KEY_DIR=$1 26 27 main() { 28 load_current_versions "${KEY_DIR}" 29 new_kernkey_ver=$(increment_version "${KEY_DIR}" "kernel_key_version") 30 new_firm_ver=$(increment_version "${KEY_DIR}" "firmware_version") 31 32 cd "${KEY_DIR}" 33 backup_existing_kernel_subkeys ${CURR_FIRM_VER} ${CURR_KERNKEY_VER} 34 backup_existing_kernel_data_keys ${CURR_FIRM_VER} ${CURR_KERNKEY_VER} 35 36 cat <<EOF 37 Generating new kernel subkey, data keys and new kernel keyblock. 38 39 New Firmware version (due to kernel subkey change): ${new_firm_ver}. 40 New Kernel key version (due to kernel datakey change): ${new_kernkey_ver}. 41 EOF 42 make_pair kernel_subkey ${KERNEL_SUBKEY_ALGOID} ${new_firm_ver} 43 make_pair kernel_data_key ${KERNEL_DATAKEY_ALGOID} ${new_kernkey_ver} 44 make_keyblock kernel ${KERNEL_KEYBLOCK_MODE} kernel_data_key kernel_subkey 45 46 write_updated_version_file ${CURR_FIRMKEY_VER} ${new_firm_ver} \ 47 ${new_kernkey_ver} ${CURR_KERN_VER} 48 } 49 50 main "$@" 51