# kill these files when making new export distributions
NONEXPORT=pgp.c pgp.h pgpinvoke.c pgpkey.c pgppubring.c sha.h sha1dgst.c \
- sha_locl.h OPS.PGP doc/pgp-Notes.txt doc/language.txt \
+ gnupgparse.c sha_locl.h OPS.PGP doc/pgp-Notes.txt doc/language.txt \
doc/language50.txt
all: mutt
/* Where is PGP 5 located on your system? */
#undef _PGPV3PATH
+/* Where is GNU Privacy Guard located on your system? */
+#undef _PGPGPGPATH
+
/* Do we have PGP 2.*? */
#undef HAVE_PGP2
/* Do we have PGP 5.0 or up? */
#undef HAVE_PGP5
+/* Do we have GPG? */
+#undef HAVE_GPG
+
/* Where to find ispell on your system? */
#undef ISPELL
char *micalg = NULL;
char input_signas[SHORT_STRING];
char input_micalg[SHORT_STRING];
+ KEYINFO *secring;
+
+ struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_SIGN);
mvaddstr (LINES-1, 0, "(e)ncrypt, (s)ign, sign (a)s, (b)oth, select (m)ic algorithm, or (f)orget it? ");
clrtoeol ();
if (c == 'a')
{
unset_option(OPTPGPCHECKTRUST);
- if ((p = pgp_ask_for_key (pgp_secring(PGP_SIGN),
- NULL, "Sign as: ", NULL, KEYFLAG_CANSIGN, &micalg)))
+
+ if(pgp)
{
- snprintf (input_signas, sizeof (input_signas), "0x%s", p);
- safe_free((void **) &PgpSignAs);
- PgpSignAs = safe_strdup(input_signas);
- safe_free((void **) &PgpSignMicalg);
- PgpSignMicalg = micalg; /* micalg is malloc()ed by pgp_ask_for_key */
- pgp_void_passphrase (); /* probably need a different passphrase */
- safe_free ((void **) &p);
- bits |= PGPSIGN;
+ if(!(secring = pgp->read_secring(pgp)))
+ {
+ mutt_error("Can't open your secret key ring!");
+ bits &= ~PGPSIGN;
+ }
+ else
+ {
+ if ((p = pgp_ask_for_key (pgp, secring, "Sign as: ",
+ NULL, KEYFLAG_CANSIGN, &micalg)))
+ {
+ snprintf (input_signas, sizeof (input_signas), "0x%s", p);
+ safe_free((void **) &PgpSignAs);
+ PgpSignAs = safe_strdup(input_signas);
+ safe_free((void **) &PgpSignMicalg);
+ PgpSignMicalg = micalg; /* micalg is malloc()ed by pgp_ask_for_key */
+ pgp_void_passphrase (); /* probably need a different passphrase */
+ safe_free ((void **) &p);
+ bits |= PGPSIGN;
+ }
+
+ pgp_close_keydb(&secring);
+ }
+ }
+ else
+ {
+ bits &= ~PGPSIGN;
+ mutt_error("An unkown PGP version was defined for signing.");
}
}
else if (c == 'm')
{
mutt_error("Unknown MIC algorithm, valid ones are: pgp-md5, pgp-sha1, pgp-rmd160");
}
- else {
+ else
+ {
safe_free((void **) &PgpSignMicalg);
PgpSignMicalg = safe_strdup(input_micalg);
}
-
-
-
-
static void draw_envelope (HEADER *msg, char *fcc)
{
char buf[STRING];
/* Where is PGP 5 located on your system? */
#undef _PGPV3PATH
+/* Where is GNU Privacy Guard located on your system? */
+#undef _PGPGPGPATH
+
/* Do we have PGP 2.*? */
#undef HAVE_PGP2
/* Do we have PGP 5.0 or up? */
#undef HAVE_PGP5
+/* Do we have GPG? */
+#undef HAVE_GPG
+
/* Where to find ispell on your system? */
#undef ISPELL
if test -f $srcdir/pgp.c; then
SUBVERSION=i
PGPPATH=no
+
+ # Extract the first word of "gpg", so it can be a program name with args.
+set dummy gpg; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:893: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_GPG'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ case "$GPG" in
+ /*)
+ ac_cv_path_GPG="$GPG" # Let the user override the test with a path.
+ ;;
+ *)
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_path_GPG="$ac_dir/$ac_word"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+ test -z "$ac_cv_path_GPG" && ac_cv_path_GPG="no"
+ ;;
+esac
+fi
+GPG="$ac_cv_path_GPG"
+if test -n "$GPG"; then
+ echo "$ac_t""$GPG" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ if test $GPG != no ; then
+ cat >> confdefs.h <<EOF
+#define _PGPGPGPATH "$GPG"
+EOF
+
+ PGPPATH="$GPG"
+ cat >> confdefs.h <<\EOF
+#define HAVE_GPG 1
+EOF
+
+ fi
+
# Extract the first word of "pgpk", so it can be a program name with args.
set dummy pgpk; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:892: checking for $ac_word" >&5
+echo "configure:937: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_PGPK'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# Extract the first word of "pgp", so it can be a program name with args.
set dummy pgp; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:937: checking for $ac_word" >&5
+echo "configure:982: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_PGP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fi
if test $PGP != no || test $PGPK != no ; then
- LIBOBJS="$LIBOBJS pgp.o pgpinvoke.o pgpkey.o pgppubring.o sha1dgst.o"
+ LIBOBJS="$LIBOBJS pgp.o pgpinvoke.o pgpkey.o pgppubring.o sha1dgst.o gnupgparse.o"
OPS="$OPS \$(srcdir)/OPS.PGP"
fi
fi
# Extract the first word of "ispell", so it can be a program name with args.
set dummy ispell; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1001: checking for $ac_word" >&5
+echo "configure:1046: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_ISPELL'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1038: checking how to run the C preprocessor" >&5
+echo "configure:1083: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1053 "configure"
+#line 1098 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1059: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1104: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1070 "configure"
+#line 1115 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1076: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1121: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
if test "${with_slang+set}" = set; then
withval="$with_slang"
echo $ac_n "checking if -ltermlib is required""... $ac_c" 1>&6
-echo "configure:1102: checking if -ltermlib is required" >&5
+echo "configure:1147: checking if -ltermlib is required" >&5
if eval "test \"`echo '$''{'mutt_cv_bsdish'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 1110 "configure"
+#line 1155 "configure"
#include "confdefs.h"
#include <sys/param.h>
#endif
}
EOF
-if { (eval echo configure:1123: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1168: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
mutt_cv_bsdish=yes
else
echo "$ac_t""$mutt_cv_bsdish" 1>&6
echo $ac_n "checking for S-Lang""... $ac_c" 1>&6
-echo "configure:1140: checking for S-Lang" >&5
+echo "configure:1185: checking for S-Lang" >&5
if test $withval = yes; then
if test -d $srcdir/../slang; then
mutt_cv_slang=$srcdir/../slang/src
echo $ac_n "checking if I can compile a test SLang program""... $ac_c" 1>&6
-echo "configure:1186: checking if I can compile a test SLang program" >&5
+echo "configure:1231: checking if I can compile a test SLang program" >&5
cat > conftest.$ac_ext <<EOF
-#line 1188 "configure"
+#line 1233 "configure"
#include "confdefs.h"
int main() {
SLtt_get_terminfo ();
; return 0; }
EOF
-if { (eval echo configure:1195: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1240: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6
else
echo $ac_n "checking for initscr in -lncurses""... $ac_c" 1>&6
-echo "configure:1223: checking for initscr in -lncurses" >&5
+echo "configure:1268: checking for initscr in -lncurses" >&5
ac_lib_var=`echo ncurses'_'initscr | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lncurses $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1231 "configure"
+#line 1276 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
initscr()
; return 0; }
EOF
-if { (eval echo configure:1242: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1287: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1265: checking for $ac_hdr" >&5
+echo "configure:1310: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1270 "configure"
+#line 1315 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1275: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1320: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
echo $ac_n "checking for start_color""... $ac_c" 1>&6
-echo "configure:1316: checking for start_color" >&5
+echo "configure:1361: checking for start_color" >&5
if eval "test \"`echo '$''{'ac_cv_func_start_color'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1321 "configure"
+#line 1366 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char start_color(); below. */
; return 0; }
EOF
-if { (eval echo configure:1344: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1389: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_start_color=yes"
else
for ac_func in typeahead bkgdset curs_set meta use_default_colors
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1369: checking for $ac_func" >&5
+echo "configure:1414: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1374 "configure"
+#line 1419 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:1397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1442: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
for ac_func in resizeterm
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1424: checking for $ac_func" >&5
+echo "configure:1469: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1429 "configure"
+#line 1474 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:1452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1497: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1481: checking for ANSI C header files" >&5
+echo "configure:1526: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1486 "configure"
+#line 1531 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1494: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1539: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1511 "configure"
+#line 1556 "configure"
#include "confdefs.h"
#include <string.h>
EOF
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1529 "configure"
+#line 1574 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
:
else
cat > conftest.$ac_ext <<EOF
-#line 1550 "configure"
+#line 1595 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
exit (0); }
EOF
-if { (eval echo configure:1561: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1606: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
:
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1589: checking for $ac_hdr" >&5
+echo "configure:1634: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1594 "configure"
+#line 1639 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1599: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1644: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:1627: checking return type of signal handlers" >&5
+echo "configure:1672: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1632 "configure"
+#line 1677 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
int i;
; return 0; }
EOF
-if { (eval echo configure:1649: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1694: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
echo $ac_n "checking for sys_siglist declaration in signal.h or unistd.h""... $ac_c" 1>&6
-echo "configure:1669: checking for sys_siglist declaration in signal.h or unistd.h" >&5
+echo "configure:1714: checking for sys_siglist declaration in signal.h or unistd.h" >&5
if eval "test \"`echo '$''{'ac_cv_decl_sys_siglist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1674 "configure"
+#line 1719 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
char *msg = *(sys_siglist + 1);
; return 0; }
EOF
-if { (eval echo configure:1686: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1731: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_decl_sys_siglist=yes
else
echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:1708: checking size of long" >&5
+echo "configure:1753: checking size of long" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 1716 "configure"
+#line 1761 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
exit(0);
}
EOF
-if { (eval echo configure:1727: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_long=`cat conftestval`
else
echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:1748: checking for pid_t" >&5
+echo "configure:1793: checking for pid_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1753 "configure"
+#line 1798 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
for ac_func in setegid srand48 strerror
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1784: checking for $ac_func" >&5
+echo "configure:1829: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1789 "configure"
+#line 1834 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:1812: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1857: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
for ac_func in strcasecmp
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1840: checking for $ac_func" >&5
+echo "configure:1885: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1845 "configure"
+#line 1890 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:1868: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1913: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
mutt_cv_snprintf=no
echo $ac_n "checking for snprintf""... $ac_c" 1>&6
-echo "configure:1897: checking for snprintf" >&5
+echo "configure:1942: checking for snprintf" >&5
if eval "test \"`echo '$''{'ac_cv_func_snprintf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1902 "configure"
+#line 1947 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char snprintf(); below. */
; return 0; }
EOF
-if { (eval echo configure:1925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1970: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_snprintf=yes"
else
fi
echo $ac_n "checking for vsnprintf""... $ac_c" 1>&6
-echo "configure:1949: checking for vsnprintf" >&5
+echo "configure:1994: checking for vsnprintf" >&5
if eval "test \"`echo '$''{'ac_cv_func_vsnprintf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1954 "configure"
+#line 1999 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vsnprintf(); below. */
; return 0; }
EOF
-if { (eval echo configure:1977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_vsnprintf=yes"
else
for ac_func in ftruncate
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2007: checking for $ac_func" >&5
+echo "configure:2052: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2012 "configure"
+#line 2057 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:2035: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2080: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for chsize in -lx""... $ac_c" 1>&6
-echo "configure:2057: checking for chsize in -lx" >&5
+echo "configure:2102: checking for chsize in -lx" >&5
ac_lib_var=`echo x'_'chsize | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lx $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2065 "configure"
+#line 2110 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
chsize()
; return 0; }
EOF
-if { (eval echo configure:2076: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2121: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
for ac_func in strftime
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2110: checking for $ac_func" >&5
+echo "configure:2155: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2115 "configure"
+#line 2160 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:2138: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2183: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for strftime in -lintl""... $ac_c" 1>&6
-echo "configure:2160: checking for strftime in -lintl" >&5
+echo "configure:2205: checking for strftime in -lintl" >&5
ac_lib_var=`echo intl'_'strftime | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lintl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2168 "configure"
+#line 2213 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
strftime()
; return 0; }
EOF
-if { (eval echo configure:2179: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2224: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
for ac_func in regcomp
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2232: checking for $ac_func" >&5
+echo "configure:2277: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2237 "configure"
+#line 2282 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:2260: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
mutt_cv_mailpath=$withval
else
echo $ac_n "checking where new mail is stored""... $ac_c" 1>&6
-echo "configure:2331: checking where new mail is stored" >&5
+echo "configure:2376: checking where new mail is stored" >&5
if eval "test \"`echo '$''{'mutt_cv_mailpath'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
echo $ac_n "checking if $mutt_cv_mailpath is world writable""... $ac_c" 1>&6
-echo "configure:2360: checking if $mutt_cv_mailpath is world writable" >&5
+echo "configure:2405: checking if $mutt_cv_mailpath is world writable" >&5
if eval "test \"`echo '$''{'mutt_cv_worldwrite'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 2368 "configure"
+#line 2413 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
exit (1);
}
EOF
-if { (eval echo configure:2382: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
mutt_cv_worldwrite=yes
else
else
echo $ac_n "checking if $mutt_cv_mailpath is group writable""... $ac_c" 1>&6
-echo "configure:2407: checking if $mutt_cv_mailpath is group writable" >&5
+echo "configure:2452: checking if $mutt_cv_mailpath is group writable" >&5
if eval "test \"`echo '$''{'mutt_cv_groupwrite'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 2415 "configure"
+#line 2460 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
exit (1);
}
EOF
-if { (eval echo configure:2429: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2474: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
mutt_cv_groupwrite=yes
else
mutt_cv_sharedir=$withval
else
echo $ac_n "checking where to put architecture-independent data files""... $ac_c" 1>&6
-echo "configure:2465: checking where to put architecture-independent data files" >&5
+echo "configure:2510: checking where to put architecture-independent data files" >&5
if eval "test \"`echo '$''{'mutt_cv_sharedir'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
EOF
echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:2533: checking for socket in -lsocket" >&5
+echo "configure:2578: checking for socket in -lsocket" >&5
ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lsocket $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2541 "configure"
+#line 2586 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
socket()
; return 0; }
EOF
-if { (eval echo configure:2552: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2597: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
fi
echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:2580: checking for gethostbyname in -lnsl" >&5
+echo "configure:2625: checking for gethostbyname in -lnsl" >&5
ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2588 "configure"
+#line 2633 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
gethostbyname()
; return 0; }
EOF
-if { (eval echo configure:2599: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2644: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
EOF
echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:2639: checking for socket in -lsocket" >&5
+echo "configure:2684: checking for socket in -lsocket" >&5
ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lsocket $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2647 "configure"
+#line 2692 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
socket()
; return 0; }
EOF
-if { (eval echo configure:2658: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
fi
echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:2686: checking for gethostbyname in -lnsl" >&5
+echo "configure:2731: checking for gethostbyname in -lnsl" >&5
ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2694 "configure"
+#line 2739 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
gethostbyname()
; return 0; }
EOF
-if { (eval echo configure:2705: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2750: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
s%@INSTALL_DATA@%$INSTALL_DATA%g
s%@SENDMAIL@%$SENDMAIL%g
+s%@GPG@%$GPG%g
s%@PGPK@%$PGPK%g
s%@PGP@%$PGP%g
s%@OPS@%$OPS%g
if test -f $srcdir/pgp.c; then
SUBVERSION=i
PGPPATH=no
+
+ AC_PATH_PROG(GPG, gpg, no)
+ if test $GPG != no ; then
+ AC_DEFINE_UNQUOTED(_PGPGPGPATH, "$GPG")
+ PGPPATH="$GPG"
+ AC_DEFINE(HAVE_GPG)
+ fi
+
AC_PATH_PROG(PGPK, pgpk, no)
if test $PGPK != no ; then
PGPK=`echo $PGPK | sed 's,.$,,'`
fi
if test $PGP != no || test $PGPK != no ; then
- LIBOBJS="$LIBOBJS pgp.o pgpinvoke.o pgpkey.o pgppubring.o sha1dgst.o"
+ LIBOBJS="$LIBOBJS pgp.o pgpinvoke.o pgpkey.o pgppubring.o sha1dgst.o gnupgparse.o"
OPS="$OPS \$(srcdir)/OPS.PGP"
fi
fi
--- /dev/null
+/*
+ * Copyright (C) 1998 Werner Koch <werner.koch@guug.de>
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h>
+
+#include "mutt.h"
+#include "pgp.h"
+
+static const char *
+pkalgbytype(unsigned char type)
+{
+ switch(type)
+ {
+ case 1:
+ case 2:
+ case 3: return "RSA";
+ case 16: /* encrypt only */
+ case 20: return "ElG";
+ case 17: return "DSA";
+ default: return "unk";
+ }
+}
+
+static short canencrypt(unsigned char type)
+{
+ switch(type)
+ {
+ case 1:
+ case 2:
+ case 16:
+ case 20:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static short cansign(unsigned char type)
+{
+ switch(type)
+ {
+ case 1:
+ case 3:
+ case 16: /* hmmm: this one can only sign if used in a v3 packet */
+ case 17:
+ case 20:
+ return 1;
+ default:
+ return 0;
+ }
+}
+/* return values:
+ *
+ * 1 = sign only
+ * 2 = encrypt only
+ * 3 = both
+ */
+
+static short get_abilities(unsigned char type)
+{
+ return (canencrypt(type) << 1) | cansign(type);
+}
+
+/****************
+ * Read the GNUPG keys. For now we read the complete keyring by
+ * calling gnupg in a special mode.
+ *
+ * The output format of gpgm is colon delimited with these fields:
+ * - record type ("pub","uid","sig","rev" etc.)
+ * - trust info
+ * - key length
+ * - pubkey algo
+ * - 16 hex digits with the long keyid.
+ * - timestamp (1998-02-28)
+ * - Local id
+ * - ownertrust
+ * - name
+ * - signature class
+ */
+
+static KEYINFO *
+parse_pub_line( char *buf )
+{
+ KEYINFO *k=NULL;
+ PGPUID *uid = NULL;
+ int field = 0;
+ char *pend, *p;
+
+ if( !*buf )
+ return NULL;
+ for( p = buf; p; p = pend ) {
+ if( (pend = strchr(p, ':')) )
+ *pend++ = 0;
+ field++;
+ if( field > 1 && !*p )
+ continue;
+
+ switch( field ) {
+ case 1: /* record type */
+ if( strcmp(p,"pub") )
+ return NULL;
+ k = safe_malloc( sizeof(KEYINFO) );
+ k->keyid = NULL;
+ k->address = NULL;
+ k->flags = 0;
+ k->next = NULL;
+ k->keylen = 0;
+ break;
+ case 2: /* trust info */
+ /* k_>flags |= KEYFLAG_EXPIRED */
+ break;
+ case 3: /* key length */
+ k->keylen = atoi(p); /* fixme: add validation checks */
+ break;
+ case 4: /* pubkey algo */
+ k->algorithm = pkalgbytype(atoi(p));
+ k->flags |= get_abilities(atoi(p));
+ break;
+ case 5: /* 16 hex digits with the long keyid. */
+ /* We really should do a check here */
+ k->keyid = safe_strdup(p);
+ break;
+ case 6: /* timestamp (1998-02-28) */
+ break;
+ case 7: /* Local id */
+ break;
+ case 8: /* ownertrust */
+ break;
+ case 9: /* name */
+ k->address = mutt_new_list();
+ k->address->data = safe_malloc( sizeof(PGPUID) );
+ uid = (PGPUID *)k->address->data;
+ uid->addr = safe_strdup(p);
+ uid->trust = 0;
+ break;
+ case 10: /* signature class */
+ break;
+ default:
+ break;
+ }
+ }
+ return k;
+}
+
+static pid_t gpg_invoke_list_keys(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *uids)
+{
+ char cmd[HUGE_STRING];
+ char tmpcmd[HUGE_STRING];
+ char *cp;
+ char *keylist;
+
+ /* we use gpgm here */
+ snprintf(cmd, sizeof(cmd),
+ "%sm --no-verbose --batch --with-colons --list-keys ",
+ NONULL(*pgp->binary));
+
+ keylist = safe_strdup(uids);
+ for(cp = strtok(keylist, " "); cp ; cp = strtok(NULL, " "))
+ {
+ snprintf(tmpcmd, sizeof(tmpcmd), "%s %s",
+ cmd, cp);
+ strcpy(cmd, tmpcmd);
+ }
+ safe_free((void **) &keylist);
+
+ return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
+ pgpinfd, pgpoutfd, pgperrfd);
+}
+
+KEYINFO *gpg_read_pubring(struct pgp_vinfo *pgp)
+{
+ FILE *fp;
+ pid_t thepid;
+ char buf[LONG_STRING];
+ KEYINFO *db = NULL, **kend, *k = NULL;
+
+ thepid = gpg_invoke_list_keys(pgp, NULL, &fp, NULL, -1, -1, -1, NULL);
+ if( thepid == -1 )
+ return NULL;
+
+ kend = &db;
+ k = NULL;
+ while( fgets( buf, sizeof(buf)-1, fp ) ) {
+ if( k )
+ kend = &k->next;
+ *kend = k = parse_pub_line(buf);
+ }
+
+ fclose( fp );
+ mutt_wait_filter( thepid );
+
+ return db;
+}
+
+
+KEYINFO *gpg_read_secring(struct pgp_vinfo *pgp)
+{
+ mutt_error("gpg_read_secring() has not yet been implemented.");
+ sleep(1);
+ return NULL;
+}
PgpV3Secring = safe_strdup (buffer);
}
#endif
+
+#ifdef _PGPGPGPATH
+ PgpGpg = safe_strdup (_PGPGPGPATH);
+#endif
#endif /* _PGPPATH */
{ "pgp_v5_pubring", DT_PATH, R_NONE, UL &PgpV3Pubring, 0 },
{ "pgp_v5_secring", DT_PATH, R_NONE, UL &PgpV3Secring, 0 },
+ { "pgp_gpg", DT_PATH, R_NONE, UL &PgpGpg, 0 },
+
# ifdef HAVE_PGP2
{ "pgp_default_version", DT_STR, R_NONE, UL &PgpDefaultVersion, UL "pgp2" },
# else
# ifdef HAVE_PGP5
{ "pgp_default_version", DT_STR, R_NONE, UL &PgpDefaultVersion, UL "pgp5" },
+# else
+# ifdef HAVE_GPG
+ { "pgp_default_version", DT_STR, R_NONE, UL &PgpDefaultVersion, UL "gpg" },
+# endif
# endif
# endif
{ "pgp_receive_version", DT_STR, R_NONE, UL &PgpReceiveVersion, UL "default" },
{ "pgp_send_version", DT_STR, R_NONE, UL &PgpSendVersion, UL "default" },
{ "pgp_key_version", DT_STR, R_NONE, UL &PgpKeyVersion, UL "default" },
-
+
#endif /* _PGPPATH */
-
-
+
+
{ "pipe_split", DT_BOOL, R_NONE, OPTPIPESPLIT, 0 },
{ "pipe_decode", DT_BOOL, R_NONE, OPTPIPEDECODE, 0 },
{ "pipe_sep", DT_STR, R_NONE, UL &PipeSep, UL "\n" },
#ifdef HAVE_PGP2
"+HAVE_PGP2 "
#endif
+#ifdef HAVE_GPG
+ "+HAVE_GPG "
+#endif
#endif
# ifdef _PGPV3PATH
printf ("_PGPV3PATH=\"%s\"\n", _PGPV3PATH);
# endif
+# ifdef _PGPGPPATH
+ pritnf ("_PGPGPGPATH=\"%s\"\n", _PGPGPGPATH);
+# endif
#endif
/*
* Copyright (C) 1996,1997 Michael R. Elkins <me@cs.hmc.edu>
+ * Copyright (c) 1998 Thomas Roessler <roessler@guug.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
static struct pgp_vinfo pgp_vinfo[] =
{
- { PGP_V2, "pgp2", &PgpV2, &PgpV2Pubring, &PgpV2Secring, &PgpV2Language },
- { PGP_V3, "pgp3", &PgpV3, &PgpV3Pubring, &PgpV3Secring, &PgpV3Language },
- { PGP_V3, "pgp5", &PgpV3, &PgpV3Pubring, &PgpV3Secring, &PgpV3Language },
- { PGP_UNKNOWN, NULL, NULL, NULL, NULL, NULL}
+
+ { PGP_V2,
+ "pgp2",
+ &PgpV2, &PgpV2Pubring, &PgpV2Secring, &PgpV2Language,
+ pgp_read_pubring, pgp_read_secring,
+ pgp_v2_invoke_decode, pgp_v2_invoke_verify, pgp_v2_invoke_decrypt,
+ pgp_v2_invoke_sign, pgp_v2_invoke_encrypt, pgp_v2_invoke_import,
+ pgp_v2_invoke_export, pgp_v2_invoke_verify_key
+ },
+
+ { PGP_V3,
+ "pgp3",
+ &PgpV3, &PgpV3Pubring, &PgpV3Secring, &PgpV3Language,
+ pgp_read_pubring, pgp_read_secring,
+ pgp_v3_invoke_decode, pgp_v3_invoke_verify, pgp_v3_invoke_decrypt,
+ pgp_v3_invoke_sign, pgp_v3_invoke_encrypt, pgp_v3_invoke_import,
+ pgp_v3_invoke_export, pgp_v3_invoke_verify_key
+ },
+
+ { PGP_V3,
+ "pgp5",
+ &PgpV3, &PgpV3Pubring, &PgpV3Secring, &PgpV3Language,
+ pgp_read_pubring, pgp_read_secring,
+ pgp_v3_invoke_decode, pgp_v3_invoke_verify, pgp_v3_invoke_decrypt,
+ pgp_v3_invoke_sign, pgp_v3_invoke_encrypt, pgp_v3_invoke_import,
+ pgp_v3_invoke_export, pgp_v3_invoke_verify_key
+ },
+
+ { PGP_GPG,
+ "gpg",
+ &PgpGpg, &PgpGpgDummy, &PgpGpgDummy, &PgpGpgDummy,
+ gpg_read_pubring, gpg_read_secring,
+ pgp_gpg_invoke_decode, pgp_gpg_invoke_verify, pgp_gpg_invoke_decrypt,
+ pgp_gpg_invoke_sign, pgp_gpg_invoke_encrypt, pgp_gpg_invoke_import,
+ pgp_gpg_invoke_export, pgp_gpg_invoke_verify_key
+ },
+
+ { PGP_UNKNOWN,
+ NULL,
+ NULL, NULL, NULL, NULL,
+ NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL
+ }
};
static struct
{ PGP_SIGN, &PgpSendVersion },
{ PGP_ENCRYPT, &PgpSendVersion },
{ PGP_VERIFY_KEY, &PgpSendVersion },
- { PGP_EXTRACT, &PgpKeyVersion },
- { PGP_EXTRACT_KEY, &PgpKeyVersion },
+ { PGP_IMPORT, &PgpKeyVersion },
+ { PGP_EXPORT, &PgpKeyVersion },
{ PGP_LAST_OP, NULL }
};
{
int i;
char *version = "default";
+ char msg[LONG_STRING];
for(i = 0; pgp_opvers[i].op != PGP_LAST_OP; i++)
{
if(!strcasecmp(pgp_vinfo[i].name, version))
return &pgp_vinfo[i];
}
-
- return NULL;
-}
-
-enum pgp_version pgp_version(enum pgp_ops op)
-{
- struct pgp_vinfo *info = pgp_get_vinfo(op);
- return info ? info->v : PGP_UNKNOWN;
-}
+ snprintf(msg, sizeof(msg), "Unknown PGP version \"%s\".",
+ version);
+ mutt_error(msg);
-char *pgp_getring (enum pgp_ops op, int pub)
-{
- struct pgp_vinfo *info = pgp_get_vinfo(op);
- if(!info) return NULL;
- return pub ? *info->pubring : *info->secring;
-}
-
-char *pgp_binary(enum pgp_ops op)
-{
- struct pgp_vinfo *info = pgp_get_vinfo(op);
- return info ? *info->binary : NULL;
+ return NULL;
}
-
char *pgp_keyid(KEYINFO *k)
{
if((k->flags & KEYFLAG_SUBKEY) && k->mainkey)
FILE *pgpout = NULL, *pgpin, *pgperr;
FILE *tmpfp;
pid_t thepid;
-
+ struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_DECODE);
+ if(!pgp)
+ return;
+
fseek (s->fpin, m->offset, 0);
last_pos = m->offset;
fclose(tmpfp);
- if ((thepid = pgp_invoke_decode (&pgpin, NULL, &pgperr, -1,
- fileno (pgpout), -1, tmpfname, needpass)) == -1)
+ if ((thepid = pgp->invoke_decode (pgp,
+ &pgpin, NULL,
+ &pgperr, -1,
+ fileno (pgpout),
+ -1, tmpfname,
+ needpass)) == -1)
{
fclose (pgpout); pgpout = NULL;
mutt_unlink(tmpfname);
int hadcr;
int c;
pid_t thepid;
+ struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_VERIFY);
+
+ if(!pgp)
+ return;
a = a->parts;
pgp_current_time (s);
- if((thepid = pgp_invoke_verify (NULL, &pgpout, NULL, -1, -1, fileno(pgperr),
- tempfile, sigfile)) != -1)
+ if((thepid = pgp->invoke_verify (pgp,
+ NULL, &pgpout, NULL,
+ -1, -1, fileno(pgperr),
+ tempfile, sigfile)) != -1)
{
mutt_copy_stream(pgpout, s->fpout);
fclose (pgpout);
int i;
STATE s;
char tempfname[_POSIX_PATH_MAX];
+ struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_IMPORT);
+
+ if(!pgp)
+ return;
if(h)
{
fclose(s.fpout);
endwin();
- pgp_invoke_extract(tempfname);
+ pgp->invoke_import(pgp, tempfname);
mutt_any_key_to_continue(NULL);
bailout:
}
-static void pgp_extract_keys_from_attachment(FILE *fp, BODY *top)
+static void pgp_extract_keys_from_attachment(struct pgp_vinfo *pgp,
+ FILE *fp, BODY *top)
{
STATE s;
FILE *tempfp;
fclose(tempfp);
- pgp_invoke_extract(tempfname);
+ pgp->invoke_import(pgp, tempfname);
mutt_any_key_to_continue(NULL);
mutt_unlink(tempfname);
void pgp_extract_keys_from_attachment_list (FILE *fp, int tag, BODY *top)
{
+ struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_IMPORT);
+
+ if(!pgp)
+ return;
+
if(!fp)
{
mutt_error("Internal error. Inform <roessler@guug.de>.");
for(; top; top = top->next)
{
if(!tag || top->tagged)
- pgp_extract_keys_from_attachment (fp, top);
+ pgp_extract_keys_from_attachment (pgp, fp, top);
if(!tag)
break;
char pgperrfile[_POSIX_PATH_MAX];
char pgptmpfile[_POSIX_PATH_MAX];
pid_t thepid;
-
+ struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_DECRYPT);
+
+ if(!pgp)
+ return NULL;
+
mutt_mktemp (pgperrfile);
if ((pgperr = safe_fopen (pgperrfile, "w+")) == NULL)
{
mutt_copy_bytes (s->fpin, pgptmp, a->length);
fclose (pgptmp);
- if ((thepid = pgp_invoke_decrypt (&pgpin, &pgpout, NULL, -1, -1,
+ if ((thepid = pgp->invoke_decrypt (pgp, &pgpin, &pgpout, NULL, -1, -1,
fileno (pgperr), pgptmpfile)) == -1)
{
fclose (pgperr);
int err = 0;
int empty = 1;
pid_t thepid;
-
+ struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_SIGN);
+
+ if(!pgp)
+ return NULL;
+
convert_to_7bit (a); /* Signed data _must_ be in 7-bit format. */
mutt_mktemp (sigfile);
mutt_write_mime_body (a, sfp);
fclose(sfp);
- if((thepid = pgp_invoke_sign(&pgpin, &pgpout, &pgperr,
+ if((thepid = pgp->invoke_sign(pgp, &pgpin, &pgpout, &pgperr,
-1, -1, -1, signedfile)) == -1)
{
mutt_perror("Can't open PGP subprocess!");
*/
char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
{
- char *pubring = pgp_pubring(PGP_ENCRYPT);
char *key, *keylist = NULL;
size_t keylist_size = 0;
size_t keylist_used = 0;
int i;
KEYINFO *db;
KEYINFO *k_info;
+ struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_ENCRYPT);
- db = pgp_read_keyring(pubring);
+ if(!pgp)
+ return NULL;
+
+ db = pgp->read_pubring(pgp);
for (i = 0; i < 3; i++)
{
for (p = tmp; p ; p = p->next)
{
- if ((k_info = ki_getkeybyaddr (p, db, KEYFLAG_CANENCRYPT)) == NULL)
+ if ((k_info = ki_getkeybyaddr (pgp, p, db, KEYFLAG_CANENCRYPT)) == NULL)
{
char buf[LONG_STRING];
snprintf (buf, sizeof (buf), "Enter keyID for %s: ", p->mailbox);
- if ((key = pgp_ask_for_key (pubring, db, buf, p->mailbox,
+ if ((key = pgp_ask_for_key (pgp, db, buf, p->mailbox,
KEYFLAG_CANENCRYPT, NULL)) == NULL)
{
- pgp_closedb (db);
+ pgp_close_keydb (&db);
safe_free ((void **)&keylist);
rfc822_free_address (&tmp);
return NULL;
keylist_used = strlen (keylist);
}
rfc822_free_address (&tmp);
- pgp_closedb (db);
+ pgp_close_keydb (&db);
return (keylist);
}
int err = 0;
int empty;
pid_t thepid;
+ struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_ENCRYPT);
+
+ if(!pgp)
+ return NULL;
mutt_mktemp (tempfile);
if ((fpout = safe_fopen (tempfile, "w+")) == NULL)
mutt_write_mime_body (a, fptmp);
fclose(fptmp);
- if ((thepid = pgp_invoke_encrypt (&pgpin, NULL, NULL, -1,
- fileno (fpout), fileno (pgperr),
- pgpinfile, keylist, sign)) == -1)
+ if ((thepid = pgp->invoke_encrypt (pgp, &pgpin, NULL, NULL, -1,
+ fileno (fpout), fileno (pgperr),
+ pgpinfile, keylist, sign)) == -1)
{
fclose (pgperr);
unlink(pgpinfile);
enum pgp_version
{
PGP_V2,
- PGP_V3,
+ PGP_V3,
+ PGP_GPG,
PGP_UNKNOWN
};
PGP_DECRYPT, /* PGP/MIME, encrypted */
PGP_SIGN, /* sign data */
PGP_ENCRYPT, /* encrypt data */
- PGP_EXTRACT, /* extract keys from messages */
+ PGP_IMPORT, /* extract keys from messages */
PGP_VERIFY_KEY, /* verify key when selecting */
- PGP_EXTRACT_KEY, /* extract keys from key ring */
+ PGP_EXPORT, /* extract keys from key ring */
PGP_LAST_OP
};
struct pgp_vinfo
{
+
+ /* data */
+
enum pgp_version v;
char *name;
char **binary;
char **pubring;
char **secring;
char **language;
+
+ /* functions */
+
+ KEYINFO * (*read_pubring)(struct pgp_vinfo *);
+ KEYINFO * (*read_secring)(struct pgp_vinfo *);
+
+ pid_t (*invoke_decode)(struct pgp_vinfo *, FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, int);
+
+ pid_t (*invoke_verify)(struct pgp_vinfo *, FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, const char *);
+
+ pid_t (*invoke_decrypt)(struct pgp_vinfo *, FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+ pid_t (*invoke_sign)(struct pgp_vinfo *, FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+ pid_t (*invoke_encrypt)(struct pgp_vinfo *, FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, const char *, int);
+
+ void (*invoke_import)(struct pgp_vinfo *, const char *);
+
+ pid_t (*invoke_export)(struct pgp_vinfo *, FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+ pid_t (*invoke_verify_key)(struct pgp_vinfo *, FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
};
WHERE char *PgpV3Pubring;
WHERE char *PgpV3Secring;
+WHERE char *PgpGpg;
+#if 0
+WHERE char *PgpGpgLanguage;
+WHERE char *PgpGpgPubring;
+WHERE char *PgpGpgSecring;
+#else
+WHERE char *PgpGpgDummy;
+#endif
+
WHERE char *PgpSendVersion;
WHERE char *PgpReceiveVersion;
WHERE char *PgpKeyVersion;
const char *pgp_pkalg_to_mic(const char *);
-char *pgp_ask_for_key (const char *, KEYINFO *, char *, char *, short, char **);
+char *pgp_ask_for_key (struct pgp_vinfo *, KEYINFO *, char *, char *, short, char **);
-char *pgp_binary(enum pgp_ops);
-char *pgp_getring (enum pgp_ops, int);
char *pgp_keyid(KEYINFO *);
char *_pgp_keyid(KEYINFO *);
-enum pgp_version pgp_version(enum pgp_ops);
struct pgp_vinfo *pgp_get_vinfo(enum pgp_ops);
int mutt_check_pgp (HEADER *h);
int pgp_query (BODY *);
int pgp_valid_passphrase (void);
-KEYINFO *ki_getkeybyaddr (ADDRESS *, KEYINFO *, short);
-KEYINFO *ki_getkeybystr (char *, KEYINFO *, short);
-KEYINFO *pgp_read_keyring(const char *);
+KEYINFO *ki_getkeybyaddr (struct pgp_vinfo *pgp, ADDRESS *, KEYINFO *, short);
+KEYINFO *ki_getkeybystr (struct pgp_vinfo *pgp, char *, KEYINFO *, short);
+KEYINFO *pgp_read_pubring(struct pgp_vinfo *pgp);
+KEYINFO *pgp_read_secring(struct pgp_vinfo *pgp);
+KEYINFO *gpg_read_pubring(struct pgp_vinfo *pgp);
+KEYINFO *gpg_read_secring(struct pgp_vinfo *pgp);
void application_pgp_handler (BODY *, STATE *);
void mutt_forget_passphrase (void);
-void pgp_closedb (KEYINFO *);
+void pgp_close_keydb (KEYINFO **);
void pgp_encrypted_handler (BODY *, STATE *);
void pgp_extract_keys_from_attachment_list (FILE *fp, int tag, BODY *top);
void pgp_extract_keys_from_messages(HEADER *hdr);
#define pgp_secring(a) pgp_getring(a, 0)
#define pgp_pubring(a) pgp_getring(a, 1)
+/* PGP V2 prototypes */
+
+
+pid_t pgp_v2_invoke_decode(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, int);
+
+pid_t pgp_v2_invoke_verify(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, const char *);
+
+
+pid_t pgp_v2_invoke_decrypt(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+pid_t pgp_v2_invoke_sign(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+pid_t pgp_v2_invoke_encrypt(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, const char *, int);
+
+void pgp_v2_invoke_import(struct pgp_vinfo *, const char *);
+
+pid_t pgp_v2_invoke_export(struct pgp_vinfo*,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+pid_t pgp_v2_invoke_verify_key(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+/* PGP V3 prototypes */
+
+pid_t pgp_v3_invoke_decode(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, int);
+
+pid_t pgp_v3_invoke_verify(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, const char *);
+
+
+pid_t pgp_v3_invoke_decrypt(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+pid_t pgp_v3_invoke_sign(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+pid_t pgp_v3_invoke_encrypt(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, const char *, int);
+
+void pgp_v3_invoke_import(struct pgp_vinfo *, const char *);
+
+pid_t pgp_v3_invoke_export(struct pgp_vinfo*,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+pid_t pgp_v3_invoke_verify_key(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+/* GNU Privacy Guard Prototypes */
+
+pid_t pgp_gpg_invoke_decode(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, int);
+
+pid_t pgp_gpg_invoke_verify(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, const char *);
+
+
+pid_t pgp_gpg_invoke_decrypt(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+pid_t pgp_gpg_invoke_sign(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+pid_t pgp_gpg_invoke_encrypt(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, const char *, int);
+
+void pgp_gpg_invoke_import(struct pgp_vinfo *, const char *);
+
+pid_t pgp_gpg_invoke_export(struct pgp_vinfo*,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+pid_t pgp_gpg_invoke_verify_key(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+
+
+
+#if 0
+
+/* use these as templates for your own prototypes */
+
+
+pid_t pgp_VERSION_invoke_decode(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, int);
+
+pid_t pgp_VERSION_invoke_verify(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, const char *);
+
+
+pid_t pgp_VERSION_invoke_decrypt(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+pid_t pgp_VERSION_invoke_sign(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+
+pid_t pgp_VERSION_invoke_encrypt(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *, const char *, int);
+
+void pgp_VERSION_invoke_import(struct pgp_vinfo *, const char *);
+
+pid_t pgp_VERSION_invoke_export(struct pgp_vinfo*,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
-pid_t pgp_invoke_decode(FILE **, FILE **, FILE **, int, int, int, const char *, int);
-pid_t pgp_invoke_verify(FILE **, FILE **, FILE **, int, int, int, const char *, const char *);
-pid_t pgp_invoke_decrypt(FILE **, FILE **, FILE **, int, int, int, const char *);
-pid_t pgp_invoke_sign(FILE **, FILE **, FILE **, int, int, int, const char *);
-pid_t pgp_invoke_encrypt(FILE **, FILE **, FILE **, int, int, int, const char *, const char *, int);
-void pgp_invoke_extract(const char *);
-pid_t pgp_invoke_verify_key(FILE **, FILE **, FILE **, int, int, int, const char *);
-pid_t pgp_invoke_extract_key(FILE **, FILE **, FILE **, int, int, int, const char *);
+pid_t pgp_VERSION_invoke_verify_key(struct pgp_vinfo *,
+ FILE **, FILE **, FILE **,
+ int, int, int,
+ const char *);
+#endif
#endif /* _PGPPATH */
/*
- * Copyright (C) 1997 Thomas Roessler <roessler@guug.de>
+ * Copyright (C) 1997-1998 Thomas Roessler <roessler@guug.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "pgp.h"
-pid_t pgp_invoke_decode (FILE **pgpin, FILE **pgpout, FILE **pgperr,
- int pgpinfd, int pgpoutfd, int pgperrfd,
- const char *fname, int need_passphrase)
+/*******************************************************************
+ *
+ * PGP V2 Invocation stuff
+ *
+ *******************************************************************/
+
+pid_t pgp_v2_invoke_decode(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *fname, int need_passphrase)
{
char cmd[HUGE_STRING];
- struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_DECODE);
-
- if(!pgp)
- {
- mutt_error("Unknown PGP version.");
- return -1;
- }
- switch(pgp->v)
- {
- case PGP_V2:
- snprintf(cmd, sizeof(cmd), "%scat %s%s | "
- "%s +language=%s +pubring=%s +secring=%s +verbose=0 +batchmode -f",
- need_passphrase ? "PGPPASSFD=0; export PGPPASSFD; " : "",
- need_passphrase ? "- " : "",
- fname,
- NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring));
- break;
-
- case PGP_V3:
- snprintf(cmd, sizeof(cmd), "%scat %s%s | "
- "%sv +language=%s +pubring=%s +secring=%s +verbose=0 +batchmode -f "
- "--OutputInformationFD=2",
- need_passphrase ? "PGPPASSFD=0; export PGPPASSFD; " : "",
- need_passphrase ? "- " : "",
- fname,
- NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring));
- break;
-
- default:
- mutt_error("Unknown PGP version.");
- return -1;
- }
+ snprintf(cmd, sizeof(cmd), "%scat %s%s | "
+ "%s +language=%s +pubring=%s +secring=%s +verbose=0 +batchmode -f",
+ need_passphrase ? "PGPPASSFD=0; export PGPPASSFD; " : "",
+ need_passphrase ? "- " : "",
+ fname,
+ NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring));
return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
pgpinfd, pgpoutfd, pgperrfd);
}
-pid_t pgp_invoke_verify(FILE **pgpin, FILE **pgpout, FILE **pgperr,
- int pgpinfd, int pgpoutfd, int pgperrfd,
- const char *signedstuff, const char *sigfile)
+pid_t pgp_v2_invoke_verify(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *signedstuff, const char *sigfile)
{
char cmd[HUGE_STRING];
- struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_VERIFY);
- if(!pgp)
- {
- mutt_error("Unknown PGP version.");
- return -1;
- }
-
- switch(pgp->v)
- {
- case PGP_V2:
- snprintf(cmd, sizeof(cmd),
- "%s +language=%s +pubring=%s +secring=%s +batchmode +verbose=0 %s %s",
- NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), sigfile, signedstuff);
- break;
-
- case PGP_V3:
- snprintf(cmd, sizeof(cmd),
- "%sv +language=%s +pubring=%s +secring=%s --OutputInformationFD=1 +batchmode +verbose=0 %s %s",
- NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), sigfile, signedstuff);
- break;
-
- default:
- mutt_error("Unknown PGP version.");
- return -1;
- }
-
+ snprintf(cmd, sizeof(cmd),
+ "%s +language=%s +pubring=%s +secring=%s +batchmode +verbose=0 %s %s",
+ NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), sigfile, signedstuff);
+
return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
pgpinfd, pgpoutfd, pgperrfd);
}
+pid_t pgp_v2_invoke_decrypt(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *fname)
+{
+ char cmd[HUGE_STRING];
+
+ snprintf(cmd, sizeof(cmd),
+ "PGPPASSFD=0; export PGPPASSFD; cat - %s | %s +language=%s +pubring=%s +secring=%s "
+ "+verbose=0 +batchmode -f",
+ fname, NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring));
+
+ return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
+ pgpinfd, pgpoutfd, pgperrfd);
+}
-pid_t pgp_invoke_decrypt(FILE **pgpin, FILE **pgpout, FILE **pgperr,
- int pgpinfd, int pgpoutfd, int pgperrfd,
+
+
+
+pid_t pgp_v2_invoke_sign(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
const char *fname)
{
char cmd[HUGE_STRING];
- struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_DECRYPT);
- if(!pgp)
- {
- mutt_error("Unknown PGP version.");
- return -1;
- }
+ snprintf(cmd, sizeof(cmd),
+ "PGPPASSFD=0; export PGPPASSFD; cat - %s | %s "
+ "+language=%s +pubring=%s +secring=%s +verbose=0 +batchmode -abfst %s %s",
+ fname, NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring),
+ PgpSignAs ? "-u" : "",
+ PgpSignAs ? PgpSignAs : "");
+
+ return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
+ pgpinfd, pgpoutfd, pgperrfd);
+}
- switch(pgp->v)
- {
- case PGP_V2:
- snprintf(cmd, sizeof(cmd),
- "PGPPASSFD=0; export PGPPASSFD; cat - %s | %s +language=%s +pubring=%s +secring=%s "
- "+verbose=0 +batchmode -f",
- fname, NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring));
- break;
-
- case PGP_V3:
- snprintf(cmd, sizeof(cmd),
- "PGPPASSFD=0; export PGPPASSFD; cat - %s | %sv +language=%s +pubring=%s +secring=%s "
- "+verbose=0 +batchmode -f --OutputInformationFD=2",
- fname, NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring));
- break;
-
- default:
- mutt_error("Unknown PGP version.");
- return -1;
- }
+
+pid_t pgp_v2_invoke_encrypt(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *fname, const char *uids, int sign)
+{
+ char cmd[HUGE_STRING];
+
+ snprintf(cmd, sizeof(cmd),
+ "%scat %s%s | %s +language=%s +pubring=%s +secring=%s +verbose=0 %s +batchmode -aeft%s %s%s %s",
+ sign ? "PGPPASSFD=0; export PGPPASSFD; " : "",
+ sign ? "- " : "",
+ fname,
+ NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring),
+ option(OPTPGPENCRYPTSELF) ? "+encrypttoself" : "",
+ sign ? "s" : "",
+ sign && PgpSignAs ? "-u " : "",
+ sign && PgpSignAs ? PgpSignAs : "",
+ uids);
+
+ return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
+ pgpinfd, pgpoutfd, pgperrfd);
+}
+
+void pgp_v2_invoke_import(struct pgp_vinfo *pgp, const char *fname)
+{
+ char cmd[HUGE_STRING];
+
+ snprintf(cmd, sizeof(cmd), "%s +language=%s +pubring=%s +secring=%s -ka %s",
+ NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), fname);
+ mutt_system(cmd);
+}
+
+pid_t pgp_v2_invoke_export(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd, const char *id)
+{
+ char cmd[HUGE_STRING];
+
+ snprintf(cmd, sizeof(cmd), "%s -kxaf +language=%s +pubring=%s +secring=%s 0x%8s",
+ NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), id);
return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
- pgpinfd, pgpoutfd, pgperrfd);
+ pgpinfd, pgpoutfd, pgperrfd);
}
-pid_t pgp_invoke_sign(FILE **pgpin, FILE **pgpout, FILE **pgperr,
- int pgpinfd, int pgpoutfd, int pgperrfd,
- const char *fname)
+pid_t pgp_v2_invoke_verify_key(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd, const char *id)
{
char cmd[HUGE_STRING];
- struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_SIGN);
- if(!pgp)
- {
- mutt_error("Unknown PGP version.");
- return -1;
- }
+ snprintf(cmd, sizeof(cmd), "%s +language=%s +pubring=%s +secring=%s +batchmode -kcc 0x%8s",
+ NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), id);
+ return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
+ pgpinfd, pgpoutfd, pgperrfd);
+}
- switch(pgp->v)
- {
- case PGP_V2:
- snprintf(cmd, sizeof(cmd),
- "PGPPASSFD=0; export PGPPASSFD; cat - %s | %s "
- "+language=%s +pubring=%s +secring=%s +verbose=0 +batchmode -abfst %s %s",
- fname, NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring),
- PgpSignAs ? "-u" : "",
- PgpSignAs ? PgpSignAs : "");
- break;
-
- case PGP_V3:
- snprintf(cmd, sizeof(cmd),
- "PGPPASSFD=0; export PGPPASSFD; cat - %s | %ss "
- "+language=%s +pubring=%s +secring=%s +verbose=0 -abft %s %s",
- fname, NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring),
- PgpSignAs ? "-u" : "",
- PgpSignAs ? PgpSignAs : "");
- break;
-
- default:
- mutt_error("Unknown PGP version.");
- return -1;
- }
+/*******************************************************************
+ *
+ * PGP V3 Invocation stuff
+ *
+ *******************************************************************/
+
+
+pid_t pgp_v3_invoke_decode(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *fname, int need_passphrase)
+{
+ char cmd[HUGE_STRING];
+
+ snprintf(cmd, sizeof(cmd), "%scat %s%s | "
+ "%sv +language=%s +pubring=%s +secring=%s +verbose=0 +batchmode -f "
+ "--OutputInformationFD=2",
+ need_passphrase ? "PGPPASSFD=0; export PGPPASSFD; " : "",
+ need_passphrase ? "- " : "",
+ fname,
+ NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring));
return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
pgpinfd, pgpoutfd, pgperrfd);
}
-pid_t pgp_invoke_encrypt(FILE **pgpin, FILE **pgpout, FILE **pgperr,
- int pgpinfd, int pgpoutfd, int pgperrfd,
- const char *fname, const char *uids, int sign)
+pid_t pgp_v3_invoke_verify(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *signedstuff, const char *sigfile)
+{
+ char cmd[HUGE_STRING];
+
+ snprintf(cmd, sizeof(cmd),
+ "%sv +language=%s +pubring=%s +secring=%s --OutputInformationFD=1 +batchmode +verbose=0 %s %s",
+ NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), sigfile, signedstuff);
+
+ return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
+ pgpinfd, pgpoutfd, pgperrfd);
+}
+
+pid_t pgp_v3_invoke_encrypt(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *fname, const char *uids, int sign)
{
char cmd[HUGE_STRING];
char tmpcmd[HUGE_STRING];
char *cp;
char *keylist;
- struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_ENCRYPT);
- if(!pgp)
- {
- mutt_error("Unknown PGP version.");
- return -1;
- }
-
- switch(pgp->v)
+ snprintf(cmd, sizeof(cmd),
+ "%scat %s%s | %se +language=%s +pubring=%s +secring=%s +verbose=0 %s +batchmode +nobatchinvalidkeys=off -aft%s %s%s",
+ sign ? "PGPPASSFD=0; export PGPPASSFD; " : "",
+ sign ? "- " : "",
+ fname,
+ NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring),
+ option(OPTPGPENCRYPTSELF) ? "+encrypttoself" : "",
+ sign ? "s" : "",
+ sign && PgpSignAs ? "-u " : "",
+ sign && PgpSignAs ? PgpSignAs : "");
+
+ keylist = safe_strdup(uids);
+
+ for(cp = strtok(keylist, " "); cp ; cp = strtok(NULL, " "))
{
- case PGP_V2:
- snprintf(cmd, sizeof(cmd),
- "%scat %s%s | %s +language=%s +pubring=%s +secring=%s +verbose=0 %s +batchmode -aeft%s %s%s %s",
- sign ? "PGPPASSFD=0; export PGPPASSFD; " : "",
- sign ? "- " : "",
- fname,
- NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring),
- option(OPTPGPENCRYPTSELF) ? "+encrypttoself" : "",
- sign ? "s" : "",
- sign && PgpSignAs ? "-u " : "",
- sign && PgpSignAs ? PgpSignAs : "",
- uids);
- break;
-
- case PGP_V3:
- snprintf(cmd, sizeof(cmd),
- "%scat %s%s | %se +language=%s +pubring=%s +secring=%s +verbose=0 %s +batchmode +nobatchinvalidkeys=off -aft%s %s%s",
- sign ? "PGPPASSFD=0; export PGPPASSFD; " : "",
- sign ? "- " : "",
- fname,
- NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring),
- option(OPTPGPENCRYPTSELF) ? "+encrypttoself" : "",
- sign ? "s" : "",
- sign && PgpSignAs ? "-u " : "",
- sign && PgpSignAs ? PgpSignAs : "");
-
- keylist = safe_strdup(uids);
- for(cp = strtok(keylist, " "); cp ; cp = strtok(NULL, " "))
- {
- snprintf(tmpcmd, sizeof(tmpcmd), "%s -r %s",
- cmd, cp);
- strcpy(cmd, tmpcmd);
- }
- safe_free((void **) &keylist);
- break;
-
- default:
- mutt_error("Unknown PGP version.");
- return -1;
-
+ snprintf(tmpcmd, sizeof(tmpcmd), "%s -r %s",
+ cmd, cp);
+ strcpy(cmd, tmpcmd);
}
+ safe_free((void **) &keylist);
return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
pgpinfd, pgpoutfd, pgperrfd);
}
-
-void pgp_invoke_extract(const char *fname)
+pid_t pgp_v3_invoke_decrypt(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *fname)
{
char cmd[HUGE_STRING];
- struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_EXTRACT);
+
+ snprintf(cmd, sizeof(cmd),
+ "PGPPASSFD=0; export PGPPASSFD; cat - %s | %sv +language=%s +pubring=%s +secring=%s "
+ "+verbose=0 +batchmode -f --OutputInformationFD=2",
+ fname, NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring));
+
+ return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
+ pgpinfd, pgpoutfd, pgperrfd);
+}
- if(!pgp)
- {
- mutt_error("Unknown PGP version.");
- return;
- }
- switch(pgp->v)
- {
- case PGP_V2:
- snprintf(cmd, sizeof(cmd), "%s +language=%s +pubring=%s +secring=%s -ka %s",
- NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), fname);
- break;
+pid_t pgp_v3_invoke_sign(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *fname)
+{
+ char cmd[HUGE_STRING];
- case PGP_V3:
- snprintf(cmd, sizeof(cmd), "%sk +language=%s +pubring=%s +secring=%s -a --OutputInformationFD=1 %s",
- NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), fname);
- break;
+ snprintf(cmd, sizeof(cmd),
+ "PGPPASSFD=0; export PGPPASSFD; cat - %s | %ss "
+ "+language=%s +pubring=%s +secring=%s +verbose=0 -abft %s %s",
+ fname, NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring),
+ PgpSignAs ? "-u" : "",
+ PgpSignAs ? PgpSignAs : "");
- default:
- mutt_error("Unknown PGP version.");
- return;
+ return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
+ pgpinfd, pgpoutfd, pgperrfd);
+}
+void pgp_v3_invoke_import(struct pgp_vinfo *pgp, const char *fname)
+{
+ char cmd[HUGE_STRING];
- }
+ snprintf(cmd, sizeof(cmd), "%sk +language=%s +pubring=%s +secring=%s -a --OutputInformationFD=1 %s",
+ NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), fname);
mutt_system(cmd);
}
-pid_t pgp_invoke_verify_key(FILE **pgpin, FILE **pgpout, FILE **pgperr,
- int pgpinfd, int pgpoutfd, int pgperrfd, const char *id)
+pid_t pgp_v3_invoke_export(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd, const char *id)
{
char cmd[HUGE_STRING];
- struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_VERIFY_KEY);
- if(!pgp)
- {
- mutt_error("Unknown PGP version.");
- return -1;
- }
+ snprintf(cmd, sizeof(cmd), "%sk -xa +language=%s +pubring=%s +secring=%s --OutputInformationFD=1 0x%8s",
+ NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), id);
+
+ return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
+ pgpinfd, pgpoutfd, pgperrfd);
+}
+
+pid_t pgp_v3_invoke_verify_key(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd, const char *id)
+{
+ char cmd[HUGE_STRING];
+
+ snprintf(cmd, sizeof(cmd), "%sk +language=%s +pubring=%s +secring=%s +batchmode -c --OutputInformationFD=1 0x%8s",
+ NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), id);
+
+ return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
+ pgpinfd, pgpoutfd, pgperrfd);
+}
+
+
+/*******************************************************************
+ *
+ * GNU Privacy Guard invocation stuff
+ *
+ * Credits go to Werner Koch for sending me the code on which this
+ * is based.
+ *
+ *******************************************************************/
+
+pid_t pgp_gpg_invoke_decode(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *fname, int need_passphrase)
+{
+ char cmd[HUGE_STRING];
+
+ snprintf(cmd, sizeof(cmd),
+ "%s%s --no-verbose -v --batch --status-fd 2 -o - "
+ "--decrypt %s",
+ NONULL(*pgp->binary), need_passphrase? " --passphrase-fd 0":"",
+ fname);
+
+ return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
+ pgpinfd, pgpoutfd, pgperrfd);
+}
+
+pid_t pgp_gpg_invoke_verify(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *signedstuff, const char *sigfile)
+{
+ char cmd[HUGE_STRING];
+
+ snprintf(cmd, sizeof(cmd),
+ "%s --no-verbose --batch --status-fd 2 -o - "
+ "--verify %s %s",
+ NONULL(*pgp->binary), sigfile, signedstuff);
+
+ return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
+ pgpinfd, pgpoutfd, pgperrfd);
+}
- switch(pgp->v)
+pid_t pgp_gpg_invoke_decrypt(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *fname)
+{
+ char cmd[HUGE_STRING];
+
+ snprintf(cmd, sizeof(cmd),
+ "%s --passphrase-fd 0 --no-verbose -v --batch --status-fd 2 -o - "
+ "--decrypt %s",
+ NONULL(*pgp->binary), fname );
+
+ return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
+ pgpinfd, pgpoutfd, pgperrfd);
+}
+
+static char *gpg_digalg(void)
+{
+ static char digalg[STRING];
+ if(PgpSignMicalg && !strncasecmp(PgpSignMicalg, "pgp-", 4))
+ strfcpy(digalg, PgpSignMicalg + 4, sizeof(digalg));
+ else
{
- case PGP_V2:
- snprintf(cmd, sizeof(cmd), "%s +language=%s +pubring=%s +secring=%s +batchmode -kcc 0x%8s",
- NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), id);
- break;
-
- case PGP_V3:
- snprintf(cmd, sizeof(cmd), "%sk +language=%s +pubring=%s +secring=%s +batchmode -c --OutputInformationFD=1 0x%8s",
- NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), id);
- break;
-
- default:
- mutt_error("Unknown PGP version.");
- return -1;
-
+ /* We use md5 here as the default value as it's the good
+ * old default value for PGP and will be used in the
+ * message's headers.
+ */
+
+ strcpy(digalg, "md5");
}
+ return digalg;
+}
+
+pid_t pgp_gpg_invoke_sign(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *fname)
+{
+ char cmd[HUGE_STRING];
+
+ snprintf(cmd, sizeof(cmd),
+ "%s --no-verbose -vv --batch --status-fd 2 -o - "
+ "--passphrase-fd 0 --digest-algo %s "
+ "--detach-sign --textmode --armor %s%s %s",
+ NONULL(*pgp->binary),
+ gpg_digalg(),
+ *PgpSignAs? "-u " : "",
+ *PgpSignAs? PgpSignAs : "", fname );
+
return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
pgpinfd, pgpoutfd, pgperrfd);
}
-pid_t pgp_invoke_extract_key(FILE **pgpin, FILE **pgpout, FILE **pgperr,
- int pgpinfd, int pgpoutfd, int pgperrfd, const char *id)
+
+pid_t pgp_gpg_invoke_encrypt(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *fname, const char *uids, int sign)
{
char cmd[HUGE_STRING];
- struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_EXTRACT_KEY);
+ char tmpcmd[HUGE_STRING];
+ char *cp;
+ char *keylist;
+
+ snprintf(cmd, sizeof(cmd),
+ "%s%s --no-verbose --batch --status-fd 2 -o - "
+ "--digest-algo %s "
+ "--encrypt%s --textmode --armor %s%s",
+ NONULL(*pgp->binary),
+ sign? " --passphrase-fd 0":"",
+ gpg_digalg(),
+ sign? " --sign":"",
+ *PgpSignAs? "-u " : "",
+ *PgpSignAs? PgpSignAs : "" );
+
+ keylist = safe_strdup(uids);
- if(!pgp)
+ for(cp = strtok(keylist, " "); cp ; cp = strtok(NULL, " "))
{
- mutt_error("Unknown PGP version.");
- return -1;
+ snprintf(tmpcmd, sizeof(tmpcmd), "%s -r %s",
+ cmd, cp);
+ strcpy(cmd, tmpcmd);
}
+ safe_free((void **) &keylist);
+ snprintf(tmpcmd, sizeof(tmpcmd), "%s %s", cmd, fname);
+ strcpy(cmd, tmpcmd);
+
+ return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
+ pgpinfd, pgpoutfd, pgperrfd);
+}
- switch(pgp->v)
- {
- case PGP_V2:
- snprintf(cmd, sizeof(cmd), "%s -kxaf +language=%s +pubring=%s +secring=%s 0x%8s",
- NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), id);
- break;
+void pgp_gpg_invoke_import(struct pgp_vinfo *pgp, const char *fname)
+{
+ mutt_error("pgp_gpg_invoke_import() has not yet been implemented.");
+}
+
+pid_t pgp_gpg_invoke_export(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd, const char *id)
+{
+ mutt_error("pgp_gpg_invoke_export() has not yet been implemented.");
+ return -1;
+}
- case PGP_V3:
- snprintf(cmd, sizeof(cmd), "%sk -xa +language=%s +pubring=%s +secring=%s --OutputInformationFD=1 0x%8s",
- NONULL (*pgp->binary), NONULL (*pgp->language), NONULL (*pgp->pubring), NONULL (*pgp->secring), id);
- break;
- default:
- mutt_error("Unknown PGP version.");
- return -1;
+pid_t pgp_gpg_invoke_verify_key(struct pgp_vinfo *pgp,
+ FILE **pgpin, FILE **pgpout, FILE **pgperr,
+ int pgpinfd, int pgpoutfd, int pgperrfd, const char *id)
+{
+ char cmd[HUGE_STRING];
- }
+ snprintf(cmd, sizeof(cmd),
+ "%sm --no-verbose --batch --fingerprint --check-sigs %s%s",
+ NONULL(*pgp->binary), (strlen(id)==8 || strlen(id)==16)? "0x":"", id );
return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr,
pgpinfd, pgpoutfd, pgperrfd);
/*
* Copyright (C) 1996,1997 Michael R. Elkins <me@cs.hmc.edu>
+ * Copyright (c) 1998 Thomas Roessler <roessler@guug.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
return strcasecmp(pgp_keyid(s->k), pgp_keyid(t->k));
}
-static KEYINFO *pgp_select_key (LIST *keys, ADDRESS *p, const char *s)
+static KEYINFO *pgp_select_key (struct pgp_vinfo *pgp,
+ LIST *keys,
+ ADDRESS *p, const char *s)
{
int keymax;
pgp_key_t *KeyTable;
mutt_message ("Invoking PGP...");
- if((thepid = pgp_invoke_verify_key(NULL, NULL, NULL, -1,
+ if((thepid = pgp->invoke_verify_key(pgp, NULL, NULL, NULL, -1,
fileno(fp), fileno(devnull),
pgp_keyid(KeyTable[menu->current].k))) == -1)
{
return (info);
}
-char *pgp_ask_for_key (const char *ringfile, KEYINFO *udb, char *tag, char *whatfor,
+char *pgp_ask_for_key (struct pgp_vinfo *pgp, KEYINFO *db, char *tag, char *whatfor,
short abilities, char **alg)
{
- KEYINFO *db;
KEYINFO *key;
char *key_id;
char resp[SHORT_STRING];
struct pgp_cache *l = NULL;
- db = udb ? udb : pgp_read_keyring(ringfile);
-
resp[0] = 0;
if (whatfor)
{
FOREVER
{
if (mutt_get_field (tag, resp, sizeof (resp), M_CLEAR) != 0)
- {
- if (!udb) pgp_closedb (db);
return NULL;
- }
if (whatfor)
{
}
}
- if ((key = ki_getkeybystr (resp, db, abilities)))
+ if ((key = ki_getkeybystr (pgp, resp, db, abilities)))
{
key_id = safe_strdup(pgp_keyid (key));
if (alg)
*alg = safe_strdup(pgp_pkalg_to_mic(key->algorithm));
- if (!udb) pgp_closedb (db);
return (key_id);
}
BEEP ();
FILE *devnull;
struct stat sb;
pid_t thepid;
+ KEYINFO *db;
+ struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_EXPORT);
+ if(!pgp)
+ return NULL;
+
unset_option (OPTPGPCHECKTRUST);
- if (!(id = pgp_ask_for_key (pgp_pubring(PGP_EXTRACT),
- NULL, "Please enter the key ID: ", NULL, 0, NULL)))
+ db = pgp->read_pubring(pgp);
+ id = pgp_ask_for_key (pgp, db, "Please enter the key ID: ", NULL, 0, NULL);
+ pgp_close_keydb(&db);
+
+ if(!id)
return NULL;
if (!tempf) {
return NULL;
}
- if ((thepid = pgp_invoke_extract_key(NULL, NULL, NULL, -1,
- fileno(tempfp), fileno(devnull), id)) == -1)
+ if ((thepid = pgp->invoke_export(pgp,
+ NULL, NULL, NULL, -1,
+ fileno(tempfp), fileno(devnull), id)) == -1)
{
mutt_perror ("Can't create filter");
unlink (tempf);
return NULL;
}
-KEYINFO *ki_getkeybyaddr (ADDRESS *a, KEYINFO *k, short abilities)
+KEYINFO *ki_getkeybyaddr (struct pgp_vinfo *pgp,
+ ADDRESS *a, KEYINFO *k, short abilities)
{
ADDRESS *r, *p;
LIST *l = NULL, *t = NULL;
if (l->next || weak)
{
/* query for which key the user wants */
- k = pgp_select_key (l, a, NULL);
+ k = pgp_select_key (pgp, l, a, NULL);
}
else
k = (KEYINFO *)l->data;
return (k);
}
-KEYINFO *ki_getkeybystr (char *p, KEYINFO *k, short abilities)
+KEYINFO *ki_getkeybystr (struct pgp_vinfo *pgp,
+ char *p, KEYINFO *k, short abilities)
{
LIST *t = NULL, *l = NULL;
LIST *a;
if (l)
{
- k = pgp_select_key (l, NULL, p);
+ k = pgp_select_key (pgp, l, NULL, p);
set_option(OPTNEEDREDRAW);
for(t = l; t; t = t->next)
}
-KEYINFO *pgp_read_keyring(const char *fname)
+static KEYINFO *pgp_read_keyring(const char *fname)
{
FILE *fp;
unsigned char *buff;
return db;
}
-void pgp_closedb (KEYINFO *k)
+KEYINFO *pgp_read_pubring(struct pgp_vinfo *pgp)
{
- KEYINFO *tmp;
- LIST *q;
+ return pgp_read_keyring(NONULL(*pgp->pubring));
+}
+
+KEYINFO *pgp_read_secring(struct pgp_vinfo *pgp)
+{
+ return pgp_read_keyring(NONULL(*pgp->secring));
+}
+void pgp_close_keydb (KEYINFO **ki)
+{
+ KEYINFO *tmp, *k = *ki;
+ LIST *q;
+
while (k)
{
if (k->keyid) safe_free ((void **)&k->keyid);
k = k->next;
safe_free ((void **)&tmp);
}
+ *ki = NULL;
}
/*
- * Copyright (C) 1996,1997 Michael R. Elkins <me@cs.hmc.edu>
+ * Copyright (C) 1996-1998 Michael R. Elkins <me@cs.hmc.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by