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