summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-11-22 13:05:22 -0200
committerSilvio Rhatto <rhatto@riseup.net>2011-11-22 13:05:22 -0200
commitff19dbc8518d5e7f7a6535f7bf651a245de51d35 (patch)
treeb8ec6552c494e01333422033a2b3860ccb3f1710
parent4d5b7821417d853b6a86fc794cc684ecc846ad6a (diff)
downloadkeyringer-ff19dbc8518d5e7f7a6535f7bf651a245de51d35.tar.gz
keyringer-ff19dbc8518d5e7f7a6535f7bf651a245de51d35.tar.bz2
Custom keyid support
-rw-r--r--README8
-rw-r--r--lib/keyringer/functions6
-rwxr-xr-xshare/keyringer/decrypt2
-rwxr-xr-xshare/keyringer/edit4
-rwxr-xr-xshare/keyringer/encrypt2
-rwxr-xr-xshare/keyringer/genpair10
-rwxr-xr-xshare/keyringer/recrypt2
7 files changed, 24 insertions, 10 deletions
diff --git a/README b/README
index 8353610..585550a 100644
--- a/README
+++ b/README
@@ -130,6 +130,14 @@ Configuration files, preferences and options
3. Custom keyring options: $KEYRING_FOLDER/config/options: managed by
"keyringer <keyring> options".
+Using a non-default OpenPGP key
+-------------------------------
+
+If you want to use a different key other than your default for a given
+keyringer, use
+
+ keyringer <keyring> preferences add KEYID=FINGERPRINT
+
Notes
-----
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index 11d1b86..58f7ad1 100644
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -204,6 +204,12 @@ function keyringer_set_env {
exit 1
fi
+ if [ ! -z "$KEYID" ]; then
+ GPG="gpg -u $KEYID"
+ else
+ GPG="gpg"
+ fi
+
# Check recipients file
keyringer_check_recipients $SUBCOMMAND
diff --git a/share/keyringer/decrypt b/share/keyringer/decrypt
index c0584f2..adc1134 100755
--- a/share/keyringer/decrypt
+++ b/share/keyringer/decrypt
@@ -11,4 +11,4 @@ source "$LIB" || exit 1
keyringer_get_file "$2"
# Decrypt
-gpg --quiet --use-agent -d "$KEYDIR/$FILE"
+$GPG --quiet --use-agent -d "$KEYDIR/$FILE"
diff --git a/share/keyringer/edit b/share/keyringer/edit
index 47945f3..73a59d9 100755
--- a/share/keyringer/edit
+++ b/share/keyringer/edit
@@ -17,7 +17,7 @@ echo "Make sure that $BASEDIR is atop of an encrypted volume."
keyringer_set_tmpfile edit
# Decrypt the information to the file
-gpg --yes -o "$TMPWORK" --use-agent -d "$KEYDIR/$FILE"
+$GPG --yes -o "$TMPWORK" --use-agent -d "$KEYDIR/$FILE"
# Prompt
echo "Press any key to open the decrypted data in $EDITOR, Ctrl-C to abort"
@@ -25,7 +25,7 @@ read key
"$EDITOR" "$TMPWORK"
# Encrypt again
-gpg --yes -o "$KEYDIR/$FILE" --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS") "$TMPWORK"
+$GPG --yes -o "$KEYDIR/$FILE" --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS") "$TMPWORK"
# Remove temp file
keyringer_unset_tmpfile "$TMPWORK"
diff --git a/share/keyringer/encrypt b/share/keyringer/encrypt
index 8cbf72a..709aac3 100755
--- a/share/keyringer/encrypt
+++ b/share/keyringer/encrypt
@@ -18,7 +18,7 @@ if [ "$BASENAME" == "encrypt" ]; then
echo "Type your message and finish your input with EOF (Ctrl-D)."
fi
-gpg --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS") - > "$KEYDIR/$FILE"
+$GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS") - > "$KEYDIR/$FILE"
# Stage
if [ -d "$BASEDIR/.git" ]; then
diff --git a/share/keyringer/genpair b/share/keyringer/genpair
index 065111e..a5b06cc 100755
--- a/share/keyringer/genpair
+++ b/share/keyringer/genpair
@@ -52,7 +52,7 @@ function genpair_gpg {
# TODO: insert random bytes
# TODO: custom Name-Comment and Name-Email
# TODO: allow for empty passphrases
- gpg --homedir "$TMPWORK" --gen-key --batch <<EOF
+ $GPG --homedir "$TMPWORK" --gen-key --batch <<EOF
Key-Type: RSA
Key-Length: 4096
Subkey-Type: ELG-E
@@ -66,9 +66,9 @@ EOF
# Encrypt the result
echo "Encrypting secret key into keyringer..."
- gpg --armor --homedir "$TMPWORK" --export-secret-keys | keyringer_exec encrypt "$BASEDIR" "$FILE"
+ $GPG --armor --homedir "$TMPWORK" --export-secret-keys | keyringer_exec encrypt "$BASEDIR" "$FILE"
echo "Encrypting public key into keyringer..."
- gpg --armor --homedir "$TMPWORK" --export | keyringer_exec encrypt "$BASEDIR" "$FILE.pub"
+ $GPG --armor --homedir "$TMPWORK" --export | keyringer_exec encrypt "$BASEDIR" "$FILE.pub"
echo "Encrypting passphrase into keyringer..."
echo "Passphrase for $FILE: $passphrase" | keyringer_exec encrypt "$BASEDIR" "$FILE.passwd"
@@ -76,8 +76,8 @@ EOF
if [ ! -z "$OUTFILE" ]; then
mkdir -p `dirname $OUTFILE`
printf "Saving copies at %s and %s.pub\n" "$OUTFILE" "$OUTFILE"
- gpg --armor --homedir "$TMPWORK" --export-secret-keys > "$OUTFILE"
- gpg --armor --homedir "$TMPWORK" --export > "$OUTFILE.pub"
+ $GPG --armor --homedir "$TMPWORK" --export-secret-keys > "$OUTFILE"
+ $GPG --armor --homedir "$TMPWORK" --export > "$OUTFILE.pub"
fi
echo "Done"
diff --git a/share/keyringer/recrypt b/share/keyringer/recrypt
index dac703a..a8f5267 100755
--- a/share/keyringer/recrypt
+++ b/share/keyringer/recrypt
@@ -12,7 +12,7 @@ function keyringer_recrypt {
keyringer_get_file "$1"
# Recrypt
- gpg --use-agent -d "$KEYDIR/$FILE" | gpg --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS") > "$KEYDIR/$FILE"
+ $GPG --use-agent -d "$KEYDIR/$FILE" | $GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS") > "$KEYDIR/$FILE"
}
if [ ! -z "$2" ]; then