Changeset 3663:e5ec22eb5a6d

Show
Ignore:
Timestamp:
2004-06-17 13:36:13 (5 years ago)
Author:
Moritz Schulte <moritz@…>
Branch:
HEAD
Message:

This is the sequel to the crypto modularization changes I did on
2003-01-21. Moritz added another abstraction layer which cleans up
the code and allows the crypto modules to use their own option menu.
Everything should work as it used to but is now in a really good
shape for part III, the Return of the GnuPG Easy Makers. -wk

* crypt-mod-pgp-classic.c, crypt-mod-smime-classic.c, crypt-mod.c,
crypt-mod.h: New files.

* smime.c (smime_valid_passphrase, smime_send_menu): New functions.
* smime.h: Removed macro: smime_valid_passphrase.
Declared: smime_valid_passphrase, smime_send_menu.
* pgp.c: Include "mutt_menu.h".
(pgp_valid_passphrase, pgp_send_menu): New functions.
* pgp.h: Removed macro: pgp_valid_passphrase.
Declared: pgp_valid_passphrase, pgp_send_menu.
* mutt_curses.h: Declare: mutt_need_hard_redraw.
* mutt_crypt.h: Declare: crypt_pgp_valid_passphrase,
crypt_pgp_send_menu, crypt_smime_valid_passphrase,
crypt_smime_send_menu, crypt_init.
Adjust WithCrypto? definition since the GPGME backend does not
exclude anymore the other `classic' backends.
(KEYFLAG_ISX509): New symbol.
* mutt.h (enum): New symbol: OPTCRYPTUSEGPGME.
(struct body): New member: is_signed_data, warnsig.
* main.c (main): Call crypt_init.
* keymap.c (km_get_table): Support for MENU_KEY_SELECT_PGP and
MENU_KEY_SELECT_SMIME.
(Menus): Added entries fuer MENU_KEY_SELECT_PGP and
MENU_KEY_SELECT_SMIME.
(km_init): Create bindings for MENU_KEY_SELECT_PGP and
MENU_KEY_SELECT_SMIME.
* keymap.h (enum): New enum symbols: MENU_KEY_SELECT_PGP,
MENU_KEY_SELECT_SMIME.
* init.h: New configuration variable: crypt_use_gpgme.
* compose.c (pgp_send_menu, smime_send_menu): Removed functions,
they are now contained in the crypto backend modules.
(mutt_compose_menu): Use crypt_pgp_send_menu and
crypt_smime_send_menu instead pgp_send_menu and smime_send_menu.
* cryptglue.c: Slightly rewritten in order to make use of the
module mechanism used to access crypto backends.
* curs_lib.c (mutt_need_hard_redraw): New function.
* crypt.c (crypt_forget_passphrase): Adjust for new crypto backend
interface.
(crypt_valid_passphrase): Stripped, use calls to
crypt_pgp_valid_passphrase and crypt_smime_valid_passphrase.

Files:
4 added
17 modified

Legend:

Unmodified
Added
Removed
  • Makefile.am

    r3511 r3663  
    2929        status.c system.c thread.c charset.c history.c lib.c \ 
    3030        muttlib.c editmsg.c utf8.c mbyte.c wcwidth.c \ 
    31         url.c ascii.c mutt_idna.c 
     31        url.c ascii.c mutt_idna.c crypt-mod.c crypt-mod.h 
    3232 
    3333mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \ 
    34         $(INTLLIBS) $(LIBICONV) 
     34        $(INTLLIBS) $(LIBICONV)  
    3535 
    3636mutt_DEPENDENCIES = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAPDEPS) \ 
     
    5656INCLUDES=-I. -I$(top_srcdir) $(IMAP_INCLUDES) -Iintl 
    5757 
    58 CPPFLAGS=@CPPFLAGS@ -I$(includedir) 
     58CPPFLAGS=@CPPFLAGS@ -I$(includedir) -D_FILE_OFFSET_BITS=64 
    5959 
    6060 
     
    6363        pgplib.c sha1.c pgpmicalg.c gnupgparse.c resize.c dotlock.c remailer.c \ 
    6464        browser.h mbyte.h remailer.h url.h mutt_ssl_nss.c \ 
     65        crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \ 
    6566        pgppacket.c mutt_idna.h 
    6667 
  • compose.c

    r3652 r3663  
    11/* 
    22 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org> 
     3 * Copyright (C) 2004 g10 Code GmbH 
    34 *  
    45 *     This program is free software; you can redistribute it and/or modify 
     
    160161      off = 20; 
    161162  } 
    162 } 
    163  
    164  
    165  
    166 static int pgp_send_menu (HEADER *msg, int *redraw) 
    167 { 
    168   pgp_key_t p; 
    169   char input_signas[SHORT_STRING]; 
    170  
    171   if (!(WithCrypto & APPLICATION_PGP)) 
    172     return msg->security; 
    173  
    174   switch (mutt_multi_choice (_("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "), 
    175                              _("esabif"))) 
    176   { 
    177   case 1: /* (e)ncrypt */ 
    178     msg->security ^= ENCRYPT; 
    179     break; 
    180  
    181   case 2: /* (s)ign */ 
    182     msg->security ^= SIGN; 
    183     break; 
    184  
    185   case 3: /* sign (a)s */ 
    186     unset_option(OPTPGPCHECKTRUST); 
    187  
    188     if ((p = crypt_pgp_ask_for_key (_("Sign as: "), NULL, 
    189                                     KEYFLAG_CANSIGN, PGP_PUBRING))) 
    190     { 
    191       snprintf (input_signas, sizeof (input_signas), "0x%s", 
    192                 crypt_pgp_keyid (p)); 
    193       mutt_str_replace (&PgpSignAs, input_signas); 
    194       crypt_pgp_free_key (&p); 
    195        
    196       msg->security |= SIGN; 
    197          
    198       crypt_pgp_void_passphrase ();  /* probably need a different passphrase */ 
    199     } 
    200     else 
    201     { 
    202       msg->security &= ~SIGN; 
    203     } 
    204  
    205     *redraw = REDRAW_FULL; 
    206     break; 
    207  
    208   case 4: /* (b)oth */ 
    209     if ((msg->security & (ENCRYPT | SIGN)) == (ENCRYPT | SIGN)) 
    210       msg->security = 0; 
    211     else 
    212       msg->security |= (ENCRYPT | SIGN); 
    213     break; 
    214  
    215   case 5: /* (i)nline */ 
    216     if ((msg->security & (ENCRYPT | SIGN))) 
    217       msg->security ^= INLINE; 
    218     else 
    219       msg->security &= ~INLINE; 
    220     break; 
    221  
    222   case 6: /* (f)orget it */ 
    223     msg->security = 0; 
    224     break; 
    225   } 
    226  
    227   if (msg->security) 
    228   { 
    229     if (! (msg->security & (ENCRYPT | SIGN))) 
    230       msg->security = 0; 
    231     else 
    232       msg->security |= APPLICATION_PGP; 
    233   } 
    234  
    235   if(*redraw) 
    236       redraw_crypt_lines (msg); 
    237   return (msg->security); 
    238 } 
    239  
    240  
    241  
    242 static int smime_send_menu (HEADER *msg, int *redraw) 
    243 { 
    244   char *p; 
    245  
    246   if (!(WithCrypto & APPLICATION_SMIME)) 
    247     return msg->security; 
    248  
    249   switch (mutt_multi_choice (_("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (f)orget it? "), 
    250                              _("eswabf"))) 
    251   { 
    252   case 1: /* (e)ncrypt */ 
    253     msg->security |= ENCRYPT; 
    254     break; 
    255  
    256   case 3: /* encrypt (w)ith */ 
    257     msg->security |= ENCRYPT; 
    258     switch (mutt_multi_choice (_("1: DES, 2: Triple-DES, 3: RC2-40," 
    259                                  " 4: RC2-64, 5: RC2-128, or (f)orget it? "), 
    260                                _("12345f"))) { 
    261     case 1: 
    262         mutt_str_replace (&SmimeCryptAlg, "des"); 
    263         break; 
    264     case 2: 
    265         mutt_str_replace (&SmimeCryptAlg, "des3"); 
    266         break; 
    267     case 3: 
    268         mutt_str_replace (&SmimeCryptAlg, "rc2-40"); 
    269         break; 
    270     case 4: 
    271         mutt_str_replace (&SmimeCryptAlg, "rc2-64"); 
    272         break; 
    273     case 5: 
    274         mutt_str_replace (&SmimeCryptAlg, "rc2-128"); 
    275         break; 
    276     case 6: /* forget it */ 
    277         break; 
    278     } 
    279     break; 
    280  
    281   case 2: /* (s)ign */ 
    282        
    283     if(!SmimeDefaultKey) 
    284         mutt_message("Can\'t sign: No key specified. use sign(as)."); 
    285     else 
    286         msg->security |= SIGN; 
    287     break; 
    288  
    289   case 4: /* sign (a)s */ 
    290  
    291     if ((p = crypt_smime_ask_for_key (_("Sign as: "), NULL, 0))) { 
    292       p[mutt_strlen (p)-1] = '\0'; 
    293       mutt_str_replace (&SmimeDefaultKey, p); 
    294          
    295       msg->security |= SIGN; 
    296  
    297       /* probably need a different passphrase */ 
    298       crypt_smime_void_passphrase (); 
    299     } 
    300     else 
    301       msg->security &= ~SIGN; 
    302  
    303     *redraw = REDRAW_FULL; 
    304     break; 
    305  
    306   case 5: /* (b)oth */ 
    307     msg->security = ENCRYPT | SIGN; 
    308     break; 
    309  
    310   case 6: /* (f)orget it */ 
    311     msg->security = 0; 
    312     break; 
    313   } 
    314  
    315   if (msg->security && msg->security != APPLICATION_SMIME) 
    316     msg->security |= APPLICATION_SMIME; 
    317   else 
    318     msg->security = 0; 
    319  
    320   if(*redraw) 
    321       redraw_crypt_lines (msg); 
    322   return (msg->security); 
    323163} 
    324164 
     
    13451185          msg->security = 0; 
    13461186        } 
    1347         msg->security = pgp_send_menu (msg, &menu->redraw); 
     1187        msg->security = crypt_pgp_send_menu (msg, &menu->redraw); 
    13481188        redraw_crypt_lines (msg); 
    13491189        break; 
     
    13701210          msg->security = 0; 
    13711211        } 
    1372         msg->security = smime_send_menu(msg, &menu->redraw); 
     1212        msg->security = crypt_smime_send_menu(msg, &menu->redraw); 
    13731213        redraw_crypt_lines (msg); 
    13741214        break; 
  • configure.in

    r3528 r3663  
    106106                    [ Define if you want classic PGP support. ]) 
    107107                PGPAUX_TARGET="pgpring pgpewrap" 
    108                 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS pgp.o pgpinvoke.o pgpkey.o pgplib.o gnupgparse.o pgpmicalg.o pgppacket.o" 
     108                MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS pgp.o pgpinvoke.o pgpkey.o pgplib.o gnupgparse.o pgpmicalg.o pgppacket.o crypt-mod-pgp-classic.o" 
    109109        fi 
    110110 
     
    118118                AC_DEFINE(CRYPT_BACKEND_CLASSIC_SMIME,1, 
    119119                  [ Define if you want clasic S/MIME support. ]) 
    120                 MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS smime.o " 
     120                MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS smime.o crypt-mod-smime-classic.o" 
    121121                SMIMEAUX_TARGET="smime_keys" 
    122122        fi 
  • crypt.c

    r3656 r3663  
    55 *                     Oliver Ehli <elmy@acm.org> 
    66 * Copyright (C) 2003  Werner Koch <wk@gnupg.org> 
     7 * Copyright (C) 2004 g10code GmbH 
    78 * 
    89 *     This program is free software; you can redistribute it and/or modify 
     
    108109{ 
    109110  time_t now = time (NULL); 
     111  int ret = 0; 
    110112 
    111113# if defined(HAVE_SETRLIMIT) &&(!defined(DEBUG)) 
     
    114116 
    115117  if ((WithCrypto & APPLICATION_PGP) && (flags & APPLICATION_PGP)) 
    116   { 
    117     extern char PgpPass[STRING]; 
    118     extern time_t PgpExptime; 
    119  
    120     if (pgp_use_gpg_agent()) 
    121     { 
    122       *PgpPass = 0; 
    123       return 1; /* handled by gpg-agent */ 
    124     } 
    125  
    126     if (now < PgpExptime) return 1; /* just use the cached copy. */ 
    127     crypt_pgp_void_passphrase (); 
    128        
    129     if (mutt_get_password (_("Enter PGP passphrase:"), 
    130                            PgpPass, sizeof (PgpPass)) == 0) 
    131     { 
    132       PgpExptime = time (NULL) + PgpTimeout; 
    133       return (1); 
    134     } 
    135     else 
    136       PgpExptime = 0; 
    137     } 
     118    ret = crypt_pgp_valid_passphrase (); 
    138119 
    139120  if ((WithCrypto & APPLICATION_SMIME) && (flags & APPLICATION_SMIME)) 
    140   { 
    141     extern char SmimePass[STRING]; 
    142     extern time_t SmimeExptime; 
    143  
    144     if (now < SmimeExptime) return (1); 
    145     crypt_smime_void_passphrase (); 
    146        
    147     if (mutt_get_password (_("Enter SMIME passphrase:"), SmimePass, 
    148                            sizeof (SmimePass)) == 0) 
    149     { 
    150       SmimeExptime = time (NULL) + SmimeTimeout; 
    151       return (1); 
    152     } 
    153     else 
    154       SmimeExptime = 0; 
    155   } 
    156  
    157   return (0); 
     121    ret = crypt_smime_valid_passphrase (); 
     122 
     123  return ret; 
    158124} 
    159125 
     
    276242      /* destroy temporary signature envelope when doing retainable  
    277243       * signatures. 
     244 
    278245       */ 
    279246      if (flags != msg->security) 
  • cryptglue.c

    r3271 r3663  
    11/* 
    22 * Copyright (C) 2003  Werner Koch <wk@gnupg.org> 
     3 * Copyright (C) 2004 g10 Code GmbH 
    34 * 
    45 *     This program is free software; you can redistribute it and/or modify 
     
    1819 
    1920/* 
    20    This file dispatches the generic crytpo functions to the implemented 
    21    backend or provides dummy stubs.  Note, that some generic functions are 
    22    handled in crypt.c. 
     21   This file dispatches the generic crypto functions to the 
     22   implemented backend or provides dummy stubs.  Note, that some 
     23   generic functions are handled in crypt.c. 
    2324*/ 
     25 
     26/* Note: This file has been changed to make use of the new module 
     27   system.  Consequently there's a 1:1 mapping between the functions 
     28   contained in this file and the functions implemented by the crypto 
     29   modules.  */ 
    2430 
    2531#include "mutt.h" 
    2632#include "mutt_crypt.h" 
    2733 
    28 /* Make sure those macros are not defined. */ 
    29 #undef BFNC_PGP_VOID_PASSPHRASE      
    30 #undef BFNC_PGP_DECRYPT_MIME            
    31 #undef BFNC_PGP_APPLICATION_PGP_HANDLER 
    32 #undef BFNC_PGP_ENCRYPTED_HANDLER 
    33 #undef BFNC_PGP_INVOKE_GETKEYS 
    34 #undef BFNC_PGP_ASK_FOR_KEY 
    35 #undef BNFC_PGP_CHECK_TRADITIONAL 
    36 #undef BFNC_PGP_TRADITIONAL_ENCRYPTSIGN   
    37 #undef BFNC_PGP_FREE_KEY 
    38 #undef BFNC_PGP_MAKE_KEY_ATTACHMENT  
    39 #undef BFNC_PGP_FINDKEYS 
    40 #undef BFNC_PGP_SIGN_MESSAGE 
    41 #undef BFNC_PGP_ENCRYPT_MESSAGE 
    42 #undef BFNC_PGP_INVOKE_IMPORT 
    43 #undef BFNC_PGP_VERIFY_ONE 
    44 #undef BFNC_PGP_KEYID 
    45 #undef BFNC_PGP_EXTRACT_KEYS_FROM_ATTACHMENT_LIST 
    46  
    47 #undef BFNC_SMIME_VOID_PASSPHRASE  
    48 #undef BFNC_SMIME_DECRYPT_MIME     
    49 #undef BFNC_SMIME_APPLICATION_SMIME_HANDLER  
    50 #undef BFNC_SMIME_GETKEYS   
    51 #undef BFNC_SMIME_VERIFY_SENDER 
    52 #undef BFNC_SMIME_ASK_FOR_KEY 
    53 #undef BFNC_SMIME_FINDKEYS 
    54 #undef BFNC_SMIME_SIGN_MESSAGE 
    55 #undef BFNC_SMIME_BUILD_SMIME_ENTITY 
    56 #undef BFNC_SMIME_INVOKE_IMPORT 
    57 #undef BFNC_SMIME_VERIFY_ONE 
    58  
    59  
    60 /* The PGP backend */ 
    61 #if defined (CRYPT_BACKEND_CLASSIC_PGP) 
    62 # include "pgp.h" 
    63 # define BFNC_PGP_VOID_PASSPHRASE         pgp_void_passphrase 
    64 # define BFNC_PGP_DECRYPT_MIME            pgp_decrypt_mime 
    65 # define BFNC_PGP_APPLICATION_PGP_HANDLER pgp_application_pgp_handler 
    66 # define BFNC_PGP_ENCRYPTED_HANDLER       pgp_encrypted_handler 
    67 # define BFNC_PGP_INVOKE_GETKEYS          pgp_invoke_getkeys 
    68 # define BFNC_PGP_ASK_FOR_KEY             pgp_ask_for_key 
    69 # define BNFC_PGP_CHECK_TRADITIONAL       pgp_check_traditional 
    70 # define BFNC_PGP_TRADITIONAL_ENCRYPTSIGN pgp_traditional_encryptsign  
    71 # define BFNC_PGP_FREE_KEY                pgp_free_key 
    72 # define BFNC_PGP_MAKE_KEY_ATTACHMENT     pgp_make_key_attachment 
    73 # define BFNC_PGP_FINDKEYS                pgp_findKeys 
    74 # define BFNC_PGP_SIGN_MESSAGE            pgp_sign_message 
    75 # define BFNC_PGP_ENCRYPT_MESSAGE         pgp_encrypt_message 
    76 # define BFNC_PGP_INVOKE_IMPORT           pgp_invoke_import 
    77 # define BFNC_PGP_VERIFY_ONE              pgp_verify_one 
    78 # define BFNC_PGP_KEYID                   pgp_keyid 
    79 # define BFNC_PGP_EXTRACT_KEYS_FROM_ATTACHMENT_LIST \ 
    80                                        pgp_extract_keys_from_attachment_list 
    81  
    82  
    83 #elif defined (CRYPT_BACKEND_GPGME) 
    84 # include "crypt-gpgme.h" 
    85 # define BFNC_PGP_VOID_PASSPHRASE NULL /* not required */ 
    86 # define BFNC_PGP_DECRYPT_MIME     gpg_pgp_decrypt_mime 
    87  
    88 #endif /* PGP backend */ 
    89  
    90  
    91 /* The SMIME backend */ 
    92 #ifdef CRYPT_BACKEND_CLASSIC_SMIME 
    93 # include "smime.h" 
    94 # define BFNC_SMIME_VOID_PASSPHRASE           smime_void_passphrase 
    95 # define BFNC_SMIME_DECRYPT_MIME              smime_decrypt_mime 
    96 # define BFNC_SMIME_APPLICATION_SMIME_HANDLER smime_application_smime_handler 
    97 # define BFNC_SMIME_GETKEYS                   smime_getkeys 
    98 # define BFNC_SMIME_VERIFY_SENDER             smime_verify_sender 
    99 # define BFNC_SMIME_ASK_FOR_KEY               smime_ask_for_key 
    100 # define BFNC_SMIME_FINDKEYS                  smime_findKeys 
    101 # define BFNC_SMIME_SIGN_MESSAGE              smime_sign_message 
    102 # define BFNC_SMIME_BUILD_SMIME_ENTITY        smime_build_smime_entity 
    103 # define BFNC_SMIME_INVOKE_IMPORT             smime_invoke_import 
    104 # define BFNC_SMIME_VERIFY_ONE            smime_verify_one 
    105  
    106 #elif defined (CRYPT_BACKEND_GPGME) 
    107   /* Already included above (gpgme supports both). */  
    108 # define BFNC_SMIME_VOID_PASSPHRASE NULL /* not required */ 
    109  
    110 #endif /* SMIME backend */ 
    111  
    112   
     34#include "crypt-mod.h" 
     35 
    11336/* 
    11437     
     
    11740*/ 
    11841 
     42#ifdef CRYPT_BACKEND_CLASSIC_PGP 
     43extern struct crypt_module_specs crypt_mod_pgp_classic; 
     44#endif 
     45 
     46#ifdef CRYPT_BACKEND_CLASSIC_SMIME 
     47extern struct crypt_module_specs crypt_mod_smime_classic; 
     48#endif 
     49 
     50#ifdef CRYPT_BACKEND_GPGME 
     51extern struct crypt_module_specs crypt_mod_pgp_gpgme; 
     52extern struct crypt_module_specs crypt_mod_smime_gpgme; 
     53#endif 
     54 
     55void crypt_init (void) 
     56{ 
     57#ifdef CRYPT_BACKEND_CLASSIC_PGP 
     58  if ( 
     59#ifdef CRYPT_BACKEND_GPGME 
     60      (! option (OPTCRYPTUSEGPGME)) 
     61#else 
     62       1 
     63#endif 
     64      ) 
     65    crypto_module_register (&crypt_mod_pgp_classic); 
     66#endif 
     67 
     68#ifdef CRYPT_BACKEND_CLASSIC_SMIME 
     69  if ( 
     70#ifdef CRYPT_BACKEND_GPGME 
     71      (! option (OPTCRYPTUSEGPGME)) 
     72#else 
     73       1 
     74#endif 
     75      ) 
     76    crypto_module_register (&crypt_mod_smime_classic); 
     77#endif 
     78 
     79  if (option (OPTCRYPTUSEGPGME)) 
     80    { 
     81#ifdef CRYPT_BACKEND_GPGME 
     82      crypto_module_register (&crypt_mod_pgp_gpgme); 
     83      crypto_module_register (&crypt_mod_smime_gpgme); 
     84#else 
     85      mutt_message (_("\"crypt_use_gpgme\" set" 
     86                      " but not build with GPGME support.")); 
     87#endif 
     88    } 
     89 
     90#if defined CRYPT_BACKEND_CLASSIG_PGP || defined CRYPT_BACKEND_CLASSIG_SMIME || defined CRYPT_BACKEND_GPGME 
     91  if (CRYPT_MOD_CALL_CHECK (PGP, init)) 
     92    (CRYPT_MOD_CALL (PGP, init)) (); 
     93 
     94  if (CRYPT_MOD_CALL_CHECK (SMIME, init)) 
     95    (CRYPT_MOD_CALL (SMIME, init)) (); 
     96#endif 
     97} 
     98 
     99 
    119100/* Show a message that a backend will be invoked. */ 
    120101void crypt_invoke_message (int type) 
    121102{ 
    122 #if defined (CRYPT_BACKEND_CLASSIC_PGP) || defined(CRYPT_BACKEND_CLASSIC_SMIME) 
    123   if ((type & APPLICATION_PGP)) 
     103  if ((WithCrypto & APPLICATION_PGP) && (type & APPLICATION_PGP)) 
    124104    mutt_message _("Invoking PGP..."); 
    125   if ((type & APPLICATION_SMIME)) 
    126     mutt_message _("Invoking OpenSSL..."); 
    127 #elif defined (CRYPT_BACKEND_GPGME) 
    128   if ((type & APPLICATION_PGP) || (type & APPLICATION_SMIME) ) 
    129     mutt_message _("Invoking GnuPG..."); 
    130 #endif 
     105  else if ((WithCrypto & APPLICATION_SMIME) && (type & APPLICATION_SMIME)) 
     106    mutt_message _("Invoking SMIME..."); 
    131107} 
    132108 
     
    143119void crypt_pgp_void_passphrase (void) 
    144120{ 
    145 #ifdef BFNC_PGP_VOID_PASSPHRASE 
    146   BFNC_PGP_VOID_PASSPHRASE (); 
    147 #endif 
    148 } 
     121  if (CRYPT_MOD_CALL_CHECK (PGP, void_passphrase)) 
     122    (CRYPT_MOD_CALL (PGP, void_passphrase)) (); 
     123} 
     124 
     125int crypt_pgp_valid_passphrase (void) 
     126{ 
     127  if (CRYPT_MOD_CALL_CHECK (PGP, valid_passphrase)) 
     128    return (CRYPT_MOD_CALL (PGP, valid_passphrase)) (); 
     129 
     130  return 0; 
     131} 
     132 
    149133 
    150134/* Decrypt a PGP/MIME message. */ 
    151135int crypt_pgp_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d) 
    152136{ 
    153 #ifdef BFNC_PGP_DECRYPT_MIME 
    154   return BFNC_PGP_DECRYPT_MIME (a, b, c, d); 
    155 #else 
    156   return -1; /* error */ 
    157 #endif 
     137  if (CRYPT_MOD_CALL_CHECK (PGP, decrypt_mime)) 
     138    return (CRYPT_MOD_CALL (PGP, decrypt_mime)) (a, b, c, d); 
     139 
     140  return -1; 
    158141} 
    159142 
     
    161144void crypt_pgp_application_pgp_handler (BODY *m, STATE *s) 
    162145{ 
    163 #ifdef BFNC_PGP_APPLICATION_PGP_HANDLER 
    164   BFNC_PGP_APPLICATION_PGP_HANDLER (m, s); 
    165 #endif 
     146  if (CRYPT_MOD_CALL_CHECK (PGP, application_handler)) 
     147    (CRYPT_MOD_CALL (PGP, application_handler)) (m, s); 
    166148} 
    167149 
     
    169151void crypt_pgp_encrypted_handler (BODY *a, STATE *s) 
    170152{ 
    171 #ifdef BFNC_PGP_ENCRYPTED_HANDLER 
    172   BFNC_PGP_ENCRYPTED_HANDLER (a, s); 
    173 #endif 
     153  if (CRYPT_MOD_CALL_CHECK (PGP, encrypted_handler)) 
     154    (CRYPT_MOD_CALL (PGP, encrypted_handler)) (a, s); 
    174155} 
    175156 
     
    177158void crypt_pgp_invoke_getkeys (ADDRESS *addr) 
    178159{ 
    179 #ifdef BFNC_PGP_INVOKE_GETKEYS 
    180   BFNC_PGP_INVOKE_GETKEYS (addr); 
    181 #endif 
    182 } 
    183  
    184 /* Ask for a PGP key. */ 
    185 pgp_key_t crypt_pgp_ask_for_key (char *tag, char *whatfor, 
    186                                  short abilities, pgp_ring_t keyring) 
    187 { 
    188 #ifdef BFNC_PGP_ASK_FOR_KEY 
    189   return BFNC_PGP_ASK_FOR_KEY (tag, whatfor, abilities, keyring); 
    190 #else 
    191   return NULL; 
    192 #endif 
    193 } 
    194  
     160  if (CRYPT_MOD_CALL_CHECK (PGP, pgp_invoke_getkeys)) 
     161    (CRYPT_MOD_CALL (PGP, pgp_invoke_getkeys)) (addr); 
     162} 
    195163 
    196164/* Check for a traditional PGP message in body B. */ 
    197165int crypt_pgp_check_traditional (FILE *fp, BODY *b, int tagged_only) 
    198166{ 
    199 #ifdef BNFC_PGP_CHECK_TRADITIONAL 
    200   return BNFC_PGP_CHECK_TRADITIONAL (fp, b, tagged_only); 
    201 #else 
    202   return 0; /* no */ 
    203 #endif 
     167  if (CRYPT_MOD_CALL_CHECK (PGP, pgp_check_traditional)) 
     168    return (CRYPT_MOD_CALL (PGP, pgp_check_traditional)) (fp, b, tagged_only); 
     169 
     170  return 0; 
    204171} 
    205172 
     
    207174BODY *crypt_pgp_traditional_encryptsign (BODY *a, int flags, char *keylist) 
    208175{ 
    209 #ifdef BFNC_PGP_TRADITIONAL_ENCRYPTSIGN   
    210   return BFNC_PGP_TRADITIONAL_ENCRYPTSIGN (a, flags, keylist); 
    211 #else 
    212   return NULL; 
    213 #endif 
    214 } 
    215  
    216 /* Release pgp key KPP. */ 
    217 void crypt_pgp_free_key (pgp_key_t *kpp) 
    218 { 
    219 #ifdef BFNC_PGP_FREE_KEY 
    220   BFNC_PGP_FREE_KEY (kpp); 
    221 #endif 
    222 } 
    223  
     176  if (CRYPT_MOD_CALL_CHECK (PGP, pgp_traditional_encryptsign)) 
     177    return (CRYPT_MOD_CALL (PGP, pgp_traditional_encryptsign)) (a, flags, keylist); 
     178 
     179  return NULL; 
     180} 
    224181 
    225182/* Generate a PGP public key attachment. */ 
    226183BODY *crypt_pgp_make_key_attachment (char *tempf) 
    227184{ 
    228 #ifdef BFNC_PGP_MAKE_KEY_ATTACHMENT  
    229   return BFNC_PGP_MAKE_KEY_ATTACHMENT (tempf); 
    230 #else 
    231   return NULL; /* error */  
    232 #endif 
     185  if (CRYPT_MOD_CALL_CHECK (PGP, pgp_make_key_attachment)) 
     186    return (CRYPT_MOD_CALL (PGP, pgp_make_key_attachment)) (tempf); 
     187 
     188  return NULL; 
    233189} 
    234190 
     
    237193char *crypt_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc) 
    238194{ 
    239 #ifdef BFNC_PGP_FINDKEYS 
    240   return BFNC_PGP_FINDKEYS (to, cc, bcc); 
    241 #else 
    242   return NULL; 
    243 #endif 
     195  if (CRYPT_MOD_CALL_CHECK (PGP, findkeys)) 
     196    return (CRYPT_MOD_CALL (PGP, findkeys)) (to, cc, bcc); 
     197 
     198  return NULL; 
    244199} 
    245200 
     
    247202BODY *crypt_pgp_sign_message (BODY *a) 
    248203{ 
    249 #ifdef BFNC_PGP_SIGN_MESSAGE 
    250   return BFNC_PGP_SIGN_MESSAGE (a); 
    251 #else 
    252   return NULL; 
    253 #endif 
     204  if (CRYPT_MOD_CALL_CHECK (PGP, sign_message)) 
     205    return (CRYPT_MOD_CALL (PGP, sign_message)) (a); 
     206 
     207  return NULL; 
    254208} 
    255209 
     
    258212BODY *crypt_pgp_encrypt_message (BODY *a, char *keylist, int sign) 
    259213{ 
    260 #ifdef BFNC_PGP_ENCRYPT_MESSAGE 
    261   return BFNC_PGP_ENCRYPT_MESSAGE (a, keylist, sign); 
    262 #else 
    263   return NULL; 
    264 #endif 
     214  if (CRYPT_MOD_CALL_CHECK (PGP, pgp_encrypt_message)) 
     215    return (CRYPT_MOD_CALL (PGP, pgp_encrypt_message)) (a, keylist, sign); 
     216 
     217  return NULL; 
    265218} 
    266219 
     
    268221void crypt_pgp_invoke_import (const char *fname) 
    269222{ 
    270 #ifdef BFNC_PGP_INVOKE_IMPORT 
    271   BFNC_PGP_INVOKE_IMPORT (fname); 
    272 #endif 
     223  if (CRYPT_MOD_CALL_CHECK (PGP, pgp_invoke_import)) 
     224    (CRYPT_MOD_CALL (PGP, pgp_invoke_import)) (fname); 
    273225} 
    274226 
     
    276228int crypt_pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempf)