Re: PGP signature of empty string

Peter Gutmann <[email protected]> Mon, 04 Mar 2013 22:01:19 +1300
Newsgroups gmane.comp.encryption.cryptlib
Message-ID <[email protected]>
Florian Mutter <[email protected]> writes:

>I have a problem with signing and checking a detached pgp signature of an
>empty string.

Hmm, why are you trying to sign an empty message?  Forgery of such a signature
on a message is trivial, you can transfer the signature to any other empty
message and it'll still verify.

>After some debugging I think this error comes from contextMessageFunction().
>When this is called from cryptEncrypt (to generate the hash) it set's the
>flag: CONTEXT_FLAG_HASH_DONE (line  544 of cryptctx.c) for zero length data.
>When cryptGetAttribute( CRYPT_ENVINFO_SIGNATURE_RESULT) is called the flag is
>checked and no hash comparison is performed at all. Maybe the check for
>already hashed data in line 524 needs to check for that second flag
>CONTEXT_FLAG_HASH_INITED and if that is set not stopping processing.
>
>I tested it without stopping there but then when the hashes are compared
>(compareDataConstTime()), they only match up to 16 Bytes and the rest of the
>35 Bytes does not match. I'm not sure if this is any helpful information. The
>hashes are SHA1. One generated by cryptlib and one by gpg for the empy string.
>gpg can verify the signature for the empty string.

Can you send me a signed file of this type, along with the code that you're
using to exercise the problem?  I'm not even sure how you'd create an empty
signed message with GPG, do you just sign a zero-length file?

>BTW: The sample code in the manual on page 92/93 to verify detached pgp
>signatures is missing the attribute CRYPT_ENVINFO_DETACHEDSIGNATURE set to 1
>and also in cryptPushData the signature should be pushed not the data.

Thanks, it'll be fixed in the next update.

Peter.


_______________________________________________
Cryptlib mailing list
[email protected] via Mail: [email protected]
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.