Search code examples
phpshaecdsa

How to verify ecdsa-with-SHA256 signature with PHP?


I have encountered the following issue while developing a secure system:

We receive some data which we have to verify by signature. The signature algorithm is ecdsa-with-SHA256, and openssl_verify() doesn't seem to have an option for that. Already tried searching for standalone PHP libraries like phpseclib - no luck either, ecdsa-with-SHA1 is the best option they seem to offer.

What would be an appropriate solution for that issue? Maybe I've missed some library that implements such functionality?


Solution

  • PHP's openssl_ currently supports ECDSA only with SHA1 digest (reefer to openssl_get_md_methods() output, position [14]). You'll need a workaround for this. From comments of this question (closed as off topic, by the way), but it was focused on bitcoin implementations.