2006-01-13 [paul] 1.9.100cvs142
[claws.git] / src / plugins / pgpmime / pgpmime.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2006 Hiroyuki Yamamoto & the Sylpheed-Claws team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #ifdef USE_GPGME
25
26 #include "defs.h"
27 #include <glib.h>
28 #include <gpgme.h>
29 #include <ctype.h>
30
31 #include "utils.h"
32 #include "privacy.h"
33 #include "procmime.h"
34
35 #include "pgpmime.h"
36 #include <plugins/pgpcore/sgpgme.h>
37 #include <plugins/pgpcore/prefs_gpg.h>
38 #include <plugins/pgpcore/passphrase.h>
39
40 #include "prefs_common.h"
41
42 typedef struct _PrivacyDataPGP PrivacyDataPGP;
43
44 struct _PrivacyDataPGP
45 {
46         PrivacyData     data;
47         
48         gboolean        done_sigtest;
49         gboolean        is_signed;
50         gpgme_verify_result_t   sigstatus;
51         gpgme_ctx_t     ctx;
52         gboolean        is_pkcs7;
53 };
54
55 static PrivacySystem pgpmime_system;
56
57 static gint pgpmime_check_signature(MimeInfo *mimeinfo);
58
59 static PrivacyDataPGP *pgpmime_new_privacydata()
60 {
61         PrivacyDataPGP *data;
62
63         data = g_new0(PrivacyDataPGP, 1);
64         data->data.system = &pgpmime_system;
65         data->done_sigtest = FALSE;
66         data->is_signed = FALSE;
67         data->sigstatus = NULL;
68         gpgme_new(&data->ctx);
69         
70         return data;
71 }
72
73 static void pgpmime_free_privacydata(PrivacyData *_data)
74 {
75         PrivacyDataPGP *data = (PrivacyDataPGP *) _data;
76         gpgme_release(data->ctx);
77         g_free(data);
78 }
79
80 static gboolean pgpmime_is_signed(MimeInfo *mimeinfo)
81 {
82         MimeInfo *parent;
83         MimeInfo *signature;
84         const gchar *protocol;
85         PrivacyDataPGP *data = NULL;
86         
87         g_return_val_if_fail(mimeinfo != NULL, FALSE);
88         if (mimeinfo->privacy != NULL) {
89                 data = (PrivacyDataPGP *) mimeinfo->privacy;
90                 if (data->done_sigtest)
91                         return data->is_signed;
92         }
93         
94         /* check parent */
95         parent = procmime_mimeinfo_parent(mimeinfo);
96         if (parent == NULL)
97                 return FALSE;
98         if ((parent->type != MIMETYPE_MULTIPART) ||
99             g_ascii_strcasecmp(parent->subtype, "signed"))
100                 return FALSE;
101         protocol = procmime_mimeinfo_get_parameter(parent, "protocol");
102         if ((protocol == NULL) || 
103             (g_ascii_strcasecmp(protocol, "application/pgp-signature") &&
104              g_ascii_strcasecmp(protocol, "application/pkcs7-signature") &&
105              g_ascii_strcasecmp(protocol, "application/x-pkcs7-signature")))
106                 return FALSE;
107
108         /* check if mimeinfo is the first child */
109         if (parent->node->children->data != mimeinfo)
110                 return FALSE;
111
112         /* check signature */
113         signature = parent->node->children->next != NULL ? 
114             (MimeInfo *) parent->node->children->next->data : NULL;
115         if (signature == NULL)
116                 return FALSE;
117         if ((signature->type != MIMETYPE_APPLICATION) ||
118             (g_ascii_strcasecmp(signature->subtype, "pgp-signature") &&
119              g_ascii_strcasecmp(signature->subtype, "pkcs7-signature") &&
120              g_ascii_strcasecmp(signature->subtype, "x-pkcs7-signature")))
121                 return FALSE;
122
123         if (data == NULL) {
124                 data = pgpmime_new_privacydata();
125                 mimeinfo->privacy = (PrivacyData *) data;
126         }
127         
128         if (!g_ascii_strcasecmp(signature->subtype, "pkcs7-signature") ||
129             !g_ascii_strcasecmp(signature->subtype, "x-pkcs7-signature"))
130                 data->is_pkcs7 = TRUE;
131         else
132                 data->is_pkcs7 = FALSE;
133
134         data->done_sigtest = TRUE;
135         data->is_signed = TRUE;
136
137         return TRUE;
138 }
139
140 static gchar *get_canonical_content(FILE *fp, const gchar *boundary)
141 {
142         gchar *ret;
143         GString *textbuffer;
144         guint boundary_len;
145         gchar buf[BUFFSIZE];
146
147         boundary_len = strlen(boundary);
148         while (fgets(buf, sizeof(buf), fp) != NULL)
149                 if (IS_BOUNDARY(buf, boundary, boundary_len))
150                         break;
151
152         textbuffer = g_string_new("");
153         while (fgets(buf, sizeof(buf), fp) != NULL) {
154                 gchar *buf2;
155
156                 if (IS_BOUNDARY(buf, boundary, boundary_len))
157                         break;
158                 
159                 buf2 = canonicalize_str(buf);
160                 g_string_append(textbuffer, buf2);
161                 g_free(buf2);
162         }
163         g_string_truncate(textbuffer, textbuffer->len - 2);
164                 
165         ret = textbuffer->str;
166         g_string_free(textbuffer, FALSE);
167
168         return ret;
169 }
170
171 static gint pgpmime_check_signature(MimeInfo *mimeinfo)
172 {
173         PrivacyDataPGP *data;
174         MimeInfo *parent, *signature;
175         FILE *fp;
176         gchar *boundary;
177         gchar *textstr;
178         gpgme_data_t sigdata = NULL, textdata = NULL;
179         gpgme_error_t err;
180         g_return_val_if_fail(mimeinfo != NULL, -1);
181         g_return_val_if_fail(mimeinfo->privacy != NULL, -1);
182         data = (PrivacyDataPGP *) mimeinfo->privacy;
183         gpgme_new(&data->ctx);
184         
185         debug_print("Checking %s/MIME signature\n", data->is_pkcs7?"S":"PGP");
186
187         if (data->is_pkcs7) {
188                 err = gpgme_set_protocol(data->ctx, GPGME_PROTOCOL_CMS);
189         } else
190                 err = gpgme_set_protocol(data->ctx, GPGME_PROTOCOL_OpenPGP);
191
192         if (err) {
193                 debug_print ("gpgme_set_protocol failed: %s\n",
194                    gpgme_strerror (err));
195         }
196         parent = procmime_mimeinfo_parent(mimeinfo);
197
198         fp = g_fopen(parent->data.filename, "rb");
199         g_return_val_if_fail(fp != NULL, SIGNATURE_INVALID);
200         
201         boundary = g_hash_table_lookup(parent->typeparameters, "boundary");
202         if (!boundary)
203                 return 0;
204
205         textstr = get_canonical_content(fp, boundary);
206
207         err = gpgme_data_new_from_mem(&textdata, textstr, strlen(textstr), 0);
208         if (err) {
209                 debug_print ("gpgme_data_new_from_mem failed: %s\n",
210                    gpgme_strerror (err));
211         }
212         signature = (MimeInfo *) mimeinfo->node->next->data;
213         sigdata = sgpgme_data_from_mimeinfo(signature);
214
215         err = 0;
216         if (signature->encoding_type == ENC_BASE64) {
217                 err = gpgme_data_set_encoding (sigdata, GPGME_DATA_ENCODING_BASE64);
218         }
219         
220         if (err) {
221                 debug_print ("gpgme_data_set_encoding failed: %s\n",
222                         gpgme_strerror (err));
223         }
224
225         data->sigstatus =
226                 sgpgme_verify_signature (data->ctx, sigdata, textdata, NULL);
227
228         gpgme_data_release(sigdata);
229         gpgme_data_release(textdata);
230         g_free(textstr);
231         fclose(fp);
232         
233         return 0;
234 }
235
236 static SignatureStatus pgpmime_get_sig_status(MimeInfo *mimeinfo)
237 {
238         PrivacyDataPGP *data = (PrivacyDataPGP *) mimeinfo->privacy;
239         
240         g_return_val_if_fail(data != NULL, SIGNATURE_INVALID);
241
242         if (data->sigstatus == NULL && 
243             prefs_gpg_get_config()->auto_check_signatures)
244                 pgpmime_check_signature(mimeinfo);
245         
246         return sgpgme_sigstat_gpgme_to_privacy(data->ctx, data->sigstatus);
247 }
248
249 static gchar *pgpmime_get_sig_info_short(MimeInfo *mimeinfo)
250 {
251         PrivacyDataPGP *data = (PrivacyDataPGP *) mimeinfo->privacy;
252         
253         g_return_val_if_fail(data != NULL, g_strdup("Error"));
254
255         if (data->sigstatus == NULL && 
256             prefs_gpg_get_config()->auto_check_signatures)
257                 pgpmime_check_signature(mimeinfo);
258         
259         return sgpgme_sigstat_info_short(data->ctx, data->sigstatus);
260 }
261
262 static gchar *pgpmime_get_sig_info_full(MimeInfo *mimeinfo)
263 {
264         PrivacyDataPGP *data = (PrivacyDataPGP *) mimeinfo->privacy;
265         
266         g_return_val_if_fail(data != NULL, g_strdup("Error"));
267
268         if (data->sigstatus == NULL && 
269             prefs_gpg_get_config()->auto_check_signatures)
270                 pgpmime_check_signature(mimeinfo);
271         
272         return sgpgme_sigstat_info_full(data->ctx, data->sigstatus);
273 }
274
275 static gboolean pgpmime_is_encrypted(MimeInfo *mimeinfo)
276 {
277         MimeInfo *tmpinfo;
278         const gchar *tmpstr;
279         
280         if (mimeinfo->type != MIMETYPE_MULTIPART)
281                 return FALSE;
282         if (g_ascii_strcasecmp(mimeinfo->subtype, "encrypted"))
283                 return FALSE;
284         tmpstr = procmime_mimeinfo_get_parameter(mimeinfo, "protocol");
285         if ((tmpstr == NULL) || g_ascii_strcasecmp(tmpstr, "application/pgp-encrypted"))
286                 return FALSE;
287         if (g_node_n_children(mimeinfo->node) != 2)
288                 return FALSE;
289         
290         tmpinfo = (MimeInfo *) g_node_nth_child(mimeinfo->node, 0)->data;
291         if (tmpinfo->type != MIMETYPE_APPLICATION)
292                 return FALSE;
293         if (g_ascii_strcasecmp(tmpinfo->subtype, "pgp-encrypted"))
294                 return FALSE;
295         
296         tmpinfo = (MimeInfo *) g_node_nth_child(mimeinfo->node, 1)->data;
297         if (tmpinfo->type != MIMETYPE_APPLICATION)
298                 return FALSE;
299         if (g_ascii_strcasecmp(tmpinfo->subtype, "octet-stream"))
300                 return FALSE;
301         
302         return TRUE;
303 }
304
305 static MimeInfo *pgpmime_decrypt(MimeInfo *mimeinfo)
306 {
307         MimeInfo *encinfo, *decinfo, *parseinfo;
308         gpgme_data_t cipher = NULL, plain = NULL;
309         static gint id = 0;
310         FILE *dstfp;
311         gchar *fname;
312         gpgme_verify_result_t sigstat = NULL;
313         PrivacyDataPGP *data = NULL;
314         gpgme_ctx_t ctx;
315         gchar *chars;
316         size_t len;
317
318         if (gpgme_new(&ctx) != GPG_ERR_NO_ERROR)
319                 return NULL;
320
321         
322         g_return_val_if_fail(pgpmime_is_encrypted(mimeinfo), NULL);
323         
324         encinfo = (MimeInfo *) g_node_nth_child(mimeinfo->node, 1)->data;
325
326         cipher = sgpgme_data_from_mimeinfo(encinfo);
327         plain = sgpgme_decrypt_verify(cipher, &sigstat, ctx);
328
329         gpgme_data_release(cipher);
330         if (plain == NULL) {
331                 debug_print("plain is null!\n");
332                 gpgme_release(ctx);
333                 return NULL;
334         }
335
336         fname = g_strdup_printf("%s%cplaintext.%08x",
337                 get_mime_tmp_dir(), G_DIR_SEPARATOR, ++id);
338
339         if ((dstfp = g_fopen(fname, "wb")) == NULL) {
340                 FILE_OP_ERROR(fname, "fopen");
341                 g_free(fname);
342                 gpgme_data_release(plain);
343                 gpgme_release(ctx);
344                 debug_print("can't open!\n");
345                 return NULL;
346         }
347
348         fprintf(dstfp, "MIME-Version: 1.0\n");
349
350         chars = gpgme_data_release_and_get_mem(plain, &len);
351         if (len > 0)
352                 fwrite(chars, len, 1, dstfp);
353         fclose(dstfp);
354
355         parseinfo = procmime_scan_file(fname);
356         g_free(fname);
357         if (parseinfo == NULL) {
358                 gpgme_release(ctx);
359                 return NULL;
360         }
361         decinfo = g_node_first_child(parseinfo->node) != NULL ?
362                 g_node_first_child(parseinfo->node)->data : NULL;
363         if (decinfo == NULL) {
364                 gpgme_release(ctx);
365                 return NULL;
366         }
367
368         g_node_unlink(decinfo->node);
369         procmime_mimeinfo_free_all(parseinfo);
370
371         decinfo->tmp = TRUE;
372
373         if (sigstat != NULL && sigstat->signatures != NULL) {
374                 if (decinfo->privacy != NULL) {
375                         data = (PrivacyDataPGP *) decinfo->privacy;
376                 } else {
377                         data = pgpmime_new_privacydata();
378                         decinfo->privacy = (PrivacyData *) data;        
379                 }
380                 data->done_sigtest = TRUE;
381                 data->is_signed = TRUE;
382                 data->sigstatus = sigstat;
383                 if (data->ctx)
384                         gpgme_release(data->ctx);
385                 data->ctx = ctx;
386         } else
387                 gpgme_release(ctx);
388
389         return decinfo;
390 }
391
392 gboolean pgpmime_sign(MimeInfo *mimeinfo, PrefsAccount *account)
393 {
394         MimeInfo *msgcontent, *sigmultipart, *newinfo;
395         gchar *textstr, *micalg;
396         FILE *fp;
397         gchar *boundary = NULL;
398         gchar *sigcontent;
399         gpgme_ctx_t ctx;
400         gpgme_data_t gpgtext, gpgsig;
401         gpgme_error_t err;
402         size_t len;
403         struct passphrase_cb_info_s info;
404         gpgme_sign_result_t result = NULL;
405         gchar *test_msg;
406         
407         fp = my_tmpfile();
408         if (fp == NULL) {
409                 perror("my_tmpfile");
410                 return FALSE;
411         }
412         procmime_write_mimeinfo(mimeinfo, fp);
413         rewind(fp);
414
415         /* read temporary file into memory */
416         test_msg = file_read_stream_to_str(fp);
417         fclose(fp);
418         
419         memset (&info, 0, sizeof info);
420
421         /* remove content node from message */
422         msgcontent = (MimeInfo *) mimeinfo->node->children->data;
423         g_node_unlink(msgcontent->node);
424
425         /* create temporary multipart for content */
426         sigmultipart = procmime_mimeinfo_new();
427         sigmultipart->type = MIMETYPE_MULTIPART;
428         sigmultipart->subtype = g_strdup("signed");
429         
430         do {
431                 if (boundary)
432                         g_free(boundary);
433                 boundary = generate_mime_boundary("Sig");
434         } while (strstr(test_msg, boundary) != NULL);
435         
436         g_free(test_msg);
437
438         g_hash_table_insert(sigmultipart->typeparameters, g_strdup("boundary"),
439                             g_strdup(boundary));
440         g_hash_table_insert(sigmultipart->typeparameters, g_strdup("protocol"),
441                             g_strdup("application/pgp-signature"));
442         g_node_append(sigmultipart->node, msgcontent->node);
443         g_node_append(mimeinfo->node, sigmultipart->node);
444
445         /* write message content to temporary file */
446         fp = my_tmpfile();
447         if (fp == NULL) {
448                 perror("my_tmpfile");
449                 return FALSE;
450         }
451         procmime_write_mimeinfo(sigmultipart, fp);
452         rewind(fp);
453
454         /* read temporary file into memory */
455         textstr = get_canonical_content(fp, boundary);
456
457         fclose(fp);
458
459         gpgme_data_new_from_mem(&gpgtext, textstr, strlen(textstr), 0);
460         gpgme_data_new(&gpgsig);
461         gpgme_new(&ctx);
462         gpgme_set_textmode(ctx, 1);
463         gpgme_set_armor(ctx, 1);
464         gpgme_signers_clear (ctx);
465
466         if (!sgpgme_setup_signers(ctx, account)) {
467                 gpgme_release(ctx);
468                 return FALSE;
469         }
470
471         if (getenv("GPG_AGENT_INFO")) {
472                 debug_print("GPG_AGENT_INFO environment defined, running without passphrase callback\n");
473         } else {
474                 info.c = ctx;
475                 gpgme_set_passphrase_cb (ctx, gpgmegtk_passphrase_cb, &info);
476         }
477
478         err = gpgme_op_sign(ctx, gpgtext, gpgsig, GPGME_SIG_MODE_DETACH);
479         if (err != GPG_ERR_NO_ERROR) {
480                 debug_print("gpgme_op_sign error : %x\n", err);
481                 gpgme_release(ctx);
482                 return FALSE;
483         }
484         result = gpgme_op_sign_result(ctx);
485         if (result && result->signatures) {
486             if (gpgme_get_protocol(ctx) == GPGME_PROTOCOL_OpenPGP) {
487                 micalg = g_strdup_printf("PGP-%s", gpgme_hash_algo_name(
488                             result->signatures->hash_algo));
489             } else {
490                 micalg = g_strdup(gpgme_hash_algo_name(
491                             result->signatures->hash_algo));
492             }
493         } else {
494             /* can't get result (maybe no signing key?) */
495             debug_print("gpgme_op_sign_result error\n");
496             return FALSE;
497         }
498
499         gpgme_release(ctx);
500         sigcontent = gpgme_data_release_and_get_mem(gpgsig, &len);
501         gpgme_data_release(gpgtext);
502         g_free(textstr);
503
504         /* add signature */
505         g_hash_table_insert(sigmultipart->typeparameters, g_strdup("micalg"),
506                             micalg);
507
508         newinfo = procmime_mimeinfo_new();
509         newinfo->type = MIMETYPE_APPLICATION;
510         newinfo->subtype = g_strdup("pgp-signature");
511         g_hash_table_insert(newinfo->typeparameters, g_strdup("name"),
512                              g_strdup("signature.asc"));
513         newinfo->content = MIMECONTENT_MEM;
514         newinfo->disposition = DISPOSITIONTYPE_ATTACHMENT;
515         g_hash_table_insert(newinfo->dispositionparameters, g_strdup("filename"),
516                             g_strdup("signature.asc"));
517         newinfo->data.mem = g_malloc(len + 1);
518         g_memmove(newinfo->data.mem, sigcontent, len);
519         newinfo->data.mem[len] = '\0';
520         g_node_append(sigmultipart->node, newinfo->node);
521
522         g_free(sigcontent);
523
524         return TRUE;
525 }
526 gchar *pgpmime_get_encrypt_data(GSList *recp_names)
527 {
528         return sgpgme_get_encrypt_data(recp_names);
529 }
530
531 gboolean pgpmime_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
532 {
533         MimeInfo *msgcontent, *encmultipart, *newinfo;
534         FILE *fp;
535         gchar *boundary, *enccontent;
536         size_t len;
537         gchar *textstr;
538         gpgme_data_t gpgtext = NULL, gpgenc = NULL;
539         gpgme_ctx_t ctx = NULL;
540         gpgme_key_t *kset = NULL;
541         gchar **fprs = g_strsplit(encrypt_data, " ", -1);
542         gint i = 0;
543         while (fprs[i] && strlen(fprs[i])) {
544                 i++;
545         }
546         
547         kset = g_malloc(sizeof(gpgme_key_t)*(i+1));
548         memset(kset, 0, sizeof(gpgme_key_t)*(i+1));
549         gpgme_new(&ctx);
550         i = 0;
551         while (fprs[i] && strlen(fprs[i])) {
552                 gpgme_key_t key;
553                 gpgme_error_t err;
554                 err = gpgme_get_key(ctx, fprs[i], &key, 0);
555                 if (err) {
556                         debug_print("can't add key '%s'[%d] (%s)\n", fprs[i],i, gpgme_strerror(err));
557                         break;
558                 }
559                 debug_print("found %s at %d\n", fprs[i], i);
560                 kset[i] = key;
561                 i++;
562         }
563         
564         debug_print("Encrypting message content\n");
565
566         /* remove content node from message */
567         msgcontent = (MimeInfo *) mimeinfo->node->children->data;
568         g_node_unlink(msgcontent->node);
569
570         /* create temporary multipart for content */
571         encmultipart = procmime_mimeinfo_new();
572         encmultipart->type = MIMETYPE_MULTIPART;
573         encmultipart->subtype = g_strdup("encrypted");
574         boundary = generate_mime_boundary("Encrypt");
575         g_hash_table_insert(encmultipart->typeparameters, g_strdup("boundary"),
576                             g_strdup(boundary));
577         g_hash_table_insert(encmultipart->typeparameters, g_strdup("protocol"),
578                             g_strdup("application/pgp-encrypted"));
579         g_node_append(encmultipart->node, msgcontent->node);
580
581         /* write message content to temporary file */
582         fp = my_tmpfile();
583         if (fp == NULL) {
584                 perror("my_tmpfile");
585                 return FALSE;
586         }
587         procmime_write_mimeinfo(encmultipart, fp);
588         rewind(fp);
589
590         /* read temporary file into memory */
591         textstr = get_canonical_content(fp, boundary);
592
593         fclose(fp);
594
595         /* encrypt data */
596         gpgme_data_new_from_mem(&gpgtext, textstr, strlen(textstr), 0);
597         gpgme_data_new(&gpgenc);
598         gpgme_set_armor(ctx, 1);
599         gpgme_data_rewind(gpgtext);
600         
601         gpgme_op_encrypt(ctx, kset, GPGME_ENCRYPT_ALWAYS_TRUST, gpgtext, gpgenc);
602
603         gpgme_release(ctx);
604         enccontent = gpgme_data_release_and_get_mem(gpgenc, &len);
605         gpgme_data_release(gpgtext);
606         g_free(textstr);
607
608         /* create encrypted multipart */
609         g_node_unlink(msgcontent->node);
610         procmime_mimeinfo_free_all(msgcontent);
611         g_node_append(mimeinfo->node, encmultipart->node);
612
613         newinfo = procmime_mimeinfo_new();
614         newinfo->type = MIMETYPE_APPLICATION;
615         newinfo->subtype = g_strdup("pgp-encrypted");
616         newinfo->content = MIMECONTENT_MEM;
617         newinfo->data.mem = g_strdup("Version: 1\n");
618         g_node_append(encmultipart->node, newinfo->node);
619
620         newinfo = procmime_mimeinfo_new();
621         newinfo->type = MIMETYPE_APPLICATION;
622         newinfo->subtype = g_strdup("octet-stream");
623         newinfo->content = MIMECONTENT_MEM;
624         newinfo->data.mem = g_malloc(len + 1);
625         g_memmove(newinfo->data.mem, enccontent, len);
626         newinfo->data.mem[len] = '\0';
627         g_node_append(encmultipart->node, newinfo->node);
628
629         g_free(enccontent);
630
631         return TRUE;
632 }
633
634 static PrivacySystem pgpmime_system = {
635         "pgpmime",                      /* id */
636         "PGP MIME",                     /* name */
637
638         pgpmime_free_privacydata,       /* free_privacydata */
639
640         pgpmime_is_signed,              /* is_signed(MimeInfo *) */
641         pgpmime_check_signature,        /* check_signature(MimeInfo *) */
642         pgpmime_get_sig_status,         /* get_sig_status(MimeInfo *) */
643         pgpmime_get_sig_info_short,     /* get_sig_info_short(MimeInfo *) */
644         pgpmime_get_sig_info_full,      /* get_sig_info_full(MimeInfo *) */
645
646         pgpmime_is_encrypted,           /* is_encrypted(MimeInfo *) */
647         pgpmime_decrypt,                /* decrypt(MimeInfo *) */
648
649         TRUE,
650         pgpmime_sign,
651
652         TRUE,
653         pgpmime_get_encrypt_data,
654         pgpmime_encrypt,
655 };
656
657 void pgpmime_init()
658 {
659         privacy_register_system(&pgpmime_system);
660 }
661
662 void pgpmime_done()
663 {
664         privacy_unregister_system(&pgpmime_system);
665 }
666
667 #endif /* USE_GPGME */