2024-10-11 23:27:07 +03:00
|
|
|
{ ... }:
|
|
|
|
{
|
|
|
|
text = ''
|
|
|
|
# Check smartcard pin.
|
|
|
|
function scunlock() {
|
|
|
|
pkill keyboxd &> /dev/null
|
|
|
|
# pkill gpg-agent &> /dev/null
|
|
|
|
echo verify | gpg --card-edit --no-tty --command-fd=0
|
|
|
|
}
|
|
|
|
|
|
|
|
# Encrypt files to myself.
|
|
|
|
# Usage: encrypt <FILES>
|
|
|
|
function encrypt() {
|
|
|
|
local IFS=$'\n'
|
|
|
|
local targets=(''${@})
|
|
|
|
|
|
|
|
if [[ "''${targets}" = "" ]]; then
|
|
|
|
help encrypt
|
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
process() {
|
|
|
|
gpg --encrypt --armor --recipient hi@voronind.com --output "''${target}.gpg" "''${target}"
|
|
|
|
}
|
|
|
|
|
|
|
|
_iterate_targets process ''${targets[@]}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Decrypt files to myself.
|
|
|
|
# Usage: decrypt [FILES]
|
|
|
|
function decrypt() {
|
|
|
|
local IFS=$'\n'
|
|
|
|
local targets=(''${@})
|
|
|
|
|
|
|
|
[[ "''${targets}" = "" ]] && targets=(*.gpg)
|
|
|
|
|
|
|
|
process() {
|
|
|
|
gpg --decrypt --output "''${target%.gpg}" "''${target}"
|
|
|
|
}
|
|
|
|
|
|
|
|
_iterate_targets process ''${targets[@]}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Sign a file.
|
|
|
|
# Usage: sign <FILES>
|
|
|
|
function sign() {
|
|
|
|
local IFS=$'\n'
|
|
|
|
local targets=(''${@})
|
|
|
|
|
|
|
|
if [[ "''${targets}" = "" ]]; then
|
|
|
|
help sign
|
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
process() {
|
|
|
|
gpg --detach-sig --armor --output "''${target}.sig" "''${target}"
|
|
|
|
}
|
|
|
|
|
|
|
|
_iterate_targets process ''${targets[@]}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Verify a signature. All .sig files by default.
|
|
|
|
# Usage: verify [FILES]
|
|
|
|
function verify() {
|
|
|
|
local IFS=$'\n'
|
|
|
|
local targets=(''${@})
|
|
|
|
|
|
|
|
[[ "''${targets}" = "" ]] && targets=(*.sig)
|
|
|
|
|
|
|
|
process() {
|
|
|
|
gpg --verify "''${target}"
|
|
|
|
}
|
|
|
|
|
|
|
|
_iterate_targets process ''${targets[@]}
|
|
|
|
}
|
2024-10-22 00:24:36 +03:00
|
|
|
|
|
|
|
# Find user keys using keyservers.
|
|
|
|
# Usage: gpg_find <EMAIL>
|
|
|
|
function gpg_find() {
|
|
|
|
local email="''${1}"
|
|
|
|
|
|
|
|
if [[ "''${email}" = "" ]]; then
|
|
|
|
help gpg_find
|
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
gpg --locate-keys "''${email}" \
|
|
|
|
|| gpg --locate-keys --auto-key-locate hkps://keys.openpgp.org "''${email}"
|
|
|
|
}
|
2024-10-22 00:26:52 +03:00
|
|
|
|
|
|
|
# Update keys.
|
|
|
|
function gpg_refresh() {
|
|
|
|
gpg --refresh-keys
|
|
|
|
}
|
2024-10-11 23:27:07 +03:00
|
|
|
'';
|
2024-04-09 16:30:33 +03:00
|
|
|
}
|