2005-10-19 [colin] 1.9.15cvs77
[claws.git] / src / plugins / pgpmime / pgpmime.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2003 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         if (fp == NULL) {
200                 perror("my_tmpfile");
201                 return 0;
202         }
203         g_return_val_if_fail(fp != NULL, SIGNATURE_INVALID);
204         
205         boundary = g_hash_table_lookup(parent->typeparameters, "boundary");
206         if (!boundary)
207                 return 0;
208
209         textstr = get_canonical_content(fp, boundary);
210
211         err = gpgme_data_new_from_mem(&textdata, textstr, strlen(textstr), 0);
212         if (err) {
213                 debug_print ("gpgme_data_new_from_mem failed: %s\n",
214                    gpgme_strerror (err));
215         }
216         signature = (MimeInfo *) mimeinfo->node->next->data;
217         sigdata = sgpgme_data_from_mimeinfo(signature);
218
219         err = 0;
220         if (signature->encoding_type == ENC_BASE64) {
221                 err = gpgme_data_set_encoding (sigdata, GPGME_DATA_ENCODING_BASE64);
222         }
223         
224         if (err) {
225                 debug_print ("gpgme_data_set_encoding failed: %s\n",
226                         gpgme_strerror (err));
227         }
228
229         data->sigstatus =
230                 sgpgme_verify_signature (data->ctx, sigdata, textdata, NULL);
231
232         gpgme_data_release(sigdata);
233         gpgme_data_release(textdata);
234         g_free(textstr);
235         fclose(fp);
236         
237         return 0;
238 }
239
240 static SignatureStatus pgpmime_get_sig_status(MimeInfo *mimeinfo)
241 {
242         PrivacyDataPGP *data = (PrivacyDataPGP *) mimeinfo->privacy;
243         
244         g_return_val_if_fail(data != NULL, SIGNATURE_INVALID);
245
246         if (data->sigstatus == NULL && 
247             prefs_gpg_get_config()->auto_check_signatures)
248                 pgpmime_check_signature(mimeinfo);
249         
250         return sgpgme_sigstat_gpgme_to_privacy(data->ctx, data->sigstatus);
251 }
252
253 static gchar *pgpmime_get_sig_info_short(MimeInfo *mimeinfo)
254 {
255         PrivacyDataPGP *data = (PrivacyDataPGP *) mimeinfo->privacy;
256         
257         g_return_val_if_fail(data != NULL, g_strdup("Error"));
258
259         if (data->sigstatus == NULL && 
260             prefs_gpg_get_config()->auto_check_signatures)
261                 pgpmime_check_signature(mimeinfo);
262         
263         return sgpgme_sigstat_info_short(data->ctx, data->sigstatus);
264 }
265
266 static gchar *pgpmime_get_sig_info_full(MimeInfo *mimeinfo)
267 {
268         PrivacyDataPGP *data = (PrivacyDataPGP *) mimeinfo->privacy;
269         
270         g_return_val_if_fail(data != NULL, g_strdup("Error"));
271
272         if (data->sigstatus == NULL && 
273             prefs_gpg_get_config()->auto_check_signatures)
274                 pgpmime_check_signature(mimeinfo);
275         
276         return sgpgme_sigstat_info_full(data->ctx, data->sigstatus);
277 }
278
279 static gboolean pgpmime_is_encrypted(MimeInfo *mimeinfo)
280 {
281         MimeInfo *tmpinfo;
282         const gchar *tmpstr;
283         
284         if (mimeinfo->type != MIMETYPE_MULTIPART)
285                 return FALSE;
286         if (g_ascii_strcasecmp(mimeinfo->subtype, "encrypted"))
287                 return FALSE;
288         tmpstr = procmime_mimeinfo_get_parameter(mimeinfo, "protocol");
289         if ((tmpstr == NULL) || g_ascii_strcasecmp(tmpstr, "application/pgp-encrypted"))
290                 return FALSE;
291         if (g_node_n_children(mimeinfo->node) != 2)
292                 return FALSE;
293         
294         tmpinfo = (MimeInfo *) g_node_nth_child(mimeinfo->node, 0)->data;
295         if (tmpinfo->type != MIMETYPE_APPLICATION)
296                 return FALSE;
297         if (g_ascii_strcasecmp(tmpinfo->subtype, "pgp-encrypted"))
298                 return FALSE;
299         
300         tmpinfo = (MimeInfo *) g_node_nth_child(mimeinfo->node, 1)->data;
301         if (tmpinfo->type != MIMETYPE_APPLICATION)
302                 return FALSE;
303         if (g_ascii_strcasecmp(tmpinfo->subtype, "octet-stream"))
304                 return FALSE;
305         
306         return TRUE;
307 }
308
309 static MimeInfo *pgpmime_decrypt(MimeInfo *mimeinfo)
310 {
311         MimeInfo *encinfo, *decinfo, *parseinfo;
312         gpgme_data_t cipher = NULL, plain = NULL;
313         static gint id = 0;
314         FILE *dstfp;
315         gchar *fname;
316         gpgme_verify_result_t sigstat = NULL;
317         PrivacyDataPGP *data = NULL;
318         gpgme_ctx_t ctx;
319         gchar *chars;
320         size_t len;
321
322         if (gpgme_new(&ctx) != GPG_ERR_NO_ERROR)
323                 return NULL;
324
325         
326         g_return_val_if_fail(pgpmime_is_encrypted(mimeinfo), NULL);
327         
328         encinfo = (MimeInfo *) g_node_nth_child(mimeinfo->node, 1)->data;
329
330         cipher = sgpgme_data_from_mimeinfo(encinfo);
331         plain = sgpgme_decrypt_verify(cipher, &sigstat, ctx);
332
333         gpgme_data_release(cipher);
334         if (plain == NULL) {
335                 debug_print("plain is null!\n");
336                 gpgme_release(ctx);
337                 return NULL;
338         }
339
340         fname = g_strdup_printf("%s%cplaintext.%08x",
341                 get_mime_tmp_dir(), G_DIR_SEPARATOR, ++id);
342
343         if ((dstfp = g_fopen(fname, "wb")) == NULL) {
344                 FILE_OP_ERROR(fname, "fopen");
345                 g_free(fname);
346                 gpgme_data_release(plain);
347                 gpgme_release(ctx);
348                 debug_print("can't open!\n");
349                 return NULL;
350         }
351
352         fprintf(dstfp, "MIME-Version: 1.0\n");
353
354         chars = gpgme_data_release_and_get_mem(plain, &len);
355         if (len > 0)
356                 fwrite(chars, len, 1, dstfp);
357         fclose(dstfp);
358
359         parseinfo = procmime_scan_file(fname);
360         g_free(fname);
361         if (parseinfo == NULL) {
362                 gpgme_release(ctx);
363                 return NULL;
364         }
365         decinfo = g_node_first_child(parseinfo->node) != NULL ?
366                 g_node_first_child(parseinfo->node)->data : NULL;
367         if (decinfo == NULL) {
368                 gpgme_release(ctx);
369                 return NULL;
370         }
371
372         g_node_unlink(decinfo->node);
373         procmime_mimeinfo_free_all(parseinfo);
374
375         decinfo->tmp = TRUE;
376
377         if (sigstat != NULL && sigstat->signatures != NULL) {
378                 if (decinfo->privacy != NULL) {
379                         data = (PrivacyDataPGP *) decinfo->privacy;
380                 } else {
381                         data = pgpmime_new_privacydata();
382                         decinfo->privacy = (PrivacyData *) data;        
383                 }
384                 data->done_sigtest = TRUE;
385                 data->is_signed = TRUE;
386                 data->sigstatus = sigstat;
387                 if (data->ctx)
388                         gpgme_release(data->ctx);
389                 data->ctx = ctx;
390         } else
391                 gpgme_release(ctx);
392
393         return decinfo;
394 }
395
396 gboolean pgpmime_sign(MimeInfo *mimeinfo, PrefsAccount *account)
397 {
398         MimeInfo *msgcontent, *sigmultipart, *newinfo;
399         gchar *textstr, *micalg;
400         FILE *fp;
401         gchar *boundary = NULL;
402         gchar *sigcontent;
403         gpgme_ctx_t ctx;
404         gpgme_data_t gpgtext, gpgsig;
405         size_t len;
406         struct passphrase_cb_info_s info;
407         gpgme_sign_result_t result = NULL;
408         gchar *test_msg;
409         
410         fp = my_tmpfile();
411         if (fp == NULL) {
412                 perror("my_tmpfile");
413                 return FALSE;
414         }
415         procmime_write_mimeinfo(mimeinfo, fp);
416         rewind(fp);
417
418         /* read temporary file into memory */
419         test_msg = file_read_stream_to_str(fp);
420         fclose(fp);
421         
422         memset (&info, 0, sizeof info);
423
424         /* remove content node from message */
425         msgcontent = (MimeInfo *) mimeinfo->node->children->data;
426         g_node_unlink(msgcontent->node);
427
428         /* create temporary multipart for content */
429         sigmultipart = procmime_mimeinfo_new();
430         sigmultipart->type = MIMETYPE_MULTIPART;
431         sigmultipart->subtype = g_strdup("signed");
432         
433         do {
434                 if (boundary)
435                         g_free(boundary);
436                 boundary = generate_mime_boundary("Sig");
437         } while (strstr(test_msg, boundary) != NULL);
438         
439         g_free(test_msg);
440
441         g_hash_table_insert(sigmultipart->typeparameters, g_strdup("boundary"),
442                             g_strdup(boundary));
443         g_hash_table_insert(sigmultipart->typeparameters, g_strdup("protocol"),
444                             g_strdup("application/pgp-signature"));
445         g_node_append(sigmultipart->node, msgcontent->node);
446         g_node_append(mimeinfo->node, sigmultipart->node);
447
448         /* write message content to temporary file */
449         fp = my_tmpfile();
450         if (fp == NULL) {
451                 perror("my_tmpfile");
452                 return FALSE;
453         }
454         procmime_write_mimeinfo(sigmultipart, fp);
455         rewind(fp);
456
457         /* read temporary file into memory */
458         textstr = get_canonical_content(fp, boundary);
459
460         fclose(fp);
461
462         gpgme_data_new_from_mem(&gpgtext, textstr, strlen(textstr), 0);
463         gpgme_data_new(&gpgsig);
464         gpgme_new(&ctx);
465         gpgme_set_textmode(ctx, 1);
466         gpgme_set_armor(ctx, 1);
467         gpgme_signers_clear (ctx);
468
469         if (!sgpgme_setup_signers(ctx, account)) {
470                 gpgme_release(ctx);
471                 return FALSE;
472         }
473
474         if (!getenv("GPG_AGENT_INFO")) {
475                 info.c = ctx;
476                 gpgme_set_passphrase_cb (ctx, gpgmegtk_passphrase_cb, &info);
477         }
478
479         if (gpgme_op_sign(ctx, gpgtext, gpgsig, GPGME_SIG_MODE_DETACH) != GPG_ERR_NO_ERROR) {
480                 gpgme_release(ctx);
481                 return FALSE;
482         }
483         result = gpgme_op_sign_result(ctx);
484         if (result && result->signatures) {
485             if (gpgme_get_protocol(ctx) == GPGME_PROTOCOL_OpenPGP) {
486                 micalg = g_strdup_printf("PGP-%s", gpgme_hash_algo_name(
487                             result->signatures->hash_algo));
488             } else {
489                 micalg = g_strdup(gpgme_hash_algo_name(
490                             result->signatures->hash_algo));
491             }
492         } else {
493             /* can't get result (maybe no signing key?) */
494             return FALSE;
495         }
496
497         gpgme_release(ctx);
498         sigcontent = gpgme_data_release_and_get_mem(gpgsig, &len);
499         gpgme_data_release(gpgtext);
500         g_free(textstr);
501
502         /* add signature */
503         g_hash_table_insert(sigmultipart->typeparameters, g_strdup("micalg"),
504                             micalg);
505
506         newinfo = procmime_mimeinfo_new();
507         newinfo->type = MIMETYPE_APPLICATION;
508         newinfo->subtype = g_strdup("pgp-signature");
509         newinfo->content = MIMECONTENT_MEM;
510         newinfo->data.mem = g_malloc(len + 1);
511         g_memmove(newinfo->data.mem, sigcontent, len);
512         newinfo->data.mem[len] = '\0';
513         g_node_append(sigmultipart->node, newinfo->node);
514
515         g_free(sigcontent);
516
517         return TRUE;
518 }
519 gchar *pgpmime_get_encrypt_data(GSList *recp_names)
520 {
521         return sgpgme_get_encrypt_data(recp_names);
522 }
523
524 gboolean pgpmime_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
525 {
526         MimeInfo *msgcontent, *encmultipart, *newinfo;
527         FILE *fp;
528         gchar *boundary, *enccontent;
529         size_t len;
530         gchar *textstr;
531         gpgme_data_t gpgtext = NULL, gpgenc = NULL;
532         gpgme_ctx_t ctx = NULL;
533         gpgme_key_t *kset = NULL;
534         gchar **fprs = g_strsplit(encrypt_data, " ", -1);
535         gint i = 0;
536         while (fprs[i] && strlen(fprs[i])) {
537                 i++;
538         }
539         
540         kset = g_malloc(sizeof(gpgme_key_t)*(i+1));
541         memset(kset, 0, sizeof(gpgme_key_t)*(i+1));
542         gpgme_new(&ctx);
543         i = 0;
544         while (fprs[i] && strlen(fprs[i])) {
545                 gpgme_key_t key;
546                 gpgme_error_t err;
547                 err = gpgme_get_key(ctx, fprs[i], &key, 0);
548                 if (err) {
549                         debug_print("can't add key '%s'[%d] (%s)\n", fprs[i],i, gpgme_strerror(err));
550                         break;
551                 }
552                 debug_print("found %s at %d\n", fprs[i], i);
553                 kset[i] = key;
554                 i++;
555         }
556         
557         debug_print("Encrypting message content\n");
558
559         /* remove content node from message */
560         msgcontent = (MimeInfo *) mimeinfo->node->children->data;
561         g_node_unlink(msgcontent->node);
562
563         /* create temporary multipart for content */
564         encmultipart = procmime_mimeinfo_new();
565         encmultipart->type = MIMETYPE_MULTIPART;
566         encmultipart->subtype = g_strdup("encrypted");
567         boundary = generate_mime_boundary("Encrypt");
568         g_hash_table_insert(encmultipart->typeparameters, g_strdup("boundary"),
569                             g_strdup(boundary));
570         g_hash_table_insert(encmultipart->typeparameters, g_strdup("protocol"),
571                             g_strdup("application/pgp-encrypted"));
572         g_node_append(encmultipart->node, msgcontent->node);
573
574         /* write message content to temporary file */
575         fp = my_tmpfile();
576         if (fp == NULL) {
577                 perror("my_tmpfile");
578                 return FALSE;
579         }
580         procmime_write_mimeinfo(encmultipart, fp);
581         rewind(fp);
582
583         /* read temporary file into memory */
584         textstr = get_canonical_content(fp, boundary);
585
586         fclose(fp);
587
588         /* encrypt data */
589         gpgme_data_new_from_mem(&gpgtext, textstr, strlen(textstr), 0);
590         gpgme_data_new(&gpgenc);
591         gpgme_set_armor(ctx, 1);
592         gpgme_data_rewind(gpgtext);
593         
594         gpgme_op_encrypt(ctx, kset, GPGME_ENCRYPT_ALWAYS_TRUST, gpgtext, gpgenc);
595
596         gpgme_release(ctx);
597         enccontent = gpgme_data_release_and_get_mem(gpgenc, &len);
598         gpgme_data_release(gpgtext);
599         g_free(textstr);
600
601         /* create encrypted multipart */
602         g_node_unlink(msgcontent->node);
603         procmime_mimeinfo_free_all(msgcontent);
604         g_node_append(mimeinfo->node, encmultipart->node);
605
606         newinfo = procmime_mimeinfo_new();
607         newinfo->type = MIMETYPE_APPLICATION;
608         newinfo->subtype = g_strdup("pgp-encrypted");
609         newinfo->content = MIMECONTENT_MEM;
610         newinfo->data.mem = g_strdup("Version: 1\n");
611         g_node_append(encmultipart->node, newinfo->node);
612
613         newinfo = procmime_mimeinfo_new();
614         newinfo->type = MIMETYPE_APPLICATION;
615         newinfo->subtype = g_strdup("octet-stream");
616         newinfo->content = MIMECONTENT_MEM;
617         newinfo->data.mem = g_malloc(len + 1);
618         g_memmove(newinfo->data.mem, enccontent, len);
619         newinfo->data.mem[len] = '\0';
620         g_node_append(encmultipart->node, newinfo->node);
621
622         g_free(enccontent);
623
624         return TRUE;
625 }
626
627 static PrivacySystem pgpmime_system = {
628         "pgpmime",                      /* id */
629         "PGP MIME",                     /* name */
630
631         pgpmime_free_privacydata,       /* free_privacydata */
632
633         pgpmime_is_signed,              /* is_signed(MimeInfo *) */
634         pgpmime_check_signature,        /* check_signature(MimeInfo *) */
635         pgpmime_get_sig_status,         /* get_sig_status(MimeInfo *) */
636         pgpmime_get_sig_info_short,     /* get_sig_info_short(MimeInfo *) */
637         pgpmime_get_sig_info_full,      /* get_sig_info_full(MimeInfo *) */
638
639         pgpmime_is_encrypted,           /* is_encrypted(MimeInfo *) */
640         pgpmime_decrypt,                /* decrypt(MimeInfo *) */
641
642         TRUE,
643         pgpmime_sign,
644
645         TRUE,
646         pgpmime_get_encrypt_data,
647         pgpmime_encrypt,
648 };
649
650 void pgpmime_init()
651 {
652         privacy_register_system(&pgpmime_system);
653 }
654
655 void pgpmime_done()
656 {
657         privacy_unregister_system(&pgpmime_system);
658 }
659
660 #endif /* USE_GPGME */