diff options
author | mw <megan@cryptoworkshop.com> | 2020-10-27 16:31:51 +1100 |
---|---|---|
committer | mw <megan@cryptoworkshop.com> | 2020-10-27 16:31:51 +1100 |
commit | b290b56d91ab7ee85198b2be77925fca9f037ac8 (patch) | |
tree | e3b377c06b354a8778d9519e12d93167ee876169 /crypto/src/tsp/TimeStampTokenGenerator.cs | |
parent | Added fractional time and new tests (diff) | |
download | BouncyCastle.NET-ed25519-b290b56d91ab7ee85198b2be77925fca9f037ac8.tar.xz |
Finished NewTspTests
Diffstat (limited to 'crypto/src/tsp/TimeStampTokenGenerator.cs')
-rw-r--r-- | crypto/src/tsp/TimeStampTokenGenerator.cs | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/crypto/src/tsp/TimeStampTokenGenerator.cs b/crypto/src/tsp/TimeStampTokenGenerator.cs index 5badcfdd0..dad0db63b 100644 --- a/crypto/src/tsp/TimeStampTokenGenerator.cs +++ b/crypto/src/tsp/TimeStampTokenGenerator.cs @@ -253,9 +253,18 @@ namespace Org.BouncyCastle.Tsp //------------------------------------------------------------------------------ public TimeStampToken Generate( + TimeStampRequest request, + BigInteger serialNumber, + DateTime genTime) + { + return Generate(request, serialNumber, genTime, null); + } + + + public TimeStampToken Generate( TimeStampRequest request, BigInteger serialNumber, - DateTime genTime) + DateTime genTime, X509Extensions additionalExtensions) { DerObjectIdentifier digestAlgOID = new DerObjectIdentifier(request.MessageImprintAlgOid); @@ -304,6 +313,33 @@ namespace Org.BouncyCastle.Tsp tsaPolicy = new DerObjectIdentifier(request.ReqPolicy); } + + X509Extensions respExtensions = request.Extensions; + if (additionalExtensions != null) + { + X509ExtensionsGenerator extGen = new X509ExtensionsGenerator(); + + if (respExtensions != null) + { + foreach(object oid in respExtensions.ExtensionOids) + { + DerObjectIdentifier id = DerObjectIdentifier.GetInstance(oid); + extGen.AddExtension(id, respExtensions.GetExtension(DerObjectIdentifier.GetInstance(id))); + } + } + + foreach (object oid in additionalExtensions.ExtensionOids) + { + DerObjectIdentifier id = DerObjectIdentifier.GetInstance(oid); + extGen.AddExtension(id, additionalExtensions.GetExtension(DerObjectIdentifier.GetInstance(id))); + + } + + respExtensions = extGen.Generate(); + } + + + DerGeneralizedTime generalizedTime; if (resolution != Resolution.R_SECONDS) { @@ -316,7 +352,7 @@ namespace Org.BouncyCastle.Tsp TstInfo tstInfo = new TstInfo(tsaPolicy, messageImprint, new DerInteger(serialNumber), generalizedTime, accuracy, - derOrdering, nonce, tsa, request.Extensions); + derOrdering, nonce, tsa, respExtensions); try { |