summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode/ssbFrame
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2023-03-13 13:27:13 +0100
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2023-03-13 13:27:13 +0100
commit94d0ba8bdd36c6621e2478fdb3bcf1c790369006 (patch)
treeee957619b41f45d3c1d68d2a75b660f2ab6e10c9 /src/main/java/org/uic/barcode/ssbFrame
parentssb unit tests (diff)
downloadUIC-barcode-94d0ba8bdd36c6621e2478fdb3bcf1c790369006.tar
UIC-barcode-94d0ba8bdd36c6621e2478fdb3bcf1c790369006.tar.gz
UIC-barcode-94d0ba8bdd36c6621e2478fdb3bcf1c790369006.tar.bz2
UIC-barcode-94d0ba8bdd36c6621e2478fdb3bcf1c790369006.tar.lz
UIC-barcode-94d0ba8bdd36c6621e2478fdb3bcf1c790369006.tar.xz
UIC-barcode-94d0ba8bdd36c6621e2478fdb3bcf1c790369006.tar.zst
UIC-barcode-94d0ba8bdd36c6621e2478fdb3bcf1c790369006.zip
Diffstat (limited to 'src/main/java/org/uic/barcode/ssbFrame')
-rw-r--r--src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java b/src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java
index 1ee68bb..b473c1e 100644
--- a/src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java
+++ b/src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java
@@ -1,5 +1,6 @@
package org.uic.barcode.ssbFrame;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.security.InvalidKeyException;
@@ -76,17 +77,33 @@ public class SsbFrame {
offset = offset + nonUicData.decodeContent(bytes,offset);
}
-
- signaturePart1 = new byte[28];
- signaturePart2 = new byte[28];
- for (int i = 0 ; i < 28;i++) {
- signaturePart1[i] = bytes[58 + i];
- signaturePart2[i] = bytes[58 + 28 + i];
+ byte[] signatureBytes = new byte[56];
+
+ try {
+ //check for non-standard signature encoding
+ BigInteger[] bInts = SecurityUtils.decodeSignatureIntegerSequence(signatureBytes);
+ byte[] sig = SecurityUtils.encodeSignatureIntegerSequence(bInts[0],bInts[1]);
+ signaturePart1 = bInts[0].toByteArray();
+ signaturePart2 = bInts[1].toByteArray();
+ //decoding the entire signature was ok, so there was no split
+ } catch (Exception e) {
+ //the signature is correctly implemented, continue with recombination
+ signaturePart1 = new byte[28];
+ signaturePart2 = new byte[28];
+
+ for (int i = 0 ; i < 28;i++) {
+ signaturePart1[i] = bytes[58 + i];
+ signaturePart2[i] = bytes[58 + 28 + i];
+ }
}
+
}
+
+
+
public byte[] encode() throws EncodingFormatException {
byte[] bytes = new byte[114];