Use p_new instead of xmalloc()
[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 #include <lib-lib/lib-lib.h>
15
16 #ifdef CRYPT_BACKEND_GPGME
17
18 #include <lib-crypt/crypt-mod.h>
19 #include "crypt-gpgme.h"
20
21 static void crypt_mod_smime_init (void)
22 {
23   smime_gpgme_init ();
24 }
25
26 static void crypt_mod_smime_void_passphrase (void)
27 {
28   /* Handled by gpg-agent.  */
29 }
30
31 static int crypt_mod_smime_valid_passphrase (void)
32 {
33   /* Handled by gpg-agent.  */
34   return 1;
35 }
36
37 static int crypt_mod_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c,
38                                          BODY ** d)
39 {
40   return smime_gpgme_decrypt_mime (a, b, c, d);
41 }
42
43 static int crypt_mod_smime_application_handler (BODY * m, STATE * s)
44 {
45   return smime_gpgme_application_handler (m, s);
46 }
47
48 static char *crypt_mod_smime_findkeys (address_t * to, address_t * cc,
49                                        address_t * bcc)
50 {
51   return smime_gpgme_findkeys (to, cc, bcc);
52 }
53
54 static BODY *crypt_mod_smime_sign_message (BODY * a)
55 {
56   return smime_gpgme_sign_message (a);
57 }
58
59 static int crypt_mod_smime_verify_one (BODY * sigbdy, STATE * s,
60                                        const char *tempf)
61 {
62   return smime_gpgme_verify_one (sigbdy, s, tempf);
63 }
64
65 static int crypt_mod_smime_send_menu (HEADER * msg, int *redraw)
66 {
67   return smime_gpgme_send_menu (msg, redraw);
68 }
69
70 static BODY *crypt_mod_smime_build_smime_entity (BODY * a, char *certlist)
71 {
72   return smime_gpgme_build_smime_entity (a, certlist);
73 }
74
75 static int crypt_mod_smime_verify_sender (HEADER * h)
76 {
77   return smime_gpgme_verify_sender (h);
78 }
79
80 struct crypt_module_specs crypt_mod_smime_gpgme = { APPLICATION_SMIME,
81   {
82    crypt_mod_smime_init,
83    crypt_mod_smime_void_passphrase,
84    crypt_mod_smime_valid_passphrase,
85    crypt_mod_smime_decrypt_mime,
86    crypt_mod_smime_application_handler,
87    NULL,                        /* encrypted_handler */
88    crypt_mod_smime_findkeys,
89    crypt_mod_smime_sign_message,
90    crypt_mod_smime_verify_one,
91    crypt_mod_smime_send_menu,
92
93    NULL,                        /* pgp_encrypt_message */
94    NULL,                        /* pgp_make_key_attachment */
95    NULL,                        /* pgp_check_traditional */
96    NULL,                        /* pgp_traditional_encryptsign */
97    NULL,                        /* pgp_invoke_getkeys */
98    NULL,                        /* pgp_invoke_import */
99    NULL,                        /* pgp_extract_keys_from_attachment_list */
100
101    NULL,                        /* smime_getkeys */
102    crypt_mod_smime_verify_sender,
103    crypt_mod_smime_build_smime_entity,
104    NULL,                        /* smime_invoke_import */
105    }
106 };
107
108 #endif