(String token, String pem)
| 376 | // ==================================================== |
| 377 | |
| 378 | static byte[] es256Sign(String token, String pem) { |
| 379 | try { |
| 380 | PrivateKey key = ecP256PrivateKeyFromPem(pem); |
| 381 | Signature sig = Signature.getInstance("SHA256withECDSAinP1363Format"); |
| 382 | sig.initSign(key); |
| 383 | sig.update(token.getBytes(StandardCharsets.US_ASCII)); |
| 384 | return sig.sign(); |
| 385 | } catch (Exception e) { |
| 386 | throw new RuntimeException("ES256 signing failed: " + e.getMessage(), e); |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | private static PrivateKey ecP256PrivateKeyFromPem(String pem) throws Exception { |
| 391 | if (pem == null) throw new IllegalArgumentException("pem is null"); |
no test coverage detected