1

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

Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240
ilcaste
  • 45
  • 1
  • 6

1 Answers1

0

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.

Jcs
  • 13,279
  • 5
  • 53
  • 70
  • which extension should i use saving the file with this method? .tsr or .tsd? Thanks – ilcaste Feb 06 '14 at 08:15
  • According to RFC 5955 http://www.rfc-editor.org/rfc/rfc5955.txt the extension should be .tsd. Actually I did not find much information about .tsr extension; only the fact that it should be used to store time-stamp responses as defined in RFC 3161 (i.e the response status along wity the time-stamp token in case of response success) – Jcs Feb 06 '14 at 08:27