File tree Expand file tree Collapse file tree
src/test/java/org/apache/xml/security/test/dom/algorithms Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626
2727import java .security .KeyPair ;
2828import java .security .KeyPairGenerator ;
29+ import java .security .interfaces .RSAPublicKey ;
2930
3031import 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 ();
You can’t perform that action at this time.
0 commit comments