summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2019-08-04 17:58:40 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2019-08-04 17:58:40 +0700
commit4af2753c154c2f5cab5a48093a666b275ad81339 (patch)
treec3e4f221e24f69ae6ed510aa35ef0a5967264229 /crypto
parentRefactoring in PublicKeyFactory (diff)
downloadBouncyCastle.NET-ed25519-4af2753c154c2f5cab5a48093a666b275ad81339.tar.xz
Misc. ASN.1 updates
Diffstat (limited to 'crypto')
-rw-r--r--crypto/src/asn1/ASN1StreamParser.cs26
-rw-r--r--crypto/src/asn1/pkcs/SignedData.cs4
-rw-r--r--crypto/src/asn1/tsp/Accuracy.cs4
-rw-r--r--crypto/src/asn1/util/Asn1Dump.cs4
-rw-r--r--crypto/src/asn1/x509/TBSCertList.cs4
-rw-r--r--crypto/src/asn1/x509/TBSCertificateStructure.cs2
-rw-r--r--crypto/test/src/asn1/test/DeclarationOfMajorityUnitTest.cs20
7 files changed, 31 insertions, 33 deletions
diff --git a/crypto/src/asn1/ASN1StreamParser.cs b/crypto/src/asn1/ASN1StreamParser.cs
index 0c6b4413a..3eaaadaee 100644
--- a/crypto/src/asn1/ASN1StreamParser.cs
+++ b/crypto/src/asn1/ASN1StreamParser.cs
@@ -218,17 +218,19 @@ namespace Org.BouncyCastle.Asn1
 			}
 		}
 
-		internal Asn1EncodableVector ReadVector()
-		{
-			Asn1EncodableVector v = new Asn1EncodableVector();
-
-			IAsn1Convertible obj;
-			while ((obj = ReadObject()) != null)
-			{
-				v.Add(obj.ToAsn1Object());
-			}
-
-			return v;
-		}
+        internal Asn1EncodableVector ReadVector()
+        {
+            IAsn1Convertible obj = ReadObject();
+            if (null == obj)
+                return new Asn1EncodableVector(0);
+
+            Asn1EncodableVector v = new Asn1EncodableVector();
+            do
+            {
+                v.Add(obj.ToAsn1Object());
+            }
+            while ((obj = ReadObject()) != null);
+            return v;
+        }
 	}
 }
diff --git a/crypto/src/asn1/pkcs/SignedData.cs b/crypto/src/asn1/pkcs/SignedData.cs
index 3442e671c..ae335103c 100644
--- a/crypto/src/asn1/pkcs/SignedData.cs
+++ b/crypto/src/asn1/pkcs/SignedData.cs
@@ -66,9 +66,9 @@ namespace Org.BouncyCastle.Asn1.Pkcs
                 // an interesting feature of SignedData is that there appear to be varying implementations...
                 // for the moment we ignore anything which doesn't fit.
                 //
-                if (o is DerTaggedObject)
+                if (o is Asn1TaggedObject)
                 {
-                    DerTaggedObject tagged = (DerTaggedObject) o;
+                    Asn1TaggedObject tagged = (Asn1TaggedObject)o;
 
                     switch (tagged.TagNo)
                     {
diff --git a/crypto/src/asn1/tsp/Accuracy.cs b/crypto/src/asn1/tsp/Accuracy.cs
index c5a5ca119..9da8f1d68 100644
--- a/crypto/src/asn1/tsp/Accuracy.cs
+++ b/crypto/src/asn1/tsp/Accuracy.cs
@@ -54,9 +54,9 @@ namespace Org.BouncyCastle.Asn1.Tsp
 				{
 					seconds = (DerInteger) seq[i];
 				}
-				else if (seq[i] is DerTaggedObject)
+                else if (seq[i] is Asn1TaggedObject)
 				{
-					DerTaggedObject extra = (DerTaggedObject) seq[i];
+                    Asn1TaggedObject extra = (Asn1TaggedObject)seq[i];
 
 					switch (extra.TagNo)
 					{
diff --git a/crypto/src/asn1/util/Asn1Dump.cs b/crypto/src/asn1/util/Asn1Dump.cs
index 6a21ee2af..019041789 100644
--- a/crypto/src/asn1/util/Asn1Dump.cs
+++ b/crypto/src/asn1/util/Asn1Dump.cs
@@ -63,7 +63,7 @@ namespace Org.BouncyCastle.Asn1.Utilities
                     }
                 }
             }
-            else if (obj is DerTaggedObject)
+            else if (obj is Asn1TaggedObject)
             {
                 string tab = indent + Tab;
                 buf.Append(indent);
@@ -76,7 +76,7 @@ namespace Org.BouncyCastle.Asn1.Utilities
                     buf.Append("Tagged [");
                 }
 
-                DerTaggedObject o = (DerTaggedObject)obj;
+                Asn1TaggedObject o = (Asn1TaggedObject)obj;
 
                 buf.Append(((int)o.TagNo).ToString());
                 buf.Append(']');
diff --git a/crypto/src/asn1/x509/TBSCertList.cs b/crypto/src/asn1/x509/TBSCertList.cs
index 5767a7f21..2b3646052 100644
--- a/crypto/src/asn1/x509/TBSCertList.cs
+++ b/crypto/src/asn1/x509/TBSCertList.cs
@@ -193,13 +193,13 @@ namespace Org.BouncyCastle.Asn1.X509
             }
 
 			if (seqPos < seq.Count
-                && !(seq[seqPos] is DerTaggedObject))
+                && !(seq[seqPos] is Asn1TaggedObject))
             {
 				revokedCertificates = Asn1Sequence.GetInstance(seq[seqPos++]);
 			}
 
 			if (seqPos < seq.Count
-                && seq[seqPos] is DerTaggedObject)
+                && seq[seqPos] is Asn1TaggedObject)
             {
 				crlExtensions = X509Extensions.GetInstance(seq[seqPos]);
 			}
diff --git a/crypto/src/asn1/x509/TBSCertificateStructure.cs b/crypto/src/asn1/x509/TBSCertificateStructure.cs
index e69e985f5..da378391e 100644
--- a/crypto/src/asn1/x509/TBSCertificateStructure.cs
+++ b/crypto/src/asn1/x509/TBSCertificateStructure.cs
@@ -69,7 +69,7 @@ namespace Org.BouncyCastle.Asn1.X509
 			//
 			// some certficates don't include a version number - we assume v1
 			//
-			if (seq[0] is DerTaggedObject)
+			if (seq[0] is Asn1TaggedObject)
 			{
 				version = DerInteger.GetInstance((Asn1TaggedObject)seq[0], true);
 			}
diff --git a/crypto/test/src/asn1/test/DeclarationOfMajorityUnitTest.cs b/crypto/test/src/asn1/test/DeclarationOfMajorityUnitTest.cs
index bd1fb5a9e..f9eef4f47 100644
--- a/crypto/test/src/asn1/test/DeclarationOfMajorityUnitTest.cs
+++ b/crypto/test/src/asn1/test/DeclarationOfMajorityUnitTest.cs
@@ -20,11 +20,11 @@ namespace Org.BouncyCastle.Asn1.Tests
 			DerGeneralizedTime dateOfBirth = new DerGeneralizedTime("20070315173729Z");
 			DeclarationOfMajority decl = new DeclarationOfMajority(dateOfBirth);
 
-			checkConstruction(decl, DeclarationOfMajority.Choice.DateOfBirth, dateOfBirth, -1);
+			CheckConstruction(decl, DeclarationOfMajority.Choice.DateOfBirth, dateOfBirth, -1);
 
 			decl = new DeclarationOfMajority(6);
 
-			checkConstruction(decl, DeclarationOfMajority.Choice.NotYoungerThan, null, 6);
+			CheckConstruction(decl, DeclarationOfMajority.Choice.NotYoungerThan, null, 6);
 
 			decl = DeclarationOfMajority.GetInstance(null);
 
@@ -45,28 +45,24 @@ namespace Org.BouncyCastle.Asn1.Tests
 			}
 		}
 
-		private void checkConstruction(
+		private void CheckConstruction(
 			DeclarationOfMajority			decl,
 			DeclarationOfMajority.Choice	type,
 			DerGeneralizedTime				dateOfBirth,
 			int								notYoungerThan)
 		{
-			checkValues(decl, type, dateOfBirth, notYoungerThan);
+			CheckValues(decl, type, dateOfBirth, notYoungerThan);
 
 			decl = DeclarationOfMajority.GetInstance(decl);
 
-			checkValues(decl, type, dateOfBirth, notYoungerThan);
+			CheckValues(decl, type, dateOfBirth, notYoungerThan);
 
-			Asn1InputStream aIn = new Asn1InputStream(decl.ToAsn1Object().GetEncoded());
+            decl = DeclarationOfMajority.GetInstance(Asn1Object.FromByteArray(decl.GetEncoded()));
 
-			DerTaggedObject info = (DerTaggedObject) aIn.ReadObject();
-
-			decl = DeclarationOfMajority.GetInstance(info);
-
-			checkValues(decl, type, dateOfBirth, notYoungerThan);
+			CheckValues(decl, type, dateOfBirth, notYoungerThan);
 		}
 
-		private void checkValues(
+		private void CheckValues(
 			DeclarationOfMajority			decl,
 			DeclarationOfMajority.Choice	type,
 			DerGeneralizedTime				dateOfBirth,