如何使用OpenSSL命令验证ECC签名?

3

我有一份公钥、一个192位的哈希值和一个384位的签名,它们都是以.txt十六进制文件的形式存在的,曲线为prime192v1。

我应该使用哪些命令行来通过OpenSSL验证这条消息?

1个回答

3

参考以下命令可以创建 EC 密钥:

  • Create the EC key:

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

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

使用EC密钥签署消息的哈希值并验证签名的方式与其他密钥类型相同:

  • 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 key.pem
     Signature Verified Successfully
    

我认为最后一个命令应该是 openssl pkeyutl -verify -in hash.txt -sigfile sig.txt -inkey pub.pem -pubin。你使用了私钥来进行验证,但应该使用公钥。 - Blaz

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接