return false;
}
ECDSAParameters initParams = getECDSAParameters(header.getAlgorithm());
X9ECParameters x9ECParameters = initParams.getX9ECParameters();
Digest digest = initParams.getDigest();
byte[] signatureBytes = signature.decode();
// Split signature into R and S parts
int rsByteArrayLength = ECDSAProvider.getSignatureByteArrayLength(header.getAlgorithm());
byte[] rBytes = new byte[rsByteArrayLength / 2];
byte[] sBytes = new byte[rsByteArrayLength / 2];
try {
System.arraycopy(signatureBytes, 0, rBytes, 0, rBytes.length);
System.arraycopy(signatureBytes, rBytes.length, sBytes, 0, sBytes.length);
} catch (Exception e) {
throw new JOSEException("Invalid ECDSA signature format: " + e.getMessage(), e);
}
BigInteger r = new BigInteger(1, rBytes);
BigInteger s = new BigInteger(1, sBytes);
ECCurve curve = x9ECParameters.getCurve();
ECPoint q = curve.createPoint(x, y);
ECDomainParameters ecDomainParameters = new ECDomainParameters(
curve,
x9ECParameters.getG(),
x9ECParameters.getN(),
x9ECParameters.getH(),
x9ECParameters.getSeed());
ECPublicKeyParameters ecPublicKeyParameters = new ECPublicKeyParameters(
q, ecDomainParameters);
org.bouncycastle.crypto.signers.ECDSASigner verifier =
new org.bouncycastle.crypto.signers.ECDSASigner();
verifier.init(false, ecPublicKeyParameters);
digest.update(signedContent, 0, signedContent.length);
byte[] out = new byte[digest.getDigestSize()];
digest.doFinal(out, 0);
return verifier.verifySignature(out, r, s);
}