Different signatures when using C routines and openssl dgst, rsautl commands

后端 未结 2 777
[愿得一人]
[愿得一人] 2020-12-06 20:50

I am using following statement to create a RSA public and private key.

openssl genrsa -out ksign_private.pem 1024 openssl rsa -in ksign_private.pem -pubout > ksign_p

相关标签:
2条回答
  • 2020-12-06 21:32

    The pkeyutl command should be preferred to rsautl since pkeyutl can handle any algorithm. To obtain the same signature on the command line, you should use the following:

    openssl pkeyutl -sign -in testfile.sha1 -inkey ksign_private.pem -pkeyopt digest:sha1 -outfile testfile.sig
    

    The important part is telling openssl that you're using a digest value. Otherwise it seems to be signing a digest of your digest.

    0 讨论(0)
  • 2020-12-06 21:44

    You can directly use dgst command to hash and sign data like:

    openssl dgst -sha1 -binary -sign privkey.pem < myData > mySignature

    see docs for all options.

    0 讨论(0)
提交回复
热议问题