From 74d19c0493d7bf464d466b2dff2305021d911c27 Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Wed, 17 May 2023 13:57:03 +0200 Subject: SSB tests --- .../java/org/uic/barcode/staticFrame/StaticFrame.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/main/java/org/uic/barcode/staticFrame') diff --git a/src/main/java/org/uic/barcode/staticFrame/StaticFrame.java b/src/main/java/org/uic/barcode/staticFrame/StaticFrame.java index 8dc1adb..25649df 100644 --- a/src/main/java/org/uic/barcode/staticFrame/StaticFrame.java +++ b/src/main/java/org/uic/barcode/staticFrame/StaticFrame.java @@ -19,7 +19,9 @@ import java.util.zip.DataFormatException; import java.util.zip.Deflater; import java.util.zip.Inflater; +import org.uic.barcode.dynamicFrame.Constants; import org.uic.barcode.ticket.EncodingFormatException; +import org.uic.barcode.utils.SecurityUtils; /** @@ -660,11 +662,20 @@ public class StaticFrame { * @throws IOException */ public boolean verifyByAlgorithmOid(PublicKey key, String signingAlg) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IllegalArgumentException, UnsupportedOperationException, IOException, EncodingFormatException { + + String signatureAlgorithmOid = signingAlg; + + + // guess the signature algorithm based on the signature size + if ((signingAlg == null || signingAlg.length() < 1) && this.getSignature() != null) { + signatureAlgorithmOid = SecurityUtils.getDsaAlgorithm(this.getSignature()); + } + //find the algorithm name for the signature OID String algo = null; Provider[] provs = Security.getProviders(); for (Provider prov : provs) { - Service service = prov.getService("Signature",signingAlg); + Service service = prov.getService("Signature",signatureAlgorithmOid); if (service != null) { algo = service.getAlgorithm(); } @@ -776,7 +787,8 @@ public class StaticFrame { if (algo == null) { throw new NoSuchAlgorithmException("No service for algorthm found: " + signingAlg); } - Signature sig = Signature.getInstance(algo); + Signature sig = Signature.getInstance(algo,prov); + sig.initSign(key); signedData = getDataForSignature(); sig.update(signedData); -- cgit v1.2.3 From 91507261d564cb2a8b7dd338f92d80738d4646f1 Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Thu, 25 May 2023 12:03:47 +0200 Subject: fix on head with wrong month --- src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/org/uic/barcode/staticFrame') diff --git a/src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java b/src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java index 31a664b..30777a5 100644 --- a/src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java +++ b/src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java @@ -255,7 +255,7 @@ public class UHEADDataRecord extends DataRecord{ String timeElement = String.format("%02d%02d%04d%02d%02d", now.get(Calendar.DAY_OF_MONTH), - now.get(Calendar.MONTH), + now.get(Calendar.MONTH) + 1, now.get(Calendar.YEAR), now.get(Calendar.HOUR), now.get(Calendar.MINUTE)); -- cgit v1.2.3