f5613eed6e789a5b9436591b1eb1ad57ffe7f5df
[apps/madmutt.git] / crypt-mod-pgp-classic.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 classic pgp code.
21  */
22
23 #if HAVE_CONFIG_H
24 # include "config.h"
25 #endif
26
27 #include "crypt-mod.h"
28 #include "pgp.h"
29
30 static void crypt_mod_pgp_void_passphrase (void)
31 {
32   pgp_void_passphrase ();
33 }
34
35 static int crypt_mod_pgp_valid_passphrase (void)
36 {
37   return pgp_valid_passphrase ();
38 }
39
40 static int crypt_mod_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c,
41                                        BODY ** d)
42 {
43   return pgp_decrypt_mime (a, b, c, d);
44 }
45 static void crypt_mod_pgp_application_handler (BODY * m, STATE * s)
46 {
47   pgp_application_pgp_handler (m, s);
48 }
49
50 static char *crypt_mod_pgp_findkeys (ADDRESS * to, ADDRESS * cc,
51                                      ADDRESS * bcc)
52 {
53   return pgp_findKeys (to, cc, bcc);
54 }
55
56 static BODY *crypt_mod_pgp_sign_message (BODY * a)
57 {
58   return pgp_sign_message (a);
59 }
60
61 static int crypt_mod_pgp_verify_one (BODY * sigbdy, STATE * s,
62                                      const char *tempf)
63 {
64   return pgp_verify_one (sigbdy, s, tempf);
65 }
66
67 static int crypt_mod_pgp_send_menu (HEADER * msg, int *redraw)
68 {
69   return pgp_send_menu (msg, redraw);
70 }
71
72 static BODY *crypt_mod_pgp_encrypt_message (BODY * a, char *keylist, int sign)
73 {
74   return pgp_encrypt_message (a, keylist, sign);
75 }
76
77 static BODY *crypt_mod_pgp_make_key_attachment (char *tempf)
78 {
79   return pgp_make_key_attachment (tempf);
80 }
81
82 static int crypt_mod_pgp_check_traditional (FILE * fp, BODY * b,
83                                             int tagged_only)
84 {
85   return pgp_check_traditional (fp, b, tagged_only);
86 }
87
88 static BODY *crypt_mod_pgp_traditional_encryptsign (BODY * a, int flags,
89                                                     char *keylist)
90 {
91   return pgp_traditional_encryptsign (a, flags, keylist);
92 }
93
94 static void crypt_mod_pgp_encrypted_handler (BODY * m, STATE * s)
95 {
96   pgp_encrypted_handler (m, s);
97 }
98
99 static void crypt_mod_pgp_invoke_getkeys (ADDRESS * addr)
100 {
101   pgp_invoke_getkeys (addr);
102 }
103
104 static void crypt_mod_pgp_invoke_import (const char *fname)
105 {
106   pgp_invoke_import (fname);
107 }
108
109 static void crypt_mod_pgp_extract_keys_from_attachment_list (FILE * fp,
110                                                              int tag,
111                                                              BODY * top)
112 {
113   pgp_extract_keys_from_attachment_list (fp, tag, top);
114 }
115
116 struct crypt_module_specs crypt_mod_pgp_classic = { APPLICATION_PGP,
117   {
118    NULL,                        /* init */
119    crypt_mod_pgp_void_passphrase,
120    crypt_mod_pgp_valid_passphrase,
121    crypt_mod_pgp_decrypt_mime,
122    crypt_mod_pgp_application_handler,
123    crypt_mod_pgp_encrypted_handler,
124    crypt_mod_pgp_findkeys,
125    crypt_mod_pgp_sign_message,
126    crypt_mod_pgp_verify_one,
127    crypt_mod_pgp_send_menu,
128
129    crypt_mod_pgp_encrypt_message,
130    crypt_mod_pgp_make_key_attachment,
131    crypt_mod_pgp_check_traditional,
132    crypt_mod_pgp_traditional_encryptsign,
133    crypt_mod_pgp_invoke_getkeys,
134    crypt_mod_pgp_invoke_import,
135    crypt_mod_pgp_extract_keys_from_attachment_list,
136
137    NULL,                        /* smime_getkeys */
138    NULL,                        /* smime_verify_sender */
139    NULL,                        /* smime_build_smime_entity */
140    NULL,                        /* smime_invoke_import */
141    }
142 };