aboutsummaryrefslogtreecommitdiff
path: root/lib/_ak_gpg
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-03-27 04:27:43 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-03-27 04:27:43 +0200
commit63fc31c7917aa4dbcf4dcea34ef8352056a1da95 (patch)
treed0992496c0a37c49336a2a49b28c3537c7f01b3f /lib/_ak_gpg
parentf55ca4b700791905eb1c132092fdfcacda98615a (diff)
downloadarching-kaos-tools-63fc31c7917aa4dbcf4dcea34ef8352056a1da95.tar.gz
arching-kaos-tools-63fc31c7917aa4dbcf4dcea34ef8352056a1da95.tar.bz2
arching-kaos-tools-63fc31c7917aa4dbcf4dcea34ef8352056a1da95.zip
_ak_gpg library. forgot to added @ 28717ad
Diffstat (limited to 'lib/_ak_gpg')
-rwxr-xr-xlib/_ak_gpg118
1 files changed, 118 insertions, 0 deletions
diff --git a/lib/_ak_gpg b/lib/_ak_gpg
new file mode 100755
index 0000000..b497da8
--- /dev/null
+++ b/lib/_ak_gpg
@@ -0,0 +1,118 @@
+#!/bin/bash
+source $AK_LIBDIR/_ak_logit
+
+_ak_gpg(){
+ gpg2 --homedir $AK_GPGHOME $*
+}
+
+_ak_gpg_key_import_from_file(){
+ if [ -z $1 ]
+ then
+ logit "[ERROR]" "No argument given"
+ exit 1
+ fi
+ if [ ! -n "$1" ]
+ then
+ logit "[ERROR]" "Empty argument given"
+ exit 1
+ fi
+ if [ ! -f "$1" ]
+ then
+ logit "[ERROR]" "File not found"
+ exit 1
+ fi
+ _ak_gpg --import $1 > /dev/null 2>&1
+}
+
+_ak_gpg_key_self_get_fingerprint_from_config(){
+ ak-config show | jq -r '.gpg'
+}
+
+_ak_gpg_key_self_get_fingerprint(){
+ if [ -z $1 ]
+ then
+ ak-ipfs-cat "$(_ak_gpg_key_self_get_fingerprint_from_config)" | \
+ _ak_gpg --show-keys 2>&1 | \
+ head -n 2 | \
+ tail -n 1 | \
+ sed 's/ //g'
+ else
+ exit 1
+ fi
+}
+
+_ak_gpg_key_get_fingerprint_from_ipfs(){
+ if [ -n "$1" ]
+ then
+ ak-ipfs-cat "$1" | \
+ _ak_gpg --show-keys 2>&1 | \
+ head -n 2 | \
+ tail -n 1 | \
+ sed 's/ //g'
+ else
+ exit 1
+ fi
+}
+
+_ak_gpg_sign_detached(){
+ if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ]
+ then
+ _ak_gpg --detach-sign --sign-with $AK_FINGERPRINT --armor --output $1 $2
+ else
+ exit 1
+ fi
+}
+
+_ak_gpg_encrypt_sign(){
+ if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ] && [ ! -z $3 ] && [ -n "$3" ]
+ then
+ _ak_gpg --sign-with $AK_FINGERPRINT --encypt -r $3 --armor --output $1 $2
+ else
+ exit 1
+ fi
+}
+
+_ak_gpg_encrypt_sign_for_self(){
+ if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ]
+ then
+ _ak_gpg --sign-with $AK_FINGERPRINT --encypt -r $AK_FINGERPRINT --armor --output $1 $2
+ else
+ exit 1
+ fi
+}
+
+_ak_gpg_encrypt(){
+ if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ] && [ ! -z $3 ] && [ -n "$3" ]
+ then
+ _ak_gpg --encypt -r $3 --armor --output $1 $2
+ else
+ exit 1
+ fi
+}
+
+_ak_gpg_encrypt_for_self(){
+ if [ ! -z $1 ] && [ -n "$1" ] && [ ! -z $2 ] && [ -n "$2" ]
+ then
+ _ak_gpg --encypt -r $AK_FINGERPRINT --armor --output $1 $2
+ else
+ exit 1
+ fi
+}
+
+_ak_gpg_verify_signature(){
+ if [ ! -z $1 ] && [ -n "$1" ] && [ -f "$1" ] && [ ! -z $2 ] && [ -n "$2" ] && [ -f "$2" ]
+ then
+ _ak_gpg --verify $1 $2 > /dev/null 2>&1
+ else
+ exit 1
+ fi
+}
+
+_ak_gpg_key_self_export(){
+ if [ ! -z $1 ] && [ -n "$1" ]
+ then
+ _ak_gpg --armour --output $1 --export $AK_FINGERPRINT
+ else
+ exit 1
+ fi
+}