What exactly is digested in an S/MIME signated-only e-mail?

It's definitely not only a sha256-digest of the original message, which means that

$ openssl dgst -sha256 <<< "Text"

would never create the digest that is created for a S/MIME mail with the exact same "Text".

I've read and tried to understand information about this in RFC 5751 (in section, but it's still unclear to me, what exactly is digested for a S/MIME e-mail.

How is the original message prepared and enhanced before being hashed and encrypted?

If I understood correctly, some CMS processing and transfer-encoding is done for preparation. Is it possible to put the entire process into easy words?

Notes like these (in section 3.1) are even more confusing:

These (three) steps are descriptive rather than prescriptive. The implementer is free to use any procedure as long as the result is the same.

How can different e-mail-applications even work together on a basis of such vague descriptions?


From RFC 5652, section 5.4

The message digest calculation process computes a message digest on either the content being signed or the content together with the signed attributes.

But you can verify the (cms-)digest of the plaintext by hand:

  1. Save signed mail from Thunderbird as Test.eml
  2. Check message digest: $ openssl cms -in Test.eml -cmsout -print
  3. Cut out plaintext from mail and save to Test.txt
  4. Compare all hashes to digest from step 2: $ lua sha256-hash-finder.lua Test.eml "4db15ae843e3 ... "

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.