PGP signature of empty string

Florian Mutter <[email protected]> Fri, 1 Mar 2013 17:05:15 +0100
Newsgroups gmane.comp.encryption.cryptlib
Message-ID <[email protected]>
Hey,

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

When I try to sign the empty string with cryptlib, it return Bad Argument 2 for cryptPushData() because isReadPtr() wants a length of > 0.

If I check such a signature from gpg the status of cryptPopData is 0 but the CRYPT_ENVINFO_SIGNATURE_RESULT is CRYPT_ERROR_COMPLETE. The same code is working for signatures of the same source for a non empty string. 

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.

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.

With regards,
Florian

_______________________________________________
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.
smime.p7s (application/pkcs7-signature, 4.2 KB) - not displayed