The following command generates a signature for an input file:
openssl dgst -sha1 -sign privateKey.pem -out signature1 someInputFile
The following commands also generates a signature for an input file:
openssl dgst -binary -sha1 someInputFile > digest
openssl rsautl -sign -in digest -inkey privateKey.pem -out signature2
As far as I know, they should both create the RSA signature of a SHA1 digest of the file. But they don't generate the same signature.
As a result, the signature generated with method 2 can also not be verified by an openssl dgst -verify
call.
Does somebody know what the difference is, and how that can be overcome?
rsautl -sign
includes the encrypted contents of the input file (or digest in your case) in the output signature file. To just do raw RSA signing, useopenssl pkeyutl
as explained in stackoverflow.com/questions/9380856/…