f05487cd43eb7c94402b7f852de158f1e1944e7a
[apps/madmutt.git] / lib-crypt / crypt-mod-pgp-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 pgp 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_pgp_init (void)
22 {
23   pgp_gpgme_init ();
24 }
25
26 static void crypt_mod_pgp_void_passphrase (void)
27 {
28   /* Handled by gpg-agent.  */
29 }
30
31 static int crypt_mod_pgp_valid_passphrase (void)
32 {
33   /* Handled by gpg-agent.  */
34   return 1;
35 }
36
37 static int crypt_mod_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c,
38                                        BODY ** d)
39 {
40   return pgp_gpgme_decrypt_mime (a, b, c, d);
41 }
42
43 static int crypt_mod_pgp_application_handler (BODY * m, STATE * s)
44 {
45   return pgp_gpgme_application_handler (m, s);
46 }
47
48 static int crypt_mod_pgp_encrypted_handler (BODY * m, STATE * s)
49 {
50   return pgp_gpgme_encrypted_handler (m, s);
51 }
52
53 static int crypt_mod_pgp_check_traditional (FILE * fp, BODY * b,
54                                             int tagged_only)
55 {
56   return pgp_gpgme_check_traditional (fp, b, tagged_only);
57 }
58
59 static char *crypt_mod_pgp_findkeys (address_t * to, address_t * cc,
60                                      address_t * bcc)
61 {
62   return pgp_gpgme_findkeys (to, cc, bcc);
63 }
64
65 static BODY *crypt_mod_pgp_sign_message (BODY * a)
66 {
67   return pgp_gpgme_sign_message (a);
68 }
69
70 static int crypt_mod_pgp_verify_one (BODY * sigbdy, STATE * s,
71                                      const char *tempf)
72 {
73   return pgp_gpgme_verify_one (sigbdy, s, tempf);
74 }
75
76 static int crypt_mod_pgp_send_menu (HEADER * msg, int *redraw)
77 {
78   return pgp_gpgme_send_menu (msg, redraw);
79 }
80
81 static BODY *crypt_mod_pgp_encrypt_message (BODY * a, char *keylist, int sign)
82 {
83   return pgp_gpgme_encrypt_message (a, keylist, sign);
84 }
85
86 struct crypt_module_specs crypt_mod_pgp_gpgme = { APPLICATION_PGP,
87   {
88    /* Common.  */
89    crypt_mod_pgp_init,
90    crypt_mod_pgp_void_passphrase,
91    crypt_mod_pgp_valid_passphrase,
92    crypt_mod_pgp_decrypt_mime,
93    crypt_mod_pgp_application_handler,
94    crypt_mod_pgp_encrypted_handler,
95    crypt_mod_pgp_findkeys,
96    crypt_mod_pgp_sign_message,
97    crypt_mod_pgp_verify_one,
98    crypt_mod_pgp_send_menu,
99
100    /* PGP specific.  */
101    crypt_mod_pgp_encrypt_message,
102    NULL,                        /* pgp_make_key_attachment, */
103    crypt_mod_pgp_check_traditional,
104    NULL,                        /* pgp_traditional_encryptsign  */
105    NULL,                        /* pgp_invoke_getkeys  */
106    NULL,                        /* pgp_invoke_import  */
107    NULL,                        /* pgp_extract_keys_from_attachment_list  */
108
109    NULL,                        /* smime_getkeys */
110    NULL,                        /* smime_verify_sender */
111    NULL,                        /* smime_build_smime_entity */
112    NULL,                        /* smime_invoke_import */
113    }
114 };
115
116 #endif