I'm trying to verify a time stamp token embedded into a PDF using the PDF 2.0 feature of the "Document Time-stamp Dictionary". The embedded time stamp token is exactly the token of a time stamp response from a time stamp authority server.
Since the OpenSSL library of Ruby doesn't seem to provide the necessary interfaces to do the task, I'm trying to do it manually. And I'm stuck at verifying that the digest value of the time stamp token is equal to the digest value of original content.
Here is the openssl pkcs7 -in response.der -inform DER -print
output of a sample time stamp token: https://pastebin.com/s4CTGeQX
What I was able to do:
I can navigate the ASN1 structure of the PKCS7 object to locate the used digest algorithm inside the SignerInfo. In the example case this is "SHA512".
I also found the authenticated attribute called "messageDigest (1.2.840.113549.1.9.4)".
However, the messageDigest attribute value doesn't match the result of using SHA512 over the original content.
I'm not quite sure whether I have to further process messageDigest somehow or whether the digest I'm looking for is hiding (in plain sight) somewhere else. So any information on how to verify the signed content digest in the time stamp token is appreciated - thanks!
openssl asn1parse ... -strparse 65 -out x
, which are the contentInfo value beginning 30 81 and ending 31 5A, I get b8e362aa8b2eaa8e4eb81a019f14ffb96b4af0910ce0ad4e15621ada378518d07f327a7feca3ec2523ef212ce3a1fa8bbab6a6aef68706d82caaa531a43266e3 which does match the value of messageDigest in signedattrs $\endgroup$openssl
command output shows another DER encoded structure lurking in there. I think I can now get to what I want $\endgroup$