summary refs log tree commit diff
path: root/crypto/src/tsp/TimeStampResponse.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/tsp/TimeStampResponse.cs')
-rw-r--r--crypto/src/tsp/TimeStampResponse.cs21
1 files changed, 19 insertions, 2 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);
+		}
 	}
 }