Skip to content

Commit

Permalink
fix: base64urlencode public key parameters
Browse files Browse the repository at this point in the history
- applies to X/Y for EC
- N/E for RSA
  • Loading branch information
ascheibal committed Jan 15, 2024
1 parent c3e043e commit a1817d0
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,17 @@ private void assertVerificationMethod(Object in, String kid, X509Certificate dsc

if (dsc.getPublicKey().getAlgorithm().equals(CertificateTestUtils.SignerType.EC.getSigningAlgorithm())) {
Assertions.assertEquals(((ECPublicKey) dsc.getPublicKey()).getW().getAffineX(),
new BigInteger(Base64.getDecoder().decode(publicKeyJwk.get("x").toString())));
new BigInteger(Base64.getUrlDecoder().decode(publicKeyJwk.get("x").toString())));
Assertions.assertEquals(((ECPublicKey) dsc.getPublicKey()).getW().getAffineY(),
new BigInteger(Base64.getDecoder().decode(publicKeyJwk.get("y").toString())));
new BigInteger(Base64.getUrlDecoder().decode(publicKeyJwk.get("y").toString())));
Assertions.assertEquals(CertificateTestUtils.SignerType.EC.getSigningAlgorithm(),
publicKeyJwk.get("kty").toString());
Assertions.assertEquals("P-256", publicKeyJwk.get("crv").toString());
} else {
Assertions.assertEquals(((RSAPublicKey) dsc.getPublicKey()).getPublicExponent(),
new BigInteger(Base64.getDecoder().decode(publicKeyJwk.get("e").toString())));
new BigInteger(Base64.getUrlDecoder().decode(publicKeyJwk.get("e").toString())));
Assertions.assertEquals(((RSAPublicKey) dsc.getPublicKey()).getModulus(),
new BigInteger(Base64.getDecoder().decode(publicKeyJwk.get("n").toString())));
new BigInteger(Base64.getUrlDecoder().decode(publicKeyJwk.get("n").toString())));
Assertions.assertEquals(CertificateTestUtils.SignerType.RSA.getSigningAlgorithm(),
publicKeyJwk.get("kty").toString());
}
Expand Down

0 comments on commit a1817d0

Please sign in to comment.