I successfully obtained a timestamptoken by a trusted authority, now i need to bind it using bouncycastle like so:

|private  static  byte[]  BindTimestampTokenWithFile(FileInfo  file,  byte[]  
timeStampToken)
{
    var  uri=  new  DerIA5String(file.Name);
    var  content=  new  
BerOctetString(Encoding.UTF8.GetBytes(File.ReadAllText(file.FullName)));
    var  tokenInfo=  new  Org.BouncyCastle.Asn1.Cms.ContentInfo(new  
DerObjectIdentifier(TimestampTokenOid),  new  BerOctetString(timeStampToken));
    var  stampAndCrl=  new  TimeStampAndCrl(tokenInfo);
    var  attr=  new  Attributes(new  Asn1EncodableVector(tokenInfo));
    var  tokenEvidence=  new  TimeStampTokenEvidence(stampAndCrl);
    var  evid=  new  Evidence(tokenEvidence);
    var  meta=  new  MetaData(DerBoolean.True,  new  DerUtf8String(file.Name),  new  
DerIA5String("application/pkcs7-mime"),  attr);
    var  timeStampedData=  new  TimeStampedData(uri,  meta,  content,  evid);
    var  contentInfo=  new  
Org.BouncyCastle.Asn1.Cms.ContentInfo(CmsObjectIdentifiers.timestampedData,  
timeStampedData);
    return  contentInfo.GetEncoded();
}|

This piece of code runs smoothly without errors but when i save and Validate the bytes returned, it gives me a Bad Structure Error.

What am i doing wrong?

Thanks in advance

--
Riccardo Castegnaro



Reply via email to