summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2020-02-20 01:37:07 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2020-02-20 01:37:07 +0700
commit765426a8dc1fe20295f91d55e7bbf539e6b831fc (patch)
tree8e62ef9b9f45be2030ff490bd09834f2fb4df7a5
parentMark methods as "Var" for clarity (diff)
downloadBouncyCastle.NET-ed25519-765426a8dc1fe20295f91d55e7bbf539e6b831fc.tar.xz
Misc. updates from bc-java
-rw-r--r--crypto/src/asn1/nist/NISTObjectIdentifiers.cs4
-rw-r--r--crypto/src/asn1/pkcs/CertBag.cs16
-rw-r--r--crypto/src/cms/CMSSignedData.cs10
-rw-r--r--crypto/src/tsp/TimeStampToken.cs15
-rw-r--r--crypto/test/src/tsp/test/TimeStampTokenInfoTest.cs2
5 files changed, 39 insertions, 8 deletions
diff --git a/crypto/src/asn1/nist/NISTObjectIdentifiers.cs b/crypto/src/asn1/nist/NISTObjectIdentifiers.cs
index 840718ccd..417fa8df9 100644
--- a/crypto/src/asn1/nist/NISTObjectIdentifiers.cs
+++ b/crypto/src/asn1/nist/NISTObjectIdentifiers.cs
@@ -35,6 +35,10 @@ namespace Org.BouncyCastle.Asn1.Nist
         public static readonly DerObjectIdentifier IdHMacWithSha3_256 = HashAlgs.Branch("14");
         public static readonly DerObjectIdentifier IdHMacWithSha3_384 = HashAlgs.Branch("15");
         public static readonly DerObjectIdentifier IdHMacWithSha3_512 = HashAlgs.Branch("16");
+        public static readonly DerObjectIdentifier IdShake128Len = HashAlgs.Branch("17");
+        public static readonly DerObjectIdentifier IdShake256Len = HashAlgs.Branch("18");
+        public static readonly DerObjectIdentifier IdKmacWithShake128 = HashAlgs.Branch("19");
+        public static readonly DerObjectIdentifier IdKmacWithShake256 = HashAlgs.Branch("20");
 
         public static readonly DerObjectIdentifier Aes = new DerObjectIdentifier(NistAlgorithm + ".1");
 
diff --git a/crypto/src/asn1/pkcs/CertBag.cs b/crypto/src/asn1/pkcs/CertBag.cs
index e561fb890..61165c087 100644
--- a/crypto/src/asn1/pkcs/CertBag.cs
+++ b/crypto/src/asn1/pkcs/CertBag.cs
@@ -5,17 +5,25 @@ namespace Org.BouncyCastle.Asn1.Pkcs
     public class CertBag
         : Asn1Encodable
     {
-//		private readonly Asn1Sequence seq;
+        public static CertBag GetInstance(object obj)
+        {
+            if (obj is CertBag)
+                return (CertBag)obj;
+            if (obj == null)
+                return null;
+            return new CertBag(Asn1Sequence.GetInstance(obj));
+        }
+
         private readonly DerObjectIdentifier certID;
         private readonly Asn1Object certValue;
 
+        [Obsolete("Use 'GetInstance' instead")]
 		public CertBag(
             Asn1Sequence seq)
         {
 			if (seq.Count != 2)
 				throw new ArgumentException("Wrong number of elements in sequence", "seq");
 
-//			this.seq = seq;
             this.certID = DerObjectIdentifier.GetInstance(seq[0]);
             this.certValue = Asn1TaggedObject.GetInstance(seq[1]).GetObject();
         }
@@ -28,12 +36,12 @@ namespace Org.BouncyCastle.Asn1.Pkcs
             this.certValue = certValue;
         }
 
-		public DerObjectIdentifier CertID
+		public virtual DerObjectIdentifier CertID
 		{
 			get { return certID; }
 		}
 
-		public Asn1Object CertValue
+		public virtual Asn1Object CertValue
 		{
 			get { return certValue; }
 		}
diff --git a/crypto/src/cms/CMSSignedData.cs b/crypto/src/cms/CMSSignedData.cs
index 979be6535..8634b2b3a 100644
--- a/crypto/src/cms/CMSSignedData.cs
+++ b/crypto/src/cms/CMSSignedData.cs
@@ -280,6 +280,16 @@ namespace Org.BouncyCastle.Cms
 			return contentInfo.GetEncoded();
 		}
 
+        /**
+         * return the ASN.1 encoded representation of this object using the specified encoding.
+         *
+         * @param encoding the ASN.1 encoding format to use ("BER" or "DER").
+         */
+        public byte[] GetEncoded(string encoding)
+        {
+            return contentInfo.GetEncoded(encoding);
+        }
+
 		/**
 		* Replace the signerinformation store associated with this
 		* CmsSignedData object with the new one passed in. You would
diff --git a/crypto/src/tsp/TimeStampToken.cs b/crypto/src/tsp/TimeStampToken.cs
index 105208a7d..643813552 100644
--- a/crypto/src/tsp/TimeStampToken.cs
+++ b/crypto/src/tsp/TimeStampToken.cs
@@ -244,9 +244,18 @@ namespace Org.BouncyCastle.Tsp
 		 */
 		public byte[] GetEncoded()
 		{
-			return tsToken.GetEncoded();
-		}
-
+            return tsToken.GetEncoded(Asn1Encodable.Der);
+        }
+
+        /**
+         * return the ASN.1 encoded representation of this object using the specified encoding.
+         *
+         * @param encoding the ASN.1 encoding format to use ("BER" or "DER").
+         */
+        public byte[] GetEncoded(string encoding)
+        {
+            return tsToken.GetEncoded(encoding);
+        }
 
 		// perhaps this should be done using an interface on the ASN.1 classes...
 		private class CertID
diff --git a/crypto/test/src/tsp/test/TimeStampTokenInfoTest.cs b/crypto/test/src/tsp/test/TimeStampTokenInfoTest.cs
index 5a26f5ef6..ea7f2c4dc 100644
--- a/crypto/test/src/tsp/test/TimeStampTokenInfoTest.cs
+++ b/crypto/test/src/tsp/test/TimeStampTokenInfoTest.cs
@@ -28,7 +28,7 @@ namespace Org.BouncyCastle.Tsp.Tests
 
 		private static readonly byte[] tstInfoDudDate = Hex.Decode(
 			  "303e02010106022a033021300906052b0e03021a050004140000000000000000000000000000000000000000"
-			+ "020118180f32303056313130313038313732315a");
+            + "020118180f32303030563130313038313732315a");
 
 		[Test]
 		public void TestTstInfo1()