ca17ce9845201f9dbd9e45c9e88298dc1930a5a5
[apps/madmutt.git] / crypt-mod-smime-gpgme.c
1 /* 
2  * Copyright (C) 2004 g10 Code GmbH
3  *
4  *     This program is free software; you can redistribute it and/or modify
5  *     it under the terms of the GNU General Public License as published by
6  *     the Free Software Foundation; either version 2 of the License, or
7  *     (at your option) any later version.
8  * 
9  *     This program is distributed in the hope that it will be useful,
10  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *     GNU General Public License for more details.
13  * 
14  *     You should have received a copy of the GNU General Public License
15  *     along with this program; if not, write to the Free Software
16  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
17  */
18
19 /* 
20     This is a crytpo module wrapping the gpgme based smime code.
21  */
22
23 #if HAVE_CONFIG_H
24 # include "config.h"
25 #endif
26
27 #ifdef CRYPT_BACKEND_GPGME
28
29 #include "crypt-mod.h"
30 #include "crypt-gpgme.h"
31
32 static void crypt_mod_smime_init (void)
33 {
34   smime_gpgme_init ();
35 }
36
37 static void crypt_mod_smime_void_passphrase (void)
38 {
39   /* Handled by gpg-agent.  */
40 }
41
42 static int crypt_mod_smime_valid_passphrase (void)
43 {
44   /* Handled by gpg-agent.  */
45   return 1;
46 }
47
48 static int crypt_mod_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c,
49                                          BODY ** d)
50 {
51   return smime_gpgme_decrypt_mime (a, b, c, d);
52 }
53
54 static void crypt_mod_smime_application_handler (BODY * m, STATE * s)
55 {
56   smime_gpgme_application_handler (m, s);
57 }
58
59 static char *crypt_mod_smime_findkeys (ADDRESS * to, ADDRESS * cc,
60                                        ADDRESS * bcc)
61 {
62   return smime_gpgme_findkeys (to, cc, bcc);
63 }
64
65 static BODY *crypt_mod_smime_sign_message (BODY * a)
66 {
67   return smime_gpgme_sign_message (a);
68 }
69
70 static int crypt_mod_smime_verify_one (BODY * sigbdy, STATE * s,
71                                        const char *tempf)
72 {
73   return smime_gpgme_verify_one (sigbdy, s, tempf);
74 }
75
76 static int crypt_mod_smime_send_menu (HEADER * msg, int *redraw)
77 {
78   return smime_gpgme_send_menu (msg, redraw);
79 }
80
81 static BODY *crypt_mod_smime_build_smime_entity (BODY * a, char *certlist)
82 {
83   return smime_gpgme_build_smime_entity (a, certlist);
84 }
85
86 static int crypt_mod_smime_verify_sender (HEADER * h)
87 {
88   return smime_gpgme_verify_sender (h);
89 }
90
91 struct crypt_module_specs crypt_mod_smime_gpgme = { APPLICATION_SMIME,
92   {
93    crypt_mod_smime_init,
94    crypt_mod_smime_void_passphrase,
95    crypt_mod_smime_valid_passphrase,
96    crypt_mod_smime_decrypt_mime,
97    crypt_mod_smime_application_handler,
98    NULL,                        /* encrypted_handler */
99    crypt_mod_smime_findkeys,
100    crypt_mod_smime_sign_message,
101    crypt_mod_smime_verify_one,
102    crypt_mod_smime_send_menu,
103
104    NULL,                        /* pgp_encrypt_message */
105    NULL,                        /* pgp_make_key_attachment */
106    NULL,                        /* pgp_check_traditional */
107    NULL,                        /* pgp_traditional_encryptsign */
108    NULL,                        /* pgp_invoke_getkeys */
109    NULL,                        /* pgp_invoke_import */
110    NULL,                        /* pgp_extract_keys_from_attachment_list */
111
112    NULL,                        /* smime_getkeys */
113    crypt_mod_smime_verify_sender,
114    crypt_mod_smime_build_smime_entity,
115    NULL,                        /* smime_invoke_import */
116    }
117 };
118
119 #endif