Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to verify a ECC signature with OpenSSL command?

I have a public key, a 192 bit hash, and a 384 bit signature, all as .txt hex files, and the curve is prime192v1.

What command lines can I use to verify the message with OpenSSL?

like image 774
skvery Avatar asked Sep 16 '25 18:09

skvery


1 Answers

For reference, the EC key can be created with the following command:

  • Create the EC key:

    $ openssl ecparam -genkey -name prime192v1 > key.pem
    
  • Extract the public key:

    $ openssl ec -in key.pem -pubout > pub.pem
    

Signing the hash of a message and verifying the signature with an EC key can be done the same way as with other key types:

  • Calculate the hash (use a hash funtion of your choice):

    $ openssl dgst -sha256 -binary message.txt > hash.txt
    
  • Sign the hash with the private key:

     $ openssl pkeyutl -sign -inkey key.pem -in hash.txt > sig.txt
    
  • Verify the signature with the public key:

     $ openssl pkeyutl -verify -in hash.txt -sigfile sig.txt -inkey pub.pem -pubin
     Signature Verified Successfully
    
like image 189
f9c69e9781fa194211448473495534 Avatar answered Sep 19 '25 22:09

f9c69e9781fa194211448473495534