From 09f0f9449a10b713207126348105fafec4781bed Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Mon, 24 Jan 2022 16:51:04 +0100 Subject: signature validation changed to work with teh dynamic header version 2. --- .../org/uic/barcode/test/BinaryStringTest.java | 61 ++++++++++++++++++++++ .../test/DynamicFrameDynamicContentApiTest.java | 2 - 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 src/test/java/org/uic/barcode/test/BinaryStringTest.java (limited to 'src/test/java/org/uic') diff --git a/src/test/java/org/uic/barcode/test/BinaryStringTest.java b/src/test/java/org/uic/barcode/test/BinaryStringTest.java new file mode 100644 index 0000000..d5533fa --- /dev/null +++ b/src/test/java/org/uic/barcode/test/BinaryStringTest.java @@ -0,0 +1,61 @@ +package org.uic.barcode.test; + +import java.io.IOException; +import org.junit.Test; +import org.uic.barcode.asn1.uper.AsnUtils; +import org.uic.barcode.ticket.EncodingFormatException; + +public class BinaryStringTest { + + + + + @Test public void testBinaryString() throws IOException, EncodingFormatException{ + + String bs1 = "01000000"; + String ms1 = "1000000001000000001000000001000000001000000001000000001000000001"; + String ms2 = "10000000010000000010000000010000"; + + + //String bs1 = "1011111100001000011011100000000000000001000000010000010010000000"; + + byte[] bytes = AsnUtils.fromBooleanString(bs1); + + String bs2 = AsnUtils.toBooleanString(bytes); + + + + byte[] mask = new byte[] { + (byte) 0b1000_0000, + 0b0100_0000, + 0b0010_0000, + 0b0001_0000, + 0b0000_1000, + 0b0000_0100, + 0b0000_0010, + 0b0000_0001, + }; + String bs3 = AsnUtils.toBooleanString(mask); + byte[] bytes2 = AsnUtils.fromBooleanString(bs3); + + + byte[] mask2 = new byte[] { + (byte) 0b1000_0000, + 0b0100_0000, + 0b0010_0000, + 0b0001_0000, + }; + String bs4 = AsnUtils.toBooleanString(mask2); + byte[] bytes3 = AsnUtils.fromBooleanString(bs4); + + + assert(bs4.equals(ms2)); + + assert(bs3.equals(ms1)); + + assert(bs1.equals(bs2)); + + } + + +} \ No newline at end of file diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java index 5a70841..4d34c1b 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java @@ -10,8 +10,6 @@ import java.security.NoSuchProviderException; import java.security.SecureRandom; import java.security.Security; import java.security.SignatureException; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; -- cgit v1.2.3