*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
gboolean is_signed;
gpgme_verify_result_t sigstatus;
gpgme_ctx_t ctx;
+ gboolean is_pkcs7;
};
static PrivacySystem pgpmime_system;
g_ascii_strcasecmp(parent->subtype, "signed"))
return FALSE;
protocol = procmime_mimeinfo_get_parameter(parent, "protocol");
- if ((protocol == NULL) || g_ascii_strcasecmp(protocol, "application/pgp-signature"))
+ if ((protocol == NULL) ||
+ (g_ascii_strcasecmp(protocol, "application/pgp-signature") &&
+ g_ascii_strcasecmp(protocol, "application/pkcs7-signature") &&
+ g_ascii_strcasecmp(protocol, "application/x-pkcs7-signature")))
return FALSE;
/* check if mimeinfo is the first child */
if (signature == NULL)
return FALSE;
if ((signature->type != MIMETYPE_APPLICATION) ||
- g_ascii_strcasecmp(signature->subtype, "pgp-signature"))
+ (g_ascii_strcasecmp(signature->subtype, "pgp-signature") &&
+ g_ascii_strcasecmp(signature->subtype, "pkcs7-signature") &&
+ g_ascii_strcasecmp(signature->subtype, "x-pkcs7-signature")))
return FALSE;
if (data == NULL) {
data = pgpmime_new_privacydata();
mimeinfo->privacy = (PrivacyData *) data;
}
+
+ if (!g_ascii_strcasecmp(signature->subtype, "pkcs7-signature") ||
+ !g_ascii_strcasecmp(signature->subtype, "x-pkcs7-signature"))
+ data->is_pkcs7 = TRUE;
+ else
+ data->is_pkcs7 = FALSE;
+
data->done_sigtest = TRUE;
data->is_signed = TRUE;
data = (PrivacyDataPGP *) mimeinfo->privacy;
gpgme_new(&data->ctx);
- debug_print("Checking PGP/MIME signature\n");
+ debug_print("Checking %s/MIME signature\n", data->is_pkcs7?"S":"PGP");
+
+ if (data->is_pkcs7) {
+ err = gpgme_set_protocol(data->ctx, GPGME_PROTOCOL_CMS);
+ } else
+ err = gpgme_set_protocol(data->ctx, GPGME_PROTOCOL_OpenPGP);
+
+ if (err) {
+ debug_print ("gpgme_set_protocol failed: %s\n",
+ gpgme_strerror (err));
+ }
parent = procmime_mimeinfo_parent(mimeinfo);
fp = g_fopen(parent->data.filename, "rb");
signature = (MimeInfo *) mimeinfo->node->next->data;
sigdata = sgpgme_data_from_mimeinfo(signature);
+ err = 0;
+ if (signature->encoding_type == ENC_BASE64) {
+ err = gpgme_data_set_encoding (sigdata, GPGME_DATA_ENCODING_BASE64);
+ }
+
+ if (err) {
+ debug_print ("gpgme_data_set_encoding failed: %s\n",
+ gpgme_strerror (err));
+ }
+
data->sigstatus =
sgpgme_verify_signature (data->ctx, sigdata, textdata, NULL);
PrivacyDataPGP *data = NULL;
gpgme_ctx_t ctx;
gchar *chars;
- int len;
+ size_t len;
if (gpgme_new(&ctx) != GPG_ERR_NO_ERROR)
return NULL;
MimeInfo *msgcontent, *sigmultipart, *newinfo;
gchar *textstr, *micalg;
FILE *fp;
- gchar *boundary, *sigcontent;
+ gchar *boundary = NULL;
+ gchar *sigcontent;
gpgme_ctx_t ctx;
gpgme_data_t gpgtext, gpgsig;
size_t len;
struct passphrase_cb_info_s info;
gpgme_sign_result_t result = NULL;
+ gchar *test_msg;
+
+ fp = my_tmpfile();
+ if (fp == NULL) {
+ perror("my_tmpfile");
+ return FALSE;
+ }
+ procmime_write_mimeinfo(mimeinfo, fp);
+ rewind(fp);
+ /* read temporary file into memory */
+ test_msg = file_read_stream_to_str(fp);
+ fclose(fp);
+
memset (&info, 0, sizeof info);
/* remove content node from message */
sigmultipart = procmime_mimeinfo_new();
sigmultipart->type = MIMETYPE_MULTIPART;
sigmultipart->subtype = g_strdup("signed");
- boundary = generate_mime_boundary("Signature");
+
+ do {
+ if (boundary)
+ g_free(boundary);
+ boundary = generate_mime_boundary("Sig");
+ } while (strstr(test_msg, boundary) != NULL);
+
+ g_free(test_msg);
+
g_hash_table_insert(sigmultipart->typeparameters, g_strdup("boundary"),
g_strdup(boundary));
g_hash_table_insert(sigmultipart->typeparameters, g_strdup("protocol"),
/* write message content to temporary file */
fp = my_tmpfile();
+ if (fp == NULL) {
+ perror("my_tmpfile");
+ return FALSE;
+ }
procmime_write_mimeinfo(sigmultipart, fp);
rewind(fp);
/* write message content to temporary file */
fp = my_tmpfile();
+ if (fp == NULL) {
+ perror("my_tmpfile");
+ return FALSE;
+ }
procmime_write_mimeinfo(encmultipart, fp);
rewind(fp);