summary refs log tree commit diff
path: root/crypto/test/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-11-18 13:46:18 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-11-18 13:46:18 +0700
commit4fccb8f490eefe7181558b2c3376ab23c33632ee (patch)
treefe8c1877bb5567cb4823823af77e5c8a38423db8 /crypto/test/src
parentASN.1: Staged encoding (diff)
downloadBouncyCastle.NET-ed25519-4fccb8f490eefe7181558b2c3376ab23c33632ee.tar.xz
ASN.1: Port of bc-java TYPE instances
- we use Meta.Instance here due to syntax restrictions
- also reworked some ASN.1 string types
Diffstat (limited to 'crypto/test/src')
-rw-r--r--crypto/test/src/asn1/test/DERUTF8StringTest.cs5
-rw-r--r--crypto/test/src/asn1/test/SetTest.cs6
2 files changed, 8 insertions, 3 deletions
diff --git a/crypto/test/src/asn1/test/DERUTF8StringTest.cs b/crypto/test/src/asn1/test/DERUTF8StringTest.cs
index be4dace79..15f98a7c4 100644
--- a/crypto/test/src/asn1/test/DERUTF8StringTest.cs
+++ b/crypto/test/src/asn1/test/DERUTF8StringTest.cs
@@ -66,8 +66,9 @@ namespace Org.BouncyCastle.Asn1.Tests
 					byte[] b1 = new DerUtf8String(s).GetEncoded();
 					byte[] temp = new byte[b1.Length - 2];
 					Array.Copy(b1, 2, temp, 0, b1.Length - 2);
-					byte[] b2 = new DerUtf8String(new DerOctetString(temp).GetOctets()).GetEncoded();
-					if (!Arrays.AreEqual(b1, b2))
+                    byte[] b2 = new DerUtf8String(Strings.FromUtf8ByteArray(new DerOctetString(temp).GetOctets()))
+                        .GetEncoded();
+                    if (!Arrays.AreEqual(b1, b2))
 					{
 						return new SimpleTestResult(false, Name + ": failed UTF-8 encoding and decoding");
 					}
diff --git a/crypto/test/src/asn1/test/SetTest.cs b/crypto/test/src/asn1/test/SetTest.cs
index 57c46603d..b7da0a9b7 100644
--- a/crypto/test/src/asn1/test/SetTest.cs
+++ b/crypto/test/src/asn1/test/SetTest.cs
@@ -83,7 +83,11 @@ namespace Org.BouncyCastle.Asn1.Tests
 
 			// create an implicitly tagged "set" without sorting
 			Asn1TaggedObject tag = new DerTaggedObject(false, 1, new DerSequence(v));
-			s = Asn1Set.GetInstance(tag, false);
+
+            // Encode/decode to get 'tag' as a parsed instance
+            tag = (Asn1TaggedObject)Asn1Object.FromByteArray(tag.GetEncoded(Asn1Encodable.Der));;
+
+            s = Asn1Set.GetInstance(tag, false);
 
 			if (s[0] is DerBoolean)
 			{