diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2023-05-30 09:28:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-30 09:28:14 +0200 |
commit | 804b064202a8212bba0a1e2f69b66adc6336c575 (patch) | |
tree | 15610c6226033753cbc77a3d060bd834f85471af /src/main/java/org/uic/barcode/staticFrame/StaticFrame.java | |
parent | Merge pull request #63 from irrationalism/bugfix/fix-productIdNum-range-v2 (diff) | |
parent | fix on productId in version 1 FCB (diff) | |
download | UIC-barcode-804b064202a8212bba0a1e2f69b66adc6336c575.tar UIC-barcode-804b064202a8212bba0a1e2f69b66adc6336c575.tar.gz UIC-barcode-804b064202a8212bba0a1e2f69b66adc6336c575.tar.bz2 UIC-barcode-804b064202a8212bba0a1e2f69b66adc6336c575.tar.lz UIC-barcode-804b064202a8212bba0a1e2f69b66adc6336c575.tar.xz UIC-barcode-804b064202a8212bba0a1e2f69b66adc6336c575.tar.zst UIC-barcode-804b064202a8212bba0a1e2f69b66adc6336c575.zip |
Diffstat (limited to '')
-rw-r--r-- | src/main/java/org/uic/barcode/staticFrame/StaticFrame.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/main/java/org/uic/barcode/staticFrame/StaticFrame.java b/src/main/java/org/uic/barcode/staticFrame/StaticFrame.java index 30bbe3f..2cab54f 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);
|