101 throw new SignatureException(
"The signature algorithm is null");
104 throw new SignatureException(
"The ECDSA public key is null");
106 if (signingInput == null) {
107 throw new SignatureException(
"The signing input is null");
114 algorithm =
"SHA256WITHECDSA";
118 algorithm =
"SHA384WITHECDSA";
122 algorithm =
"SHA512WITHECDSA";
126 throw new SignatureException(
"Unsupported signature algorithm");
130 byte[] sigBytes = Base64Util.base64urldecode(signature);
131 byte[] sigInBytes = signingInput.getBytes(Util.UTF8_STRING_ENCODING);
133 ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(curve);
134 BigInteger q = ((ECCurve.AbstractFp) ecSpec.getCurve()).getField().getCharacteristic();
137 ECPoint pointQ =
new ECPoint.Fp(ecSpec.getCurve(), xFieldElement, yFieldElement);
138 ECPublicKeySpec publicKeySpec =
new ECPublicKeySpec(pointQ, ecSpec);
140 KeyFactory keyFactory = KeyFactory.getInstance(
"ECDSA",
"BC");
141 PublicKey publicKey = keyFactory.generatePublic(publicKeySpec);
143 Signature sig = Signature.getInstance(algorithm,
"BC");
144 sig.initVerify(publicKey);
145 sig.update(sigInBytes);
146 return sig.verify(sigBytes);
147 }
catch (InvalidKeySpecException e) {
148 throw new SignatureException(e);
149 }
catch (InvalidKeyException e) {
150 throw new SignatureException(e);
151 }
catch (NoSuchAlgorithmException e) {
152 throw new SignatureException(e);
153 }
catch (NoSuchProviderException e) {
154 throw new SignatureException(e);
155 }
catch (UnsupportedEncodingException e) {
156 throw new SignatureException(e);
157 }
catch (Exception e) {
158 throw new SignatureException(e);
BigInteger getX()
Definition: ECDSAPublicKey.java:54
SignatureAlgorithm getSignatureAlgorithm()
Definition: AbstractJwsSigner.java:37
ECDSAPublicKey ecdsaPublicKey
Definition: ECDSASigner.java:42
BigInteger getY()
Definition: ECDSAPublicKey.java:62