reuse key list for id/fp

This commit is contained in:
drduh 2025-05-10 17:59:19 -07:00
parent 04dbdf35c3
commit 7473d2e0d8

View file

@ -28,7 +28,7 @@ get_id_label () {
get_key_type () { get_key_type () {
# Returns key type and size. # Returns key type and size.
printf "rsa2048" printf "rsa4096"
} }
get_key_expiration () { get_key_expiration () {
@ -82,14 +82,12 @@ gen_key_certify () {
"$KEY_TYPE" "cert" "never" "$KEY_TYPE" "cert" "never"
} }
set_id_fp () { set_fingerprint () {
# Sets Key ID and Fingerprint environment vars. # Sets Key ID and Fingerprint environment vars.
export KEY_ID=$(gpg -k --with-colons "$IDENTITY" | \ key_list=$(gpg --list-secret-keys --with-colons)
awk -F: '/^pub:/ { print $5; exit }') export KEY_ID=$(printf "$key_list" | awk -F: '/^sec/ { print $5; exit }')
export KEY_FP=$(gpg -k --with-colons "$IDENTITY" | \ export KEY_FP=$(printf "$key_list" | awk -F: '/^fpr/ { print $10; exit }')
awk -F: '/^fpr:/ { print $10; exit }') printf "got identity (fp='%s', id='%s')\n" "$KEY_FP" "$KEY_ID"
printf "got identity (fp='%s', id='%s')\n" \
"$KEY_FP" "$KEY_ID"
} }
gen_key_subs () { gen_key_subs () {
@ -159,7 +157,7 @@ set_pass
gen_key_certify gen_key_certify
# 5. Set resulting identity fingerprint. # 5. Set resulting identity fingerprint.
set_id_fp set_fingerprint
# 6. Generate the Subkeys. # 6. Generate the Subkeys.
gen_key_subs gen_key_subs