Andreas Krennmair:
[apps/madmutt.git] / crypt-mod-smime-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 smime code.
21  */
22
23 #include "crypt-mod.h"
24 #include "smime.h"
25
26 static void crypt_mod_smime_void_passphrase (void)
27 {
28   smime_void_passphrase ();
29 }
30
31 static int crypt_mod_smime_valid_passphrase (void)
32 {
33   return smime_valid_passphrase ();
34 }
35
36 static int crypt_mod_smime_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
37 {
38   return smime_decrypt_mime (a, b, c, d);
39 }
40 static void crypt_mod_smime_application_handler (BODY *m, STATE *s)
41 {
42   smime_application_smime_handler (m, s);
43 }
44
45 static char *crypt_mod_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
46 {
47   return smime_findKeys (to, cc, bcc);
48 }
49
50 static BODY *crypt_mod_smime_sign_message (BODY *a)
51 {
52   return smime_sign_message (a);
53 }
54
55 static int crypt_mod_smime_verify_one (BODY *sigbdy, STATE *s, const char *tempf)
56 {
57   return smime_verify_one (sigbdy, s, tempf);
58 }
59
60 static int crypt_mod_smime_send_menu (HEADER *msg, int *redraw)
61 {
62   return smime_send_menu (msg, redraw);
63 }
64
65 static void crypt_mod_smime_getkeys (ENVELOPE *env)
66 {
67   smime_getkeys (env);
68 }
69
70 static int crypt_mod_smime_verify_sender (HEADER *h)
71 {
72   return smime_verify_sender (h);
73 }
74
75 static BODY *crypt_mod_smime_build_smime_entity (BODY *a, char *certlist)
76 {
77   return smime_build_smime_entity (a, certlist);
78 }
79
80 static void crypt_mod_smime_invoke_import (char *infile, char *mailbox)
81 {
82   smime_invoke_import (infile, mailbox);
83 }
84
85
86 struct crypt_module_specs crypt_mod_smime_classic =
87   { APPLICATION_SMIME,
88     {
89       NULL,                     /* init */
90       crypt_mod_smime_void_passphrase,
91       crypt_mod_smime_valid_passphrase,
92       crypt_mod_smime_decrypt_mime,
93       crypt_mod_smime_application_handler,
94       NULL,                     /* encrypted_handler */
95       crypt_mod_smime_findkeys,
96       crypt_mod_smime_sign_message,
97       crypt_mod_smime_verify_one,
98       crypt_mod_smime_send_menu,
99
100       NULL,                     /* pgp_encrypt_message */
101       NULL,                     /* pgp_make_key_attachment */
102       NULL,                     /* pgp_check_traditional */
103       NULL,                     /* pgp_traditional_encryptsign */
104       NULL,                     /* pgp_invoke_getkeys */
105       NULL,                     /* pgp_invoke_import */
106       NULL,                     /* pgp_extract_keys_from_attachment_list */
107       
108       crypt_mod_smime_getkeys,
109       crypt_mod_smime_verify_sender,
110       crypt_mod_smime_build_smime_entity,
111       crypt_mod_smime_invoke_import,
112     }
113   };