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