Re: On gmime signing: Was: compile error from current git master head
Detlef Graef <[email protected]> Wed, 8 Sep 2021 23:47:54 +0200
| Newsgroups | gmane.comp.gnome.apps.pan.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------565438966E0D644E8F0F9564
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Am 08.09.21 um 23:03 schrieb Detlef Graef:
> Am 08.09.21 um 19:25 schrieb Dominique Dumont:
>> On Wednesday, 8 September 2021 00:04:51 CEST Jack wrote:
>>> On 2021.09.07 03:44, Dominique Dumont wrote:
>>>> Gmime doc mentions: "Attempts to sign the content MIME part with
>>>> userid 's private key using the ctx signing context. "
>>>>
>>>> I guess this code is used when posting a MIME message with a part
>>>> signed with your private gpg key. I never tried that.
>>>
>>> Yes but how does one do that? I have now posted two articles (to
>>> comp.security.pgp.test) in one checking "PGP-Sign the article" and in
>>> the other checking "PGP-Encrypt the article" but both appear to have
>>> been sent with no encryption or signing. I always thought of Mime as
>>> dealing with attachments, but I see no way to attach anything to a
>>> post.
>>
>> Yes. I cannot get it to work either.
>>
>>> From the link to the gmime docs, is it correct to assume that if
>>> the signing failed, I would have seen some sort of error notification?
>>
>> Indeed, but there's a small error in dgreaf patch. I've added a comment in his
>> MR.
>
> Yes, you are right.
>
> From:
>
> https://developer-old.gnome.org/gmime/stable/GMimeMultipartSigned.html#g-mime-multipart-signed-sign
>
> "Returns a new GMimeMultipartSigned object on success or NULL on fail."
>
> So it has to be checked for "== NULL" and a cleanup has to be done.
>
I propose this patch (see also attached file):
--- mime-utils-prepatch.cc 2021-09-08 23:31:43.334217625 +0200
+++ mime-utils.cc 2021-09-08 23:32:53.635837178 +0200
@@ -1749,7 +1749,8 @@
#ifdef HAVE_GMIME_30
GMimeObject *gmo;
gmo = g_mime_message_get_mime_part (body);
- if (g_mime_multipart_signed_sign (gpg_ctx, gmo, uid.c_str(), &err) <0)
+ mps = g_mime_multipart_signed_sign (gpg_ctx, gmo, uid.c_str(), &err);
+ if ( mps == NULL)
#else
if (g_mime_multipart_signed_sign (mps, GMIME_OBJECT (part),
gpg_ctx, uid.c_str(), GMIME_DIGEST_ALGO_SHA1, &err) <0)
#endif
@@ -1784,7 +1785,7 @@
#ifdef HAVE_GMIME_30
if (g_mime_multipart_encrypted_encrypt(gpg_ctx, GMIME_OBJECT
(part), sign, uid.c_str(),
- GMIME_ENCRYPT_NONE, rcp,
&err) < 0)
+ GMIME_ENCRYPT_NONE, rcp,
&err) == NULL)
#else
if (g_mime_multipart_encrypted_encrypt(mpe, GMIME_OBJECT (part),
gpg_ctx, sign,
uid.c_str(),
GMIME_DIGEST_ALGO_SHA1, rcp, &err) < 0)
Detlef
--------------565438966E0D644E8F0F9564
Content-Type: text/x-patch; charset=UTF-8;
name="patch20210908.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="patch20210908.patch"
--- mime-utils-prepatch.cc 2021-09-08 23:31:43.334217625 +0200
+++ mime-utils.cc 2021-09-08 23:32:53.635837178 +0200
@@ -1749,7 +1749,8 @@
#ifdef HAVE_GMIME_30
GMimeObject *gmo;
gmo = g_mime_message_get_mime_part (body);
- if (g_mime_multipart_signed_sign (gpg_ctx, gmo, uid.c_str(), &err) <0)
+ mps = g_mime_multipart_signed_sign (gpg_ctx, gmo, uid.c_str(), &err);
+ if ( mps == NULL)
#else
if (g_mime_multipart_signed_sign (mps, GMIME_OBJECT (part), gpg_ctx, uid.c_str(), GMIME_DIGEST_ALGO_SHA1, &err) <0)
#endif
@@ -1784,7 +1785,7 @@
#ifdef HAVE_GMIME_30
if (g_mime_multipart_encrypted_encrypt(gpg_ctx, GMIME_OBJECT (part), sign, uid.c_str(),
- GMIME_ENCRYPT_NONE, rcp, &err) < 0)
+ GMIME_ENCRYPT_NONE, rcp, &err) == NULL)
#else
if (g_mime_multipart_encrypted_encrypt(mpe, GMIME_OBJECT (part), gpg_ctx, sign,
uid.c_str(), GMIME_DIGEST_ALGO_SHA1, rcp, &err) < 0)
--------------565438966E0D644E8F0F9564
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline
X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KUGFuLWRldmVs
IG1haWxpbmcgbGlzdApQYW4tZGV2ZWxAbm9uZ251Lm9yZwpodHRwczovL2xpc3RzLm5vbmdudS5v
cmcvbWFpbG1hbi9saXN0aW5mby9wYW4tZGV2ZWwK
--------------565438966E0D644E8F0F9564--