@@ -1429,7 +1429,7 @@ public void signatureWithSZeroShouldFail() throws Exception {
14291429 }
14301430
14311431 @ Test
1432- public void signatureWithRSValueNotLessThanOrderShouldFail () throws Exception {
1432+ public void signatureWithRValueNotLessThanOrderShouldFail () throws Exception {
14331433 exception .expect (SignatureException .class );
14341434
14351435 ECPublicKey publicKey = (ECPublicKey ) readPublicKeyFromFile (PUBLIC_KEY_FILE_256 , "EC" );
@@ -1444,4 +1444,22 @@ public void signatureWithRSValueNotLessThanOrderShouldFail() throws Exception {
14441444 ECDSAAlgorithm algorithm256 = (ECDSAAlgorithm ) Algorithm .ECDSA256 (publicKey , privateKey );
14451445 algorithm256 .validateSignatureStructure (invalidSignature , publicKey );
14461446 }
1447+
1448+ @ Test
1449+ public void signatureWithSValueNotLessThanOrderShouldFail () throws Exception {
1450+ exception .expect (SignatureException .class );
1451+
1452+ ECPublicKey publicKey = (ECPublicKey ) readPublicKeyFromFile (PUBLIC_KEY_FILE_256 , "EC" );
1453+ ECPrivateKey privateKey = (ECPrivateKey ) readPrivateKeyFromFile (PRIVATE_KEY_FILE_256 , "EC" );
1454+
1455+ String signedJwt = JWT .create ().sign (Algorithm .ECDSA256 (publicKey , privateKey ));
1456+ String jwtWithInvalidSig = signedJwt .substring (0 , signedJwt .lastIndexOf ('.' ) + 1 ) + "_____wAAAAD__________7zm-q2nF56E87nKwvxjJVH_____AAAAAP__________vOb6racXnoTzucrC_GMlUQ" ;
1457+
1458+ String [] chunks = jwtWithInvalidSig .split ("\\ ." );
1459+ byte [] invalidSignature = Base64 .getUrlDecoder ().decode (chunks [2 ]);
1460+ invalidSignature [0 ] = Byte .MAX_VALUE ;
1461+
1462+ ECDSAAlgorithm algorithm256 = (ECDSAAlgorithm ) Algorithm .ECDSA256 (publicKey , privateKey );
1463+ algorithm256 .validateSignatureStructure (invalidSignature , publicKey );
1464+ }
14471465}
0 commit comments