aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2025-07-21 21:39:09 +0300
committerkaotisk <kaotisk@arching-kaos.org>2025-07-21 21:39:09 +0300
commit1e56a83b7b06f443a83516ff4c8354a721ca97ba (patch)
tree6bbae89f84ca35dcd175e766255270b70db471c8
parentb316d58489b2004c629b9262865d25144ad0641a (diff)
downloadarching-kaos-tools-1e56a83b7b06f443a83516ff4c8354a721ca97ba.tar.gz
arching-kaos-tools-1e56a83b7b06f443a83516ff4c8354a721ca97ba.tar.bz2
arching-kaos-tools-1e56a83b7b06f443a83516ff4c8354a721ca97ba.zip
[gpg] Now can export public keys
-rwxr-xr-xbin/ak-gpg4
-rwxr-xr-xlib/_ak_gpg25
2 files changed, 28 insertions, 1 deletions
diff --git a/bin/ak-gpg b/bin/ak-gpg
index 3acfc0b..fb1e86d 100755
--- a/bin/ak-gpg
+++ b/bin/ak-gpg
@@ -26,6 +26,8 @@
## --get-key-self-as-ipfs Returns your key as an IPFS hash
## --get-key-self-as-fingerprint Returns the fingerprint of your key
## --get-key-fingerprint-from-ipfs Returns the fingerprint of a given key
+## --export-key <fingerprint> <out> Exports a public key as <out> filename
+## --export-selected-key Selects a key to export
## --export-key-self-to-file Exports self public key as 'self.pub'
## --clear-sign <file> <output> Sign a file clearly
## --verify-file <file> Verify a clear signed file
@@ -67,6 +69,8 @@ if [ ! -z $1 ]; then
--get-key-self-as-fingerprint) _ak_gpg_key_self_get_fingerprint; exit;;
--get-key-fingerprint-from-ipfs) shift; _ak_gpg_key_get_fingerprint_from_ipfs $1; exit;;
--export-key-self-to-file) _ak_gpg_key_self_export 'self.pub'; exit;;
+ --export-selected-key) _ak_gpg_select_key_to_export; exit;;
+ --export-key) _ak_gpg_key_export "$2" "$3"; exit;;
--clear-sign) shift; _ak_gpg_sign_clear "$2" "$1"; exit;;
--verify-file) shift; _ak_gpg_verify_clear_signature "$1"; exit;;
--list-keys | -l) _ak_gpg_list_keys; exit;;
diff --git a/lib/_ak_gpg b/lib/_ak_gpg
index 7832ca1..8f014f8 100755
--- a/lib/_ak_gpg
+++ b/lib/_ak_gpg
@@ -206,10 +206,19 @@ function _ak_gpg_verify_signature(){
fi
}
+function _ak_gpg_key_export(){
+ if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ]
+ then
+ _ak_gpg --armour --output $2 --export $1
+ else
+ exit 1
+ fi
+}
+
function _ak_gpg_key_self_export(){
if [ ! -z $1 ] && [ -n "$1" ]
then
- _ak_gpg --armour --output $1 --export $AK_FINGERPRINT
+ _ak_gpg_key_export $AK_FINGERPRINT $1
else
exit 1
fi
@@ -253,6 +262,20 @@ function _ak_gpg_list_secret_keys_long(){
uniq
}
+function _ak_gpg_select_key_to_export(){
+ select x in $(_ak_gpg_list_secret_keys | tr '\n' ' ')
+ do
+ if [ -n "$x" ]
+ then
+ _ak_log_info "$x was selected"
+ _ak_gpg_key_export "$x" "$x.asc"
+ break
+ else
+ _ak_log_warning "You didn't select a key"
+ fi
+ done
+}
+
function _ak_gpg_select_key(){
select x in $(_ak_gpg_list_secret_keys | tr '\n' ' ')
do