How to get ECSDA with p-256 and SHA256 in openSSL?
Apple requests to its APNS must use JWT (JSON Web Token) signed using a Elliptic Curve Digital Signature Algorithm aka ECSDA using a p-256 curve and a SHA256 hash. How can you sign with such params in openssl?
openssl ecparam -list_curves
shows:
secp256k1 : SECG curve over a 256 bit prime field
prime256v1: X9.62/SECG curve over a 256 bit prime field
The p-256 curve you want to use is prime256v1.
Try this:
Create private key:
openssl ecparam -genkey -name prime256v1 -noout -out private.pem
Create public key:
openssl ec -in private.pem -pubout -out public.pem
Sign something
openssl dgst -sha256 -sign private.pem yourinputdocument -out yourinput.sha256 yourinput
To verify:
openssl dgst -sha256 -verify public.pem -signature yourinput.sha256 yourinputdocument