Nico Golde:
[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, BODY **d)
41 {
42   return pgp_decrypt_mime (a, b, c, d);
43 }
44 static void crypt_mod_pgp_application_handler (BODY *m, STATE *s)
45 {
46   pgp_application_pgp_handler (m, s);
47 }
48
49 static char *crypt_mod_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
50 {
51   return pgp_findKeys (to, cc, bcc);
52 }
53
54 static BODY *crypt_mod_pgp_sign_message (BODY *a)
55 {
56   return pgp_sign_message (a);
57 }
58
59 static int crypt_mod_pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempf)
60 {
61   return pgp_verify_one (sigbdy, s, tempf);
62 }
63
64 static int crypt_mod_pgp_send_menu (HEADER *msg, int *redraw)
65 {
66   return pgp_send_menu (msg, redraw);
67 }
68
69 static BODY *crypt_mod_pgp_encrypt_message (BODY *a, char *keylist, int sign)
70 {
71   return pgp_encrypt_message (a, keylist, sign);
72 }
73
74 static BODY *crypt_mod_pgp_make_key_attachment (char *tempf)
75 {
76   return pgp_make_key_attachment (tempf);
77 }
78
79 static int crypt_mod_pgp_check_traditional (FILE *fp, BODY *b, int tagged_only)
80 {
81   return pgp_check_traditional (fp, b, tagged_only);
82 }
83
84 static BODY *crypt_mod_pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
85 {
86   return pgp_traditional_encryptsign (a, flags, keylist);
87 }
88
89 static void crypt_mod_pgp_encrypted_handler (BODY *m, STATE *s)
90 {
91   pgp_encrypted_handler (m, s);
92 }
93
94 static void crypt_mod_pgp_invoke_getkeys (ADDRESS *addr)
95 {
96   pgp_invoke_getkeys (addr);
97 }
98
99 static void crypt_mod_pgp_invoke_import (const char *fname)
100 {
101   pgp_invoke_import (fname);
102 }
103
104 static void crypt_mod_pgp_extract_keys_from_attachment_list (FILE *fp, int tag, BODY *top)
105 {
106   pgp_extract_keys_from_attachment_list (fp, tag, top);
107 }
108
109 struct crypt_module_specs crypt_mod_pgp_classic =
110   { APPLICATION_PGP,
111     {
112       NULL,                     /* init */
113       crypt_mod_pgp_void_passphrase,
114       crypt_mod_pgp_valid_passphrase,
115       crypt_mod_pgp_decrypt_mime,
116       crypt_mod_pgp_application_handler,
117       crypt_mod_pgp_encrypted_handler,
118       crypt_mod_pgp_findkeys,
119       crypt_mod_pgp_sign_message,
120       crypt_mod_pgp_verify_one,
121       crypt_mod_pgp_send_menu,
122
123       crypt_mod_pgp_encrypt_message,
124       crypt_mod_pgp_make_key_attachment,
125       crypt_mod_pgp_check_traditional,
126       crypt_mod_pgp_traditional_encryptsign,
127       crypt_mod_pgp_invoke_getkeys,
128       crypt_mod_pgp_invoke_import,
129       crypt_mod_pgp_extract_keys_from_attachment_list,
130
131       NULL,                     /* smime_getkeys */
132       NULL,                     /* smime_verify_sender */
133       NULL,                     /* smime_build_smime_entity */
134       NULL,                     /* smime_invoke_import */
135     }
136   };