1#!/bin/bash 2 3# Copyright 2022 The ChromiumOS Authors 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7# Load common constants and functions. 8# shellcheck source=../common.sh 9. "$(dirname "$0")/../common.sh" 10 11usage() { 12 cat <<EOF 13Usage: ${PROG} [options] 14 15Options: 16 -o, --output_dir <dir>: Where to write the keys (default is cwd) 17EOF 18 19 if [[ $# -ne 0 ]]; then 20 die "$*" 21 else 22 exit 0 23 fi 24} 25 26main() { 27 set -euo pipefail 28 29 local output_dir="${PWD}" 30 31 while [[ $# -gt 0 ]]; do 32 case "$1" in 33 -h|--help) 34 usage 35 ;; 36 -o|--output_dir) 37 output_dir="$2" 38 if [[ ! -d "${output_dir}" ]]; then 39 die "output dir (${output_dir}) doesn't exist." 40 fi 41 shift 42 ;; 43 -*) 44 usage "Unknown option: $1" 45 ;; 46 *) 47 usage "Unknown argument $1" 48 ;; 49 esac 50 shift 51 done 52 53 generate_ed25519_key "${output_dir}/key_hps" 54} 55 56main "$@" 57