We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Murat • 2 years ago

Hey Glenn, I've been trying to use this class using an RFC3161 TSA, I guess I managed to get a timestamp, verifytimestamps, but couldn't "verify" if the timestamped data has been altered or not. Verify method gives me "The hash value is not correct." error. I do not want to post my code since it's all over the place (trial and error code). I would be very glad if you can post something to show it's usage. Regards.

Basically, I have a byte array (data), I want to timestamp it, then change a byte in data, and call "verify" method.

Martin Velikov • 2 years ago

Hey Glenn,
I am testing your implementation for validating a time-stamped PDF document but when I check the UnsignedAttributes there are no records there.

This is the code snippet I used:

byte[] byteArrayCompositionForHash = this.GetByteArrayCompositionForHash();
ContentInfo contentInfo = new ContentInfo(byteArrayCompositionForHash);
SignedCms signedCms = new SignedCms(contentInfo);
signedCms.Decode(hashCodeData);
signedCms.CheckSignature(true);

if (signedCms.SignerInfos.Count == 1)
{
SignerInfo signerInfo = signedCms.SignerInfos[0];
object temp = signerInfo.CounterSignerInfos.SyncRoot;

foreach (CryptographicAttributeObject attr in signerInfo.UnsignedAttributes)
{
if (attr.Oid.Value == "1.2.840.113549.1.9.16.2.14")
{
// TODO: Implement
}
}
}

The GetByteArrayCompositionForHash() method is an internal implementation for obtaining the data by omitting the hash code content.

The document is signed using Adobe Acrobat using the "https://freetsa.org/tsr" timestamp sever.
Maybe I am missing something. Do you have any idea?

Mauro Decima • 4 years ago

This post save my day, thanks a lot.
Yoy must use
newSignerInfo.AddUnsignedAttribute(new AsnEncodedData(SignatureTimeStampOin
instead of
newSignerInfo.UnsignedAttributes.Add(new AsnEncodedData(