summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode/ssbFrame
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2023-03-09 16:30:19 +0100
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2023-03-09 16:30:19 +0100
commit37ddd3d075d0664de44f05639712869596bfb9cd (patch)
tree5d22d5578e550a0b3435c78fe133545026dffabe /src/main/java/org/uic/barcode/ssbFrame
parenterror messages for wrong header content (diff)
downloadUIC-barcode-37ddd3d075d0664de44f05639712869596bfb9cd.tar
UIC-barcode-37ddd3d075d0664de44f05639712869596bfb9cd.tar.gz
UIC-barcode-37ddd3d075d0664de44f05639712869596bfb9cd.tar.bz2
UIC-barcode-37ddd3d075d0664de44f05639712869596bfb9cd.tar.lz
UIC-barcode-37ddd3d075d0664de44f05639712869596bfb9cd.tar.xz
UIC-barcode-37ddd3d075d0664de44f05639712869596bfb9cd.tar.zst
UIC-barcode-37ddd3d075d0664de44f05639712869596bfb9cd.zip
Diffstat (limited to 'src/main/java/org/uic/barcode/ssbFrame')
-rw-r--r--src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java32
1 files changed, 26 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 b496b17..81b5eb4 100644
--- a/src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java
+++ b/src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java
@@ -7,6 +7,7 @@ import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.Provider;
import java.security.PublicKey;
+import java.security.Security;
import java.security.Signature;
import java.security.SignatureException;
import java.security.Provider.Service;
@@ -198,16 +199,18 @@ public class SsbFrame {
this.passData = passData;
}
- public void signLevel1(PrivateKey key, Provider prov, String algorithmOid) throws Exception {
+ public void signLevel1(PrivateKey key, Provider prov, String keyId, String algorithmOid) throws Exception {
+ this.header.setKeyId(Integer.parseInt(keyId));
+
byte[] data = getDataForSignature();
if (prov == null) {
//check for a provider supporting the key
prov = SecurityUtils.findPrivateKeyProvider(key);
}
-
+
//find the algorithm name for the signature OID
String algo = AlgorithmNameResolver.getSignatureAlgorithmName(algorithmOid, prov);
Signature sig = null;
@@ -261,10 +264,25 @@ public class SsbFrame {
public boolean verifyByAlgorithmOid(PublicKey key, String signingAlg, Provider prov) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IllegalArgumentException, UnsupportedOperationException, IOException, EncodingFormatException {
//find the algorithm name for the signature OID
String algo = null;
- Service service = prov.getService("Signature",signingAlg);
- if (service != null) {
- algo = service.getAlgorithm();
- }
+
+ if (prov != null) {
+ Service service = prov.getService("Signature",signingAlg);
+ if (service != null) {
+ algo = service.getAlgorithm();
+ }
+ } else {
+ Provider[] provs = Security.getProviders();
+ for (Provider p : provs) {
+ if (algo == null) {
+ Service service = p.getService("Signature",signingAlg);
+ if (service != null) {
+ algo = service.getAlgorithm();
+ }
+ }
+ }
+
+ }
+
if (algo == null) {
throw new NoSuchAlgorithmException("No service for algorithm found: " + signingAlg);
}
@@ -279,4 +297,6 @@ public class SsbFrame {
return sig.verify(signature);
}
+
+
}