Question

I successfully obtained a Timestamp from a tsa server (RFC 3161) and i've created the following Object using bouncyCastle:

TimeStampedData timeStampedData = new TimeStampedData(uri, null, asn1OctetString, evid);

How can i save this structure to a file (.tsr or .tsd) with RFC 5544 specifications?

I've looked for this all over the bouncycaste wiki and also asked in their forum but i received no answer.

Thank you

Was it helpful?

Solution

Since the RFC 5544 is based on CMS objects you need to wrap the TimeStampedData object into a ContentInfo with the timestamped-data object identifier as defined in the RFC.

You should call:

TimeStampedData timeStampedData = new TimeStampedData(uri, null, asn1OctetString, evid);
ContentInfo contentInfo = new ContentInfo(CmsObjectIdentifiers.timestampedData, timeStampedData);
Byte[] fileData = contentInfo.GetEncoded();

And then store this byte array into a file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top