summary refs log tree commit diff
path: root/crypto/src/tsp
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-07-25 18:02:45 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-07-25 18:02:45 +0700
commit510ceb7d6b857d8d50059fc63fccf64eeb207bf4 (patch)
tree24afdb9eb9b37b590797d530585df76f644ced81 /crypto/src/tsp
parentMark BER parser classes Obsolete (for removal from public API) (diff)
downloadBouncyCastle.NET-ed25519-510ceb7d6b857d8d50059fc63fccf64eeb207bf4.tar.xz
Make DL encoding public in Asn1 API
Diffstat (limited to 'crypto/src/tsp')
-rw-r--r--crypto/src/tsp/TimeStampResponse.cs21
-rw-r--r--crypto/src/tsp/TimeStampToken.cs2
2 files changed, 20 insertions, 3 deletions
diff --git a/crypto/src/tsp/TimeStampResponse.cs b/crypto/src/tsp/TimeStampResponse.cs
index 702194911..60ad79f5c 100644
--- a/crypto/src/tsp/TimeStampResponse.cs
+++ b/crypto/src/tsp/TimeStampResponse.cs
@@ -10,10 +10,10 @@ using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Tsp
 {
-	/**
+    /**
 	 * Base class for an RFC 3161 Time Stamp Response object.
 	 */
-	public class TimeStampResponse
+    public class TimeStampResponse
 	{
 		private TimeStampResp	resp;
 		private TimeStampToken	timeStampToken;
@@ -180,5 +180,22 @@ namespace Org.BouncyCastle.Tsp
 		{
 			return resp.GetEncoded();
 		}
+
+        /**
+         * return the ASN.1 encoded representation of this object for the specific encoding type.
+         *
+         * @param encoding encoding style ("DER", "DL", "BER")
+         */
+        public byte[] GetEncoded(string encoding)
+        {
+            if (Asn1Encodable.DL.Equals(encoding))
+            {
+                if (timeStampToken == null)
+                    return new DLSequence(resp.Status).GetEncoded(encoding);
+
+                return new DLSequence(resp.Status, timeStampToken.ToCmsSignedData().ContentInfo).GetEncoded(encoding);
+            }
+            return resp.GetEncoded(encoding);
+		}
 	}
 }
diff --git a/crypto/src/tsp/TimeStampToken.cs b/crypto/src/tsp/TimeStampToken.cs
index f2f86da67..8e9f09723 100644
--- a/crypto/src/tsp/TimeStampToken.cs
+++ b/crypto/src/tsp/TimeStampToken.cs
@@ -234,7 +234,7 @@ namespace Org.BouncyCastle.Tsp
 		 */
 		public byte[] GetEncoded()
 		{
-            return tsToken.GetEncoded(Asn1Encodable.Der);
+            return tsToken.GetEncoded(Asn1Encodable.DL);
         }
 
         /**