1 /* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */ 2 /* Balsa E-Mail Client 3 * Copyright (C) 1997-2013 Stuart Parmenter and others, 4 * See the file AUTHORS for a list. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2, or (at your option) 9 * any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 19 * 02111-1307, USA. 20 */ 21 22 #ifndef __RFC3156_H__ 23 #define __RFC3156_H__ 24 25 #ifndef BALSA_VERSION 26 # error "Include config.h before this file." 27 #endif 28 29 /* bits to define the protection method; needed even when we don't 30 * HAVE_GPGME */ 31 #define LIBBALSA_PROTECT_OPENPGP (1 << 2) /* RFC 2440 (OpenPGP) */ 32 #define LIBBALSA_PROTECT_SMIMEV3 (1 << 3) /* RFC 2633 (S/MIME v3) */ 33 #define LIBBALSA_PROTECT_RFC3156 (1 << 4) /* RFC 3156 (PGP/MIME) */ 34 35 #ifdef HAVE_GPGME 36 37 #include <gpgme.h> 38 #include "libbalsa.h" 39 #include "misc.h" 40 #include "gmime-gpgme-signature.h" 41 42 43 /* bits to define the protection mode: signed or encrypted */ 44 #define LIBBALSA_PROTECT_SIGN (1 << 0) 45 #define LIBBALSA_PROTECT_ENCRYPT (1 << 1) 46 #define LIBBALSA_PROTECT_MODE (3 << 0) 47 48 /* bits to define the protection method */ 49 #define LIBBALSA_PROTECT_PROTOCOL (7 << 2) 50 51 /* indicate broken structure */ 52 #define LIBBALSA_PROTECT_ERROR (1 << 5) 53 54 /* indicate that uid's should always be trusted */ 55 #define LIBBALSA_PROTECT_ALWAYS_TRUST (1 << 6) 56 57 58 /* some custom error messages */ 59 #define GPG_ERR_TRY_AGAIN GPG_ERR_USER_15 60 #define GPG_ERR_NOT_SIGNED GPG_ERR_USER_16 61 62 63 gint libbalsa_message_body_protection(LibBalsaMessageBody * body); 64 gboolean libbalsa_can_encrypt_for_all(InternetAddressList * recipients, 65 gpgme_protocol_t protocol); 66 67 /* routines dealing with RFC 2633 and RFC 3156 stuff */ 68 gboolean libbalsa_sign_mime_object(GMimeObject ** content, 69 const gchar * rfc822_for, 70 gpgme_protocol_t protocol, 71 GtkWindow * parent, 72 GError ** error); 73 gboolean libbalsa_encrypt_mime_object(GMimeObject ** content, 74 GList * rfc822_for, 75 gpgme_protocol_t protocol, 76 gboolean always_trust, 77 GtkWindow * parent, 78 GError ** error); 79 gboolean libbalsa_sign_encrypt_mime_object(GMimeObject ** content, 80 const gchar * rfc822_signer, 81 GList * rfc822_for, 82 gpgme_protocol_t protocol, 83 gboolean always_trust, 84 GtkWindow * parent, 85 GError ** error); 86 gboolean libbalsa_body_check_signature(LibBalsaMessageBody * body, 87 gpgme_protocol_t protocol); 88 LibBalsaMessageBody *libbalsa_body_decrypt(LibBalsaMessageBody * body, 89 gpgme_protocol_t protocol, 90 GtkWindow * parent); 91 92 /* routines dealing with RFC 2440 stuff */ 93 gboolean libbalsa_rfc2440_sign_encrypt(GMimePart * part, 94 const gchar * sign_for, 95 GList * encrypt_for, 96 gboolean always_trust, 97 GtkWindow * parent, 98 GError ** error); 99 gpgme_error_t libbalsa_rfc2440_verify(GMimePart * part, 100 GMimeGpgmeSigstat ** sig_info); 101 gpgme_error_t libbalsa_rfc2440_decrypt(GMimePart * part, 102 GMimeGpgmeSigstat ** sig_info, 103 GtkWindow * parent); 104 105 /* helper functions to convert states to human-readable form */ 106 const gchar *libbalsa_gpgme_sig_protocol_name(gpgme_protocol_t protocol); 107 const gchar *libbalsa_gpgme_sig_stat_to_gchar(gpgme_error_t stat); 108 const gchar *libbalsa_gpgme_validity_to_gchar(gpgme_validity_t validity); 109 const gchar *libbalsa_gpgme_validity_to_gchar_short(gpgme_validity_t validity); 110 gchar *libbalsa_signature_info_to_gchar(GMimeGpgmeSigstat * info, 111 const gchar * date_string); 112 113 #ifdef HAVE_GPG 114 115 typedef enum { 116 GPG_KEYSERVER_IMPORT = 1, 117 GPG_KEYSERVER_UPDATE 118 } gpg_keyserver_action_t; 119 120 gboolean gpg_keyserver_op(const gchar * fingerprint, 121 gpg_keyserver_action_t action, 122 GtkWindow * parent); 123 124 #endif 125 #endif /* HAVE_GPGME */ 126 #endif /* __RFC3156_GPG_H__ */ 127