Skip to content

Commit 6a391df

Browse files
committed
Fixing Cryptographic Edge Case test on Java 21+.
1 parent c226aae commit 6a391df

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/test/java/org/apache/xml/security/test/dom/algorithms/CryptographicEdgeCasesTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import java.security.KeyPair;
2828
import java.security.KeyPairGenerator;
29+
import java.security.interfaces.RSAPublicKey;
2930

3031
import static org.junit.jupiter.api.Assertions.*;
3132

@@ -79,8 +80,9 @@ void testAllZerosSignatureRejected() throws Exception {
7980
// Initialize verification
8081
sa.initVerify(keyPair.getPublic());
8182

82-
// Create all-zeros signature (256 bytes for RSA-2048)
83-
byte[] zeroSignature = new byte[256];
83+
// Create all-zeros signature with the exact byte length expected for this key
84+
int signatureLength = (((RSAPublicKey) keyPair.getPublic()).getModulus().bitLength() + 7) / 8;
85+
byte[] zeroSignature = new byte[signatureLength];
8486

8587
// Update with some data
8688
byte[] data = "test data".getBytes();

0 commit comments

Comments
 (0)