]> granicus.if.org Git - mutt/commitdiff
GPG support, first take.
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 8 Jun 1998 20:05:39 +0000 (20:05 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 8 Jun 1998 20:05:39 +0000 (20:05 +0000)
16 files changed:
Makefile.in
acconfig.h
compose.c
config.h.in
configure
configure.in
gnupgparse.c [new file with mode: 0644]
init.c
init.h
main.c
pgp.c
pgp.h
pgpinvoke.c
pgpkey.c
pgppubring.c
recvattach.c

index 0fe9f8a50d775b8799ece8039ac89889092e5039..0cb4d8ccce92c5b9775c5b9c80758605a4cd972c 100644 (file)
@@ -52,7 +52,7 @@ DISTCLEANFILES=$(VERYCLEANFILES) tags keymap_defs.h *.rej *.orig *~ Makefile.bak
 
 # 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
index d7dd17cdce90cc9f306dadc82239e50224ca5349..1e79d39a7ccdef5bc3924f00fb286a566fa75b29 100644 (file)
 /* 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
 
index 68cbf001452027d77d3a0e75f14cd819ef7a1306..285a4d37d6ca2cd616bd4925b141a3b321bed0f7 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -120,6 +120,9 @@ static int pgp_send_menu (int bits)
   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 ();
@@ -131,17 +134,36 @@ static int pgp_send_menu (int bits)
     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')
@@ -160,7 +182,8 @@ static int pgp_send_menu (int bits)
          {
            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);
          }
@@ -190,10 +213,6 @@ static int pgp_send_menu (int bits)
 
 
 
-
-
-
-
 static void draw_envelope (HEADER *msg, char *fcc)
 {
   char buf[STRING];
index efc45ee95a31eaedd7e812ad207f3d54451da0d4..cc48687e2281c2ccc1c1c8c0149b1442a76b2b82 100644 (file)
 /* 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
 
index c5f1cece787cd463b4656d50923bb74bebcb7981..972ad99fb3c5642f4b0f6b02fd586add00c790bd 100755 (executable)
--- a/configure
+++ b/configure
@@ -885,10 +885,55 @@ OPS='$(srcdir)/OPS'
 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
@@ -933,7 +978,7 @@ EOF
        # 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
@@ -982,7 +1027,7 @@ EOF
        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
@@ -997,7 +1042,7 @@ EOF
 # 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
@@ -1034,7 +1079,7 @@ EOF
 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=
@@ -1049,13 +1094,13 @@ else
   # 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
   :
@@ -1066,13 +1111,13 @@ else
   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
   :
@@ -1098,7 +1143,7 @@ echo "$ac_t""$CPP" 1>&6
 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
@@ -1106,7 +1151,7 @@ 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>
 
@@ -1119,7 +1164,7 @@ main ()
 #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
@@ -1136,7 +1181,7 @@ fi
 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
@@ -1182,16 +1227,16 @@ EOF
        
                
        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
@@ -1219,7 +1264,7 @@ fi
 
 
        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
@@ -1227,7 +1272,7 @@ else
   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
@@ -1238,7 +1283,7 @@ int main() {
 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
@@ -1261,17 +1306,17 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
 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*
@@ -1312,12 +1357,12 @@ fi
 
 
        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.  */
@@ -1340,7 +1385,7 @@ start_color();
 
 ; 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
@@ -1365,12 +1410,12 @@ fi
        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.  */
@@ -1393,7 +1438,7 @@ $ac_func();
 
 ; 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
@@ -1420,12 +1465,12 @@ done
        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.  */
@@ -1448,7 +1493,7 @@ $ac_func();
 
 ; 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
@@ -1477,12 +1522,12 @@ fi
 
 
 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>
@@ -1490,7 +1535,7 @@ else
 #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*
@@ -1507,7 +1552,7 @@ rm -f 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
@@ -1525,7 +1570,7 @@ fi
 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
@@ -1546,7 +1591,7 @@ if test "$cross_compiling" = yes; then
   :
 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')
@@ -1557,7 +1602,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 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
@@ -1585,17 +1630,17 @@ for ac_hdr in stdarg.h sys/ioctl.h
 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*
@@ -1623,12 +1668,12 @@ done
 
 
 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>
@@ -1645,7 +1690,7 @@ int main() {
 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
@@ -1665,12 +1710,12 @@ EOF
 
 
 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>
@@ -1682,7 +1727,7 @@ int main() {
 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
@@ -1704,7 +1749,7 @@ fi
 
 
 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
@@ -1712,7 +1757,7 @@ 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()
@@ -1723,7 +1768,7 @@ 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
@@ -1744,12 +1789,12 @@ EOF
 
 
 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
@@ -1780,12 +1825,12 @@ fi
 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.  */
@@ -1808,7 +1853,7 @@ $ac_func();
 
 ; 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
@@ -1836,12 +1881,12 @@ done
 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.  */
@@ -1864,7 +1909,7 @@ $ac_func();
 
 ; 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
@@ -1893,12 +1938,12 @@ done
 
 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.  */
@@ -1921,7 +1966,7 @@ snprintf();
 
 ; 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
@@ -1945,12 +1990,12 @@ mutt_cv_snprintf=yes
 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.  */
@@ -1973,7 +2018,7 @@ vsnprintf();
 
 ; 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
@@ -2003,12 +2048,12 @@ fi
 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.  */
@@ -2031,7 +2076,7 @@ $ac_func();
 
 ; 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
@@ -2053,7 +2098,7 @@ EOF
 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
@@ -2061,7 +2106,7 @@ else
   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
@@ -2072,7 +2117,7 @@ int main() {
 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
@@ -2106,12 +2151,12 @@ done
 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.  */
@@ -2134,7 +2179,7 @@ $ac_func();
 
 ; 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
@@ -2156,7 +2201,7 @@ EOF
 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
@@ -2164,7 +2209,7 @@ else
   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
@@ -2175,7 +2220,7 @@ int main() {
 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
@@ -2228,12 +2273,12 @@ 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.  */
@@ -2256,7 +2301,7 @@ $ac_func();
 
 ; 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
@@ -2327,7 +2372,7 @@ if test "${with_mailpath+set}" = set; then
   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
@@ -2356,7 +2401,7 @@ EOF
 
 
        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
@@ -2364,7 +2409,7 @@ 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>
@@ -2378,7 +2423,7 @@ int main (int argc, char **argv)
        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
@@ -2403,7 +2448,7 @@ EOF
        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
@@ -2411,7 +2456,7 @@ 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>
@@ -2425,7 +2470,7 @@ int main (int argc, char **argv)
        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
@@ -2461,7 +2506,7 @@ if test "${with_sharedir+set}" = set; then
   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
@@ -2529,7 +2574,7 @@ if test "${enable_pop+set}" = set; then
 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
@@ -2537,7 +2582,7 @@ else
   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
@@ -2548,7 +2593,7 @@ int main() {
 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
@@ -2576,7 +2621,7 @@ 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
@@ -2584,7 +2629,7 @@ else
   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
@@ -2595,7 +2640,7 @@ int main() {
 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
@@ -2635,7 +2680,7 @@ if test "${enable_imap+set}" = set; then
 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
@@ -2643,7 +2688,7 @@ else
   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
@@ -2654,7 +2699,7 @@ int main() {
 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
@@ -2682,7 +2727,7 @@ 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
@@ -2690,7 +2735,7 @@ else
   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
@@ -2701,7 +2746,7 @@ int main() {
 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
@@ -2970,6 +3015,7 @@ s%@SET_MAKE@%$SET_MAKE%g
 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
index aa620bbc734060304ea3de564a24ec7bc3870b31..7c854686855f8b6f5c0d32f777e739b34d75f091 100644 (file)
@@ -23,6 +23,14 @@ OPS='$(srcdir)/OPS'
 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,.$,,'`
@@ -43,7 +51,7 @@ if test -f $srcdir/pgp.c; then
        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
diff --git a/gnupgparse.c b/gnupgparse.c
new file mode 100644 (file)
index 0000000..3897282
--- /dev/null
@@ -0,0 +1,224 @@
+/*
+ * 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;
+}
diff --git a/init.c b/init.c
index accc95d84d50f9a034583743d30c28dae9c3f55a..d4ae189773be80bae1abf97e5788477796e086c0 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1400,6 +1400,10 @@ void mutt_init (int skip_sys_rc, LIST *commands)
     PgpV3Secring = safe_strdup (buffer);
   }
 #endif
+  
+#ifdef _PGPGPGPATH
+  PgpGpg = safe_strdup (_PGPGPGPATH);
+#endif
 
 #endif /* _PGPPATH */
   
diff --git a/init.h b/init.h
index 5f5e9df66f6276104dd435df643dca8d4a7a0d1d..452b4988b1f02240d2395dfeb627983703dfd5a0 100644 (file)
--- a/init.h
+++ b/init.h
@@ -177,21 +177,27 @@ struct option_t MuttVars[] = {
   { "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" },
diff --git a/main.c b/main.c
index a8369e16e3a17def94a06f8f7e5455943edaf120..2bea7ce7524fba2b03a006340e727cc41b8ab63f 100644 (file)
--- a/main.c
+++ b/main.c
@@ -202,6 +202,9 @@ static void show_version (void)
 #ifdef HAVE_PGP2
        "+HAVE_PGP2  "
 #endif
+#ifdef HAVE_GPG
+       "+HAVE_GPG   "
+#endif
 #endif
 
 
@@ -241,6 +244,9 @@ static void show_version (void)
 # ifdef _PGPV3PATH
   printf ("_PGPV3PATH=\"%s\"\n", _PGPV3PATH);
 # endif
+# ifdef _PGPGPPATH
+  pritnf ("_PGPGPGPATH=\"%s\"\n", _PGPGPGPATH);
+# endif
 #endif
 
 
diff --git a/pgp.c b/pgp.c
index 881f325a8333b547f28ff879b7b6204e8b2b77de..36e4497bcaae508466fe180b7b9e998cf82bb6d9 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -1,5 +1,6 @@
 /*
  * 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
@@ -46,10 +47,51 @@ static time_t PgpExptime = 0; /* when does the cached passphrase expire? */
 
 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
@@ -65,8 +107,8 @@ pgp_opvers[] =
   { 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              }
 };
 
@@ -109,6 +151,7 @@ struct pgp_vinfo *pgp_get_vinfo(enum pgp_ops op)
 {
   int i;
   char *version = "default";
+  char msg[LONG_STRING];
   
   for(i = 0; pgp_opvers[i].op != PGP_LAST_OP; i++)
   {
@@ -127,31 +170,14 @@ struct pgp_vinfo *pgp_get_vinfo(enum pgp_ops op)
     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)
@@ -203,8 +229,11 @@ void application_pgp_handler (BODY *m, STATE *s)
   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;
   
@@ -279,8 +308,12 @@ void application_pgp_handler (BODY *m, STATE *s)
 
        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);
@@ -513,6 +546,10 @@ void pgp_signed_handler (BODY *a, STATE *s)
   int hadcr;
   int c;
   pid_t thepid;
+  struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_VERIFY);
+  
+  if(!pgp)
+    return;
   
   a = a->parts;
 
@@ -583,8 +620,10 @@ void pgp_signed_handler (BODY *a, STATE *s)
       
       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);
@@ -627,6 +666,10 @@ void pgp_extract_keys_from_messages (HEADER *h)
   int i;
   STATE s;
   char tempfname[_POSIX_PATH_MAX];
+  struct pgp_vinfo *pgp = pgp_get_vinfo(PGP_IMPORT);
+  
+  if(!pgp)
+    return;
   
   if(h)
   {
@@ -676,7 +719,7 @@ void pgp_extract_keys_from_messages (HEADER *h)
       
   fclose(s.fpout);
   endwin();
-  pgp_invoke_extract(tempfname);
+  pgp->invoke_import(pgp, tempfname);
   mutt_any_key_to_continue(NULL);
 
   bailout:
@@ -686,7 +729,8 @@ void pgp_extract_keys_from_messages (HEADER *h)
   
 }
 
-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;
@@ -708,7 +752,7 @@ static void pgp_extract_keys_from_attachment(FILE *fp, BODY *top)
 
   fclose(tempfp);
 
-  pgp_invoke_extract(tempfname);
+  pgp->invoke_import(pgp, tempfname);
   mutt_any_key_to_continue(NULL);
 
   mutt_unlink(tempfname);
@@ -717,6 +761,11 @@ static void pgp_extract_keys_from_attachment(FILE *fp, BODY *top)
 
 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>.");
@@ -729,7 +778,7 @@ void pgp_extract_keys_from_attachment_list (FILE *fp, int tag, BODY *top)
   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;
@@ -748,7 +797,11 @@ BODY *pgp_decrypt_part (BODY *a, STATE *s, FILE *fpout)
   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)
   {
@@ -773,7 +826,7 @@ BODY *pgp_decrypt_part (BODY *a, STATE *s, FILE *fpout)
   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);
@@ -933,7 +986,11 @@ BODY *pgp_sign_message (BODY *a)
   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);
@@ -956,7 +1013,7 @@ BODY *pgp_sign_message (BODY *a)
   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!");
@@ -1053,7 +1110,6 @@ BODY *pgp_sign_message (BODY *a)
  */
 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;
@@ -1063,8 +1119,12 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
   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++) 
   {
@@ -1085,15 +1145,15 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
 
   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;
@@ -1109,7 +1169,7 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
     keylist_used = strlen (keylist);
   }
   rfc822_free_address (&tmp);
-  pgp_closedb (db);
+  pgp_close_keydb (&db);
   return (keylist);
 }
 
@@ -1124,6 +1184,10 @@ BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
   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)
@@ -1160,9 +1224,9 @@ BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
   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);
diff --git a/pgp.h b/pgp.h
index 80af9915b0bf51d4a022e4d42f2217ae0c273d68..e96b2fb6dde64db89ea94fcace966ac8f7b39da5 100644 (file)
--- a/pgp.h
+++ b/pgp.h
@@ -53,7 +53,8 @@ typedef struct pgp_uid
 enum pgp_version 
 {
   PGP_V2, 
-  PGP_V3, 
+  PGP_V3,
+  PGP_GPG,
   PGP_UNKNOWN
 };
 
@@ -64,20 +65,59 @@ enum pgp_ops
   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 *);
+  
 };
 
 
@@ -91,6 +131,15 @@ WHERE char *PgpV3Language;
 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;
@@ -108,14 +157,11 @@ BODY *pgp_make_key_attachment (char *);
 
 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);
@@ -125,13 +171,16 @@ int pgp_protect (HEADER *);
 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);
@@ -141,15 +190,173 @@ void pgp_void_passphrase (void);
 #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 */
index 81823b13bfb1a811353651e0972301eb28548d12..d69c3800143b907dc0c58f3f7b53f50fb648e061 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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);
index 9b6de3d3e95a6f56e9ddefd19cf652cbd49466dc..9cb2a61eb61bd1d1fe1e0db15343662f627f74f6 100644 (file)
--- a/pgpkey.c
+++ b/pgpkey.c
@@ -1,5 +1,6 @@
 /*
  * 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
@@ -106,7 +107,9 @@ static int pgp_compare (const void *a, const void *b)
     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;
@@ -216,7 +219,7 @@ static KEYINFO *pgp_select_key (LIST *keys, ADDRESS *p, const char *s)
 
        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)
         {
@@ -283,17 +286,14 @@ static KEYINFO *pgp_select_key (LIST *keys, ADDRESS *p, const char *s)
   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) 
   {
@@ -310,10 +310,7 @@ char *pgp_ask_for_key (const char *ringfile, KEYINFO *udb, char *tag, char *what
   FOREVER
   {
     if (mutt_get_field (tag, resp, sizeof (resp), M_CLEAR) != 0)
-    {
-      if (!udb) pgp_closedb (db);
       return NULL;
-    }
     
     if (whatfor) 
     {
@@ -332,14 +329,13 @@ char *pgp_ask_for_key (const char *ringfile, KEYINFO *udb, char *tag, char *what
       }
     }
 
-    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 ();
@@ -359,11 +355,19 @@ BODY *pgp_make_key_attachment (char * tempf)
   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) {
@@ -385,8 +389,9 @@ BODY *pgp_make_key_attachment (char * 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);
@@ -437,7 +442,8 @@ static char *mutt_stristr (char *haystack, char *needle)
   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;
@@ -510,7 +516,7 @@ KEYINFO *ki_getkeybyaddr (ADDRESS *a, KEYINFO *k, short abilities)
     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;
@@ -526,7 +532,8 @@ KEYINFO *ki_getkeybyaddr (ADDRESS *a, KEYINFO *k, short abilities)
   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;
@@ -572,7 +579,7 @@ KEYINFO *ki_getkeybystr (char *p, KEYINFO *k, short abilities)
 
   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)
index 8e24be2830990c18235711f723a046455e68ed5c..16bf68b22d3849b53c80257c693b6a8c675962f2 100644 (file)
@@ -719,7 +719,7 @@ static int pgp_parse_sig(unsigned char *buff, size_t l, KEYINFO *p)
 }
 
   
-KEYINFO *pgp_read_keyring(const char *fname)
+static KEYINFO *pgp_read_keyring(const char *fname)
 {
   FILE *fp;
   unsigned char *buff;
@@ -821,11 +821,21 @@ KEYINFO *pgp_read_keyring(const char *fname)
   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);
@@ -835,4 +845,5 @@ void pgp_closedb (KEYINFO *k)
     k = k->next;
     safe_free ((void **)&tmp);
   }
+  *ki = NULL;
 }
index c42123424a1dfa67d280eec866c1469fbf5c6352..670bf495b1d8180d9f9928029bf0206a6775dca2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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