increment_kernel_subkey_and_key.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. # Script to increment kernel subkey and datakey for firmware updates.
  6. # Used when revving versions for a firmware update.
  7. # Load common constants and variables.
  8. . "${0%/*}"/common.sh
  9. # Abort on errors.
  10. set -e
  11. if [ $# -ne 1 ]; then
  12. cat <<EOF
  13. Usage: $0 <keyset directory>
  14. Increments the kernel subkey, data key and firmware version in the
  15. specified keyset.
  16. EOF
  17. exit 1
  18. fi
  19. KEY_DIR=$1
  20. main() {
  21. load_current_versions "${KEY_DIR}"
  22. new_kernkey_ver=$(increment_version "${KEY_DIR}" "kernel_key_version")
  23. new_firm_ver=$(increment_version "${KEY_DIR}" "firmware_version")
  24. cd "${KEY_DIR}"
  25. backup_existing_kernel_subkeys ${CURR_FIRM_VER} ${CURR_KERNKEY_VER}
  26. backup_existing_kernel_data_keys ${CURR_FIRM_VER} ${CURR_KERNKEY_VER}
  27. cat <<EOF
  28. Generating new kernel subkey, data keys and new kernel keyblock.
  29. New Firmware version (due to kernel subkey change): ${new_firm_ver}.
  30. New Kernel key version (due to kernel datakey change): ${new_kernkey_ver}.
  31. EOF
  32. make_pair kernel_subkey ${KERNEL_SUBKEY_ALGOID} ${new_firm_ver}
  33. make_pair kernel_data_key ${KERNEL_DATAKEY_ALGOID} ${new_kernkey_ver}
  34. make_keyblock kernel ${KERNEL_KEYBLOCK_MODE} kernel_data_key kernel_subkey
  35. write_updated_version_file ${CURR_FIRMKEY_VER} ${new_firm_ver} \
  36. ${new_kernkey_ver} ${CURR_KERN_VER}
  37. }
  38. main "$@"