Hi I have generated a key pair and used the private key to generate a signature.
openssl rsautl -sign -in helloworld.txt -inkey aa.pem -out sig
However I am unable to verify the signature with my public key:
openssl rsautl -verify -in helloworld.txt -inkey aa.pub -sigfile sig
I know there -sigfile is deprecated. and some of the online doc from openssl.org is wrong.
Whats the command I should use to verify the sig with my public key?
To verify a signature, the recipient first decrypts the signature using a public key that matches with the senders private key. This produces a digest. Then the recipient calculates a digest from the received data and verifies that it matches with the one in the signature. If the digest match, the signature is valid.
Right click the .exe of the program in question and select Properties. Select Digital Signatures. Under Signature List, select the Signature, and click Details. You will see information regarding the Code Signing certificate that was used to sign the executable.
Check the signature on an EXE or MSI fileRight-click the EXE or MSI file and select Properties. Click the Digital Signatures tab to check the signature.
Digital signature and verification A digital signature is a mathematical scheme for presenting the authenticity of digital messages or documents. Message / file to be sent is signed with private key. Message received by the recipient is authenticated using public key.
I found two solutions to your problem.
You can use rsautl that way: (with private key: my.key and public key my-pub.pem)
$ openssl rsautl -sign -inkey my.key -out in.txt.rsa -in in.txt Enter pass phrase for my.key: $ openssl rsautl -verify -inkey my-pub.pem -in in.txt.rsa -pubin Bonjour
With this method, all the document is included within the signature file and is outputted by the final command.
But in my case, my certificate says: Signature Algorithm: sha1WithRSAEncryption. So I would recommend you to use the standard way of signing document in 4 steps: (This method is used for all asymmetric electronic signatures in order not to overcharge the signature file and/or CPU usage)
OpenSSL does this in two steps:
$ openssl dgst -sha256 -sign my.key -out in.txt.sha256 in.txt Enter pass phrase for my.key: $ openssl dgst -sha256 -verify my-pub.pem -signature in.txt.sha256 in.txt Verified OK
With this method, you sent the recipient two documents: the original file plain text, the signature file signed digest. Attention: the signature file does not include the whole document! Only the digest.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With