[java-idp-plugin-vci] branch main updated: Remove dead code
Codeberg
noreply at shibboleth.net
Thu Oct 29 05:38:11 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-idp-plugin-vci.
View the commit online:
https://codeberg.org/Shibboleth/java-idp-plugin-vci/commit/d9ecfc25771600dd35f52f309c408b8a0dae06be
The following commit(s) were added to refs/heads/main by this push:
new d9ecfc2 Remove dead code
d9ecfc2 is described below
commit d9ecfc25771600dd35f52f309c408b8a0dae06be
Author: Janne Lauros <janne.lauros at csc.fi>
AuthorDate: Thu Oct 29 07:38:00 2026 +0200
Remove dead code
---
.../openidvci/cose/impl/CoseSign1Signer.java | 52 +---------------------
.../openidvci/cose/impl/CoseSign1SignerTest.java | 15 -------
2 files changed, 2 insertions(+), 65 deletions(-)
diff --git a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/cose/impl/CoseSign1Signer.java b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/cose/impl/CoseSign1Signer.java
index 976c136..4807ef4 100644
--- a/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/cose/impl/CoseSign1Signer.java
+++ b/openid-vci-impl/src/main/java/org/geant/shibboleth/plugin/openidvci/cose/impl/CoseSign1Signer.java
@@ -16,7 +16,6 @@
package org.geant.shibboleth.plugin.openidvci.cose.impl;
import java.security.GeneralSecurityException;
-import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.cert.CertificateEncodingException;
@@ -202,59 +201,12 @@ public final class CoseSign1Signer {
final String jcaName = CoseAlgorithms.jcaName(algorithm);
assert jcaName != null;
try {
- Signature signer;
- boolean der = false;
- try {
- signer = Signature.getInstance(jcaName);
- } catch (final NoSuchAlgorithmException e) {
- signer = Signature.getInstance(jcaName.replace("inP1363Format", ""));
- der = true;
- }
+ final Signature signer = Signature.getInstance(jcaName);
signer.initSign(privateKey);
signer.update(toBeSigned);
- final byte[] signature = signer.sign();
- return der ? derToConcat(signature, coordinateLength()) : signature;
+ return signer.sign();
} catch (final GeneralSecurityException e) {
throw new EncodingException("Unable to sign", e);
}
}
-
- /**
- * Get the length of one signature coordinate of the algorithm.
- *
- * @return length in bytes
- */
- private int coordinateLength() {
- if (algorithm == CoseAlgorithms.ES384) {
- return 48;
- }
- return algorithm == CoseAlgorithms.ES512 ? 66 : 32;
- }
-
- /**
- * Convert a DER encoded ECDSA signature to r and s concatenated.
- *
- * @param der DER encoded signature
- * @param length length of one coordinate
- * @return r and s concatenated
- * @throws EncodingException if the signature is not a DER sequence of two integers
- */
- @Nonnull
- static byte[] derToConcat(@Nonnull final byte[] der, final int length) throws EncodingException {
- try {
- int offset = 1;
- offset += (der[offset] & 0x80) != 0 ? 1 + (der[offset] & 0x7f) : 1;
- final byte[] concat = new byte[2 * length];
- for (int part = 0; part < 2; part++) {
- final int size = der[offset + 1] & 0xff;
- final int start = offset + 2;
- final int copy = Math.min(size, length);
- System.arraycopy(der, start + size - copy, concat, part * length + length - copy, copy);
- offset = start + size;
- }
- return concat;
- } catch (final ArrayIndexOutOfBoundsException e) {
- throw new EncodingException("Malformed DER signature", e);
- }
- }
}
diff --git a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/cose/impl/CoseSign1SignerTest.java b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/cose/impl/CoseSign1SignerTest.java
index 4155966..5bb3e57 100644
--- a/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/cose/impl/CoseSign1SignerTest.java
+++ b/openid-vci-impl/src/test/java/org/geant/shibboleth/plugin/openidvci/cose/impl/CoseSign1SignerTest.java
@@ -141,21 +141,6 @@ public class CoseSign1SignerTest {
(byte[]) protectedChain.get(3)));
}
- @Test
- public void derToConcat() throws Exception {
- for (int i = 0; i < 20; i++) {
- final Signature signer = Signature.getInstance("SHA256withECDSA");
- signer.initSign(privateKey);
- signer.update(PAYLOAD);
- final byte[] concat = CoseSign1Signer.derToConcat(signer.sign(), 32);
- Assert.assertEquals(concat.length, 64);
- final Signature verifier = Signature.getInstance("SHA256withECDSAinP1363Format");
- verifier.initVerify(publicKey);
- verifier.update(PAYLOAD);
- Assert.assertTrue(verifier.verify(concat));
- }
- }
-
@Test
public void coseKey() throws Exception {
final String expected = "a401022001215820" + HexFormat.of().formatHex(Base64.getUrlDecoder().decode(X))
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list