### -*-sh-*- ### ### Key type for GNU Privacy Guard ### ### (c) 2011 Mark Wooding ### ###----- Licensing notice --------------------------------------------------- ### ### This file is part of the distorted.org.uk key management suite. ### ### distorted-keys is free software; you can redistribute it and/or modify ### it under the terms of the GNU General Public License as published by ### the Free Software Foundation; either version 2 of the License, or ### (at your option) any later version. ### ### distorted-keys is distributed in the hope that it will be useful, ### but WITHOUT ANY WARRANTY; without even the implied warranty of ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ### GNU General Public License for more details. ### ### You should have received a copy of the GNU General Public License ### along with distorted-keys; if not, write to the Free Software Foundation, ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. run_gnupg () { base=$1; shift ## Run GnuPG with some standard options. gpg --homedir="$base" --no-permission-warning -q --batch \ --always-trust \ "$@" } defprops k_props <"$nub" prefs="$kprop_cipher_prefs $kprop_digest_prefs $kprop_compress_prefs" case ${kprop_s2k_cipher+t} in t) ;; *) set -- $kprop_cipher_prefs; kprop_s2k_cipher=$1 ;; esac case ${kprop_s2k_digest+t} in t) ;; *) set -- $kprop_digest_prefs; kprop_s2k_digest=$1 ;; esac cat >"$base/gpg.conf" <"$base/fpr" run_gnupg "$base" --export --armor --output="$base/pub" } k_encrypt () { base=$1 run_gnupg "$base" --encrypt --armor --recipient=$(cat "$base/fpr") } k_decrypt () { base=$1 nub=$2 run_gnupg "$base" --passphrase-file "$nub" --decrypt } k_sign () { base=$1 nub=$2 run_gnupg "$base" --passphrase-file "$nub" --detach-sign --armor } k_verify () { base=$1 sig=$3 echo "$sig" >$tmp/sig if run_gnupg "$base" --verify $tmp/sig - >/dev/null 2>$tmp/err then :; else rc=$? cat >&2 $tmp/err return $rc fi } ###----- That's all, folks --------------------------------------------------