mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-10 18:05:23 +00:00
BUG=b:35587169 TEST=None BRANCH=None Change-Id: I2098f39dd17893c5e30ed495eaa87935efbcb0ee Reviewed-on: https://chromium-review.googlesource.com/526613 Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Marco Chen <marcochen@chromium.org>
67 lines
1.1 KiB
Bash
Executable File
67 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Copyright 2017 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} DIR
|
|
|
|
DIR: To generate a keypair from an RSA 3072 key (.pem file) for Hammer at DIR
|
|
|
|
EOF
|
|
|
|
if [[ $# -ne 0 ]]; then
|
|
die "$*"
|
|
else
|
|
exit 0
|
|
fi
|
|
}
|
|
|
|
# Generate a keypair at the given directory.
|
|
generate_key() {
|
|
local dir=$1
|
|
|
|
# Generate RSA key.
|
|
openssl genrsa -3 -out "${dir}/temp.pem" 3072
|
|
|
|
# Create a keypair from an RSA .pem file generated above.
|
|
futility create "${dir}/temp.pem" "${dir}/key_hammer"
|
|
|
|
# Best attempt to securely delete the temp.pem file.
|
|
shred --remove "${dir}/temp.pem"
|
|
}
|
|
|
|
main() {
|
|
set -e
|
|
|
|
local dir
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
-h|--help)
|
|
usage
|
|
;;
|
|
-*)
|
|
usage "Unknown option: $1"
|
|
;;
|
|
*)
|
|
break
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ $# -ne 1 ]]; then
|
|
usage "Missing output directory"
|
|
fi
|
|
dir="$1"
|
|
|
|
generate_key "${dir}"
|
|
}
|
|
|
|
main "$@"
|