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

雨燕双飞 提交于 2019-11-28 01:27:23

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!