diff options
author | Evan Benn <evanbenn@chromium.org> | 2022-01-17 13:57:51 +1100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-01-26 13:54:20 +0000 |
commit | 4d163c53d8ab413a35fe97325ee0c03eec481fe7 (patch) | |
tree | b8cab60bbb5515fb9ebbf4446a42ffe8b03b296f | |
parent | ec240b9688b5240ff9e76baa62b83db3a427ddda (diff) | |
download | vboot-4d163c53d8ab413a35fe97325ee0c03eec481fe7.tar.gz |
accessory: script to generate hps keys
hps uses ed25519 keys so generate a pair of that type.
BUG=b:214495498
TEST=./create_new_hps_key.sh
BRANCH=none
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Change-Id: I3f63ea5852b8e5959b7577e8b988284da043b449
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3394031
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Evan Benn <evanbenn@chromium.org>
Tested-by: Evan Benn <evanbenn@chromium.org>
-rwxr-xr-x | scripts/keygeneration/accessory/create_new_hps_key.sh | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/scripts/keygeneration/accessory/create_new_hps_key.sh b/scripts/keygeneration/accessory/create_new_hps_key.sh new file mode 100755 index 00000000..6d175c80 --- /dev/null +++ b/scripts/keygeneration/accessory/create_new_hps_key.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Copyright 2022 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Load common constants and functions. +. "$(dirname "$0")/../common.sh" + +usage() { + cat <<EOF +Usage: ${PROG} [options] + +Options: + -o, --output_dir <dir>: Where to write the keys (default is cwd) +EOF + + if [[ $# -ne 0 ]]; then + die "$*" + else + exit 0 + fi +} + +generate_ed25519_key() { + local output_dir="$1" + + # Generate ed25519 private and public key. + openssl genpkey -algorithm Ed25519 -out "${output_dir}/key_hps.priv.pem" + openssl pkey -in "${output_dir}/key_hps.priv.pem" -pubout -text_pub \ + -out "${output_dir}/key_hps.pub.pem" +} + +main() { + set -euo pipefail + + local output_dir="${PWD}" + + while [[ $# -gt 0 ]]; do + case "$1" in + -h|--help) + usage + ;; + -o|--output_dir) + output_dir="$2" + if [[ ! -d "${output_dir}" ]]; then + die "output dir (${output_dir}) doesn't exist." + fi + shift + ;; + -*) + usage "Unknown option: $1" + ;; + *) + usage "Unknown argument $1" + ;; + esac + shift + done + + generate_ed25519_key "${output_dir}" +} + +main "$@" |