xref: /aosp_15_r20/external/vboot_reference/scripts/keygeneration/make_arv_root.sh (revision 8617a60d3594060b7ecbd21bc622a7c14f3cf2bc)
1#!/bin/bash
2# Copyright 2022 The ChromiumOS Authors
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5#
6# Create AP RO verification Root key pair for PreMp signing.
7
8# Load common constants and functions.
9# shellcheck source=common.sh
10. "$(dirname "$0")/common.sh"
11
12usage() {
13  cat <<EOF
14Usage: $0 [destination directory]
15
16Output: arv_root.vbprivk and arv_root.vbpubk created in [destination dirctory]
17        which by default is "./${ARV_ROOT_DIR}"
18EOF
19  exit 1
20}
21
22main() {
23  local key_dir
24
25  case $# in
26    (0) # Use default directory.
27      key_dir="${ARV_ROOT_DIR}"
28      ;;
29    (1)
30      key_dir="$1"
31      ;;
32    (*)
33      usage
34  esac
35
36  if [[ -d ${key_dir} ]]; then
37    die "Destination directory \"${key_dir}\" exists. There can be only one!"
38  fi
39
40  mkdir -p "${key_dir}" || die "Failed to create \"${key_dir}\"."
41
42  cd "${key_dir}" || die "Failed to cd to \"${key_dir}\"."
43
44  make_pair "${ARV_ROOT_NAME_BASE}" "${ARV_ROOT_ALGOID}"
45}
46
47main "$@"
48