When sending a signed message using GPG, it always includes a line that says Hash: SHA256 right at the top of my email. I was wondering if/why it's required, and if not, how I can remove it (in an effort to remove some clutter).

I noticed that when attaching a signature using PGP/MIME, the Hash header is not included. Is there a reason for this? Is it a configuration option?


This hash function indication is there to support streamed processing. A signature on some data always begins by processing the message to be signed (or verified) with a hash function, e.g. SHA-256. Then, the hash function output is that which is used in the rest of the cryptographic operations.

The "signature" itself, i.e. the binary thing that GnuPG adds at the end of the email, contains the complete specification of which hash function to use, so the Hash: header at the beginning is conceptually redundant. However, the point here is that the GnuPG-produced binary structure is at the end of the email. The recipient's emailing software must then, upon reception of the email, first read it entirely, to reach the GnuPGP object at the end, and then read the full email again in order to hash it. On the other hand, if an explicit hash indication appears right at the beginning of the email, then the hashing can occur while the email is read the first time: this is streamed processing.

This makes sense if you consider that PGP was designed a good twenty years ago. At that time, software could not necessarily afford to keep a 2 MB data file in RAM; streamed processing was important. Well, stream processing is still important, but no longer for data sizes as are commonly encountered in emails. Over the years, average email size has not grown as fast as average RAM size. Nowadays, we do streamed processing for big video files, not for emails. So this "Hash:" header can be considered as a remnant of older times.

It still is part of the ASCII-armor format for cleartext-signed messages, though; theoretically, you may remove it only if the hash function is MD5. Since the information is redundant, it is possible that GnuPG would accept to process an incoming message lacking this "Hash:" header. Or not. I encourage you to try; but be aware that you may encounter interoperability issues if you deviate from the standard.

PGP/MIME does not use "ASCII armor" but MIME, the signature object then being an attached file, as if it was a picture. MIME cares less about streamed processing than the original PGP.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.