private TstInfo( Asn1Sequence seq) { IEnumerator e = seq.GetEnumerator(); // version e.MoveNext(); version = DerInteger.GetInstance(e.Current); // tsaPolicy e.MoveNext(); tsaPolicyId = DerObjectIdentifier.GetInstance(e.Current); // messageImprint e.MoveNext(); messageImprint = MessageImprint.GetInstance(e.Current); // serialNumber e.MoveNext(); serialNumber = DerInteger.GetInstance(e.Current); // genTime e.MoveNext(); genTime = DerGeneralizedTime.GetInstance(e.Current); // default for ordering ordering = DerBoolean.False; while (e.MoveNext()) { Asn1Object o = (Asn1Object) e.Current; if (o is Asn1TaggedObject) { DerTaggedObject tagged = (DerTaggedObject) o; switch (tagged.TagNo) { case 0: tsa = GeneralName.GetInstance(tagged, true); break; case 1: extensions = X509Extensions.GetInstance(tagged, false); break; default: throw new ArgumentException("Unknown tag value " + tagged.TagNo); } } if (o is DerSequence) { accuracy = Accuracy.GetInstance(o); } if (o is DerBoolean) { ordering = DerBoolean.GetInstance(o); } if (o is DerInteger) { nonce = DerInteger.GetInstance(o); } } }
public TstInfo( DerObjectIdentifier tsaPolicyId, MessageImprint messageImprint, DerInteger serialNumber, DerGeneralizedTime genTime, Accuracy accuracy, DerBoolean ordering, DerInteger nonce, GeneralName tsa, X509Extensions extensions) { this.version = new DerInteger(1); this.tsaPolicyId = tsaPolicyId; this.messageImprint = messageImprint; this.serialNumber = serialNumber; this.genTime = genTime; this.accuracy = accuracy; this.ordering = ordering; this.nonce = nonce; this.tsa = tsa; this.extensions = extensions; }
//------------------------------------------------------------------------------ public TimeStampToken Generate( TimeStampRequest request, BigInteger serialNumber, DateTime genTime) { DerObjectIdentifier digestAlgOID = new DerObjectIdentifier(request.MessageImprintAlgOid); AlgorithmIdentifier algID = new AlgorithmIdentifier(digestAlgOID, DerNull.Instance); MessageImprint messageImprint = new MessageImprint(algID, request.GetMessageImprintDigest()); Accuracy accuracy = null; if (accuracySeconds > 0 || accuracyMillis > 0 || accuracyMicros > 0) { DerInteger seconds = null; if (accuracySeconds > 0) { seconds = new DerInteger(accuracySeconds); } DerInteger millis = null; if (accuracyMillis > 0) { millis = new DerInteger(accuracyMillis); } DerInteger micros = null; if (accuracyMicros > 0) { micros = new DerInteger(accuracyMicros); } accuracy = new Accuracy(seconds, millis, micros); } DerBoolean derOrdering = null; if (ordering) { derOrdering = DerBoolean.GetInstance(ordering); } DerInteger nonce = null; if (request.Nonce != null) { nonce = new DerInteger(request.Nonce); } DerObjectIdentifier tsaPolicy = new DerObjectIdentifier(tsaPolicyOID); if (request.ReqPolicy != null) { tsaPolicy = new DerObjectIdentifier(request.ReqPolicy); } TstInfo tstInfo = new TstInfo(tsaPolicy, messageImprint, new DerInteger(serialNumber), new DerGeneralizedTime(genTime), accuracy, derOrdering, nonce, tsa, request.Extensions); try { CmsSignedDataGenerator signedDataGenerator = new CmsSignedDataGenerator(); byte[] derEncodedTstInfo = tstInfo.GetDerEncoded(); if (request.CertReq) { signedDataGenerator.AddCertificates(x509Certs); } signedDataGenerator.AddCrls(x509Crls); signedDataGenerator.AddSigner(key, cert, digestOID, signedAttr, unsignedAttr); CmsSignedData signedData = signedDataGenerator.Generate( PkcsObjectIdentifiers.IdCTTstInfo.Id, new CmsProcessableByteArray(derEncodedTstInfo), true); return new TimeStampToken(signedData); } catch (CmsException cmsEx) { throw new TspException("Error generating time-stamp token", cmsEx); } catch (IOException e) { throw new TspException("Exception encoding info", e); } catch (X509StoreException e) { throw new TspException("Exception handling CertStore", e); } // catch (InvalidAlgorithmParameterException e) // { // throw new TspException("Exception handling CertStore CRLs", e); // } }
private TstInfo( Asn1Sequence seq) { IEnumerator e = seq.GetEnumerator(); // version e.MoveNext(); version = DerInteger.GetInstance(e.Current); // tsaPolicy e.MoveNext(); tsaPolicyId = DerObjectIdentifier.GetInstance(e.Current); // messageImprint e.MoveNext(); messageImprint = MessageImprint.GetInstance(e.Current); // serialNumber e.MoveNext(); serialNumber = DerInteger.GetInstance(e.Current); // genTime e.MoveNext(); genTime = DerGeneralizedTime.GetInstance(e.Current); // default for ordering ordering = DerBoolean.False; while (e.MoveNext()) { Asn1Object o = (Asn1Object)e.Current; if (o is Asn1TaggedObject) { DerTaggedObject tagged = (DerTaggedObject)o; switch (tagged.TagNo) { case 0: tsa = GeneralName.GetInstance(tagged, true); break; case 1: extensions = X509Extensions.GetInstance(tagged, false); break; default: throw new ArgumentException("Unknown tag value " + tagged.TagNo); } } if (o is DerSequence) { accuracy = Accuracy.GetInstance(o); } if (o is DerBoolean) { ordering = DerBoolean.GetInstance(o); } if (o is DerInteger) { nonce = DerInteger.GetInstance(o); } } }
public TstInfo(DerObjectIdentifier tsaPolicyId, MessageImprint messageImprint, DerInteger serialNumber, DerGeneralizedTime genTime, Accuracy accuracy, DerBoolean ordering, DerInteger nonce, GeneralName tsa, X509Extensions extensions) { version = new DerInteger(1); this.tsaPolicyId = tsaPolicyId; this.messageImprint = messageImprint; this.serialNumber = serialNumber; this.genTime = genTime; this.accuracy = accuracy; this.ordering = ordering; this.nonce = nonce; this.tsa = tsa; this.extensions = extensions; }
public GenTimeAccuracy( Accuracy accuracy) { this.accuracy = accuracy; }