summary refs log tree commit diff
path: root/crypto/src/tsp
diff options
context:
space:
mode:
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);
         }
 
         /**