move the last crypt-* things into lib-crypt, adapt configure.ac
[apps/madmutt.git] / lib-crypt / crypt-mod-smime-gpgme.c
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 2004 g10 Code GmbH
4  *
5  * This file is part of mutt-ng, see http://www.muttng.org/.
6  * It's licensed under the GNU General Public License,
7  * please see the file GPL in the top level source directory.
8  */
9
10 /* 
11     This is a crytpo module wrapping the gpgme based smime code.
12  */
13
14 #if HAVE_CONFIG_H
15 # include "config.h"
16 #endif
17
18 #ifdef CRYPT_BACKEND_GPGME
19
20 #include <lib-crypt/crypt-mod.h>
21 #include "crypt-gpgme.h"
22
23 static void crypt_mod_smime_init (void)
24 {
25   smime_gpgme_init ();
26 }
27
28 static void crypt_mod_smime_void_passphrase (void)
29 {
30   /* Handled by gpg-agent.  */
31 }
32
33 static int crypt_mod_smime_valid_passphrase (void)
34 {
35   /* Handled by gpg-agent.  */
36   return 1;
37 }
38
39 static int crypt_mod_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c,
40                                          BODY ** d)
41 {
42   return smime_gpgme_decrypt_mime (a, b, c, d);
43 }
44
45 static int crypt_mod_smime_application_handler (BODY * m, STATE * s)
46 {
47   return smime_gpgme_application_handler (m, s);
48 }
49
50 static char *crypt_mod_smime_findkeys (address_t * to, address_t * cc,
51                                        address_t * bcc)
52 {
53   return smime_gpgme_findkeys (to, cc, bcc);
54 }
55
56 static BODY *crypt_mod_smime_sign_message (BODY * a)
57 {
58   return smime_gpgme_sign_message (a);
59 }
60
61 static int crypt_mod_smime_verify_one (BODY * sigbdy, STATE * s,
62                                        const char *tempf)
63 {
64   return smime_gpgme_verify_one (sigbdy, s, tempf);
65 }
66
67 static int crypt_mod_smime_send_menu (HEADER * msg, int *redraw)
68 {
69   return smime_gpgme_send_menu (msg, redraw);
70 }
71
72 static BODY *crypt_mod_smime_build_smime_entity (BODY * a, char *certlist)
73 {
74   return smime_gpgme_build_smime_entity (a, certlist);
75 }
76
77 static int crypt_mod_smime_verify_sender (HEADER * h)
78 {
79   return smime_gpgme_verify_sender (h);
80 }
81
82 struct crypt_module_specs crypt_mod_smime_gpgme = { APPLICATION_SMIME,
83   {
84    crypt_mod_smime_init,
85    crypt_mod_smime_void_passphrase,
86    crypt_mod_smime_valid_passphrase,
87    crypt_mod_smime_decrypt_mime,
88    crypt_mod_smime_application_handler,
89    NULL,                        /* encrypted_handler */
90    crypt_mod_smime_findkeys,
91    crypt_mod_smime_sign_message,
92    crypt_mod_smime_verify_one,
93    crypt_mod_smime_send_menu,
94
95    NULL,                        /* pgp_encrypt_message */
96    NULL,                        /* pgp_make_key_attachment */
97    NULL,                        /* pgp_check_traditional */
98    NULL,                        /* pgp_traditional_encryptsign */
99    NULL,                        /* pgp_invoke_getkeys */
100    NULL,                        /* pgp_invoke_import */
101    NULL,                        /* pgp_extract_keys_from_attachment_list */
102
103    NULL,                        /* smime_getkeys */
104    crypt_mod_smime_verify_sender,
105    crypt_mod_smime_build_smime_entity,
106    NULL,                        /* smime_invoke_import */
107    }
108 };
109
110 #endif