ECDSA: Verify Signature

To generate ECDSA Digital Signature: ECDSA: Generate ECDSA Key/Certificate/Signature By openssl

Using openssl

1
openssl dgst -sha256 -verify ecdsasigner-pub.key -signature signature <file_need_to_verify>

Using Java

1
2
3
4
5
6
7
8
9
10
11
12
public static boolean isVerifyPassed(InputStream certIs, byte[] data, String signature) {
boolean res = false;
try {
Certificate certificate = CertificateFactory.getInstance("X.509").generateCertificate(certIs);
Signature verifier = Signature.getInstance("SHA256withECDSA");
verifier.initVerify(certificate);
verifier.update(data);
res = verifier.verify(Base64.decode(signature, Base64.NO_WRAP));
} catch (Exception ignored) {
}
return res;
}