summary refs log tree commit diff
path: root/crypto/test
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2019-08-09 16:50:54 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2019-08-09 16:50:54 +0700
commita66c5d53fe0a051caacffe5daaf5cead5b482c09 (patch)
tree36e45bce1e4de9d951b4ea17d467a045f2437da9 /crypto/test
parentAdd IntValueExact and LongValueExact to BigInteger (diff)
downloadBouncyCastle.NET-ed25519-a66c5d53fe0a051caacffe5daaf5cead5b482c09.tar.xz
ASN.1 updates from bc-java
- Integer cannot have empty contents octets
- Enumerated values can't be negative
Diffstat (limited to 'crypto/test')
-rw-r--r--crypto/test/src/asn1/test/ASN1IntegerTest.cs21
1 files changed, 16 insertions, 5 deletions
diff --git a/crypto/test/src/asn1/test/ASN1IntegerTest.cs b/crypto/test/src/asn1/test/ASN1IntegerTest.cs
index 6de3f7507..35366ea96 100644
--- a/crypto/test/src/asn1/test/ASN1IntegerTest.cs
+++ b/crypto/test/src/asn1/test/ASN1IntegerTest.cs
@@ -48,7 +48,7 @@ namespace Org.BouncyCastle.Asn1.Tests
 
             new DerInteger(Hex.Decode("ffda47bfc776bcd269da4832626ac332adfca6dd835e8ecd83cd1ebe7d709b0e"));
 
-            new DerEnumerated(Hex.Decode("ffda47bfc776bcd269da4832626ac332adfca6dd835e8ecd83cd1ebe7d709b0e"));
+            new DerEnumerated(Hex.Decode("005a47bfc776bcd269da4832626ac332adfca6dd835e8ecd83cd1ebe7d709b0e"));
 
             SetAllowUnsafeProperty(false);
 
@@ -102,6 +102,17 @@ namespace Org.BouncyCastle.Asn1.Tests
             {
                 IsEquals("malformed enumerated", e.Message);
             }
+
+            try
+            {
+                new DerEnumerated(Hex.Decode("005a47bfc776bcd269da4832626ac332adfca6dd835e8ecd83cd1ebe7d709b0e"));
+
+                Fail("no exception");
+            }
+            catch (ArgumentException e)
+            {
+                IsEquals("malformed enumerated", e.Message);
+            }
 #endif
         }
 
@@ -173,7 +184,7 @@ namespace Org.BouncyCastle.Asn1.Tests
             try
             {
                 byte[] rawInt = Hex.Decode("FF81FF");
-                DerInteger i = new DerInteger(rawInt);
+                new DerInteger(rawInt);
                 Fail("Expecting illegal argument exception.");
             }
             catch (ArgumentException e)
@@ -212,7 +223,7 @@ namespace Org.BouncyCastle.Asn1.Tests
             try
             {
                 byte[] rawInt = Hex.Decode("FFFFFFFF01FF");
-                DerInteger i = new DerInteger(rawInt);
+                new DerInteger(rawInt);
                 Fail("Expecting illegal argument exception.");
             }
             catch (ArgumentException e)
@@ -235,7 +246,7 @@ namespace Org.BouncyCastle.Asn1.Tests
             {
                 SetAllowUnsafeProperty(true);
                 byte[] rawInt = Hex.Decode("0000000010FF");
-                DerInteger i = new DerInteger(rawInt);
+                new DerInteger(rawInt);
                 Fail("Expecting illegal argument exception.");
             }
             catch (ArgumentException e)
@@ -254,7 +265,7 @@ namespace Org.BouncyCastle.Asn1.Tests
             {
                 SetAllowUnsafeProperty(true);
                 byte[] rawInt = Hex.Decode("FFFFFFFF10FF");
-                DerInteger i = new DerInteger(rawInt);
+                new DerInteger(rawInt);
                 Fail("Expecting illegal argument exception.");
             }
             catch (ArgumentException e)