Hi,
Recently, I was studying about openssl.
I found that encrypting with a private key is allowed while decrypting with the public one isn't, and throws an error:
unable to load Private Key or A private key is needed for this operation
-----------------------------Generating Private/Public Keys--------------------------------------
$ openssl genrsa -out prv.pem 1024 ## generating a private key
$ openssl rsa -in prv.pem -pubout -out Emett_pubKey.pub ## generating the public key
------------------------------Encrypting/Decrypting Message--------------------------------------
$ openssl rsautl -encrypt -inkey prv.pem -in Message -out Enc_Mssg ## Encrypt file=Message
$ openssl rsautl -decrypt -in Enc_Mssg -out Messg -inkey -pubin Emett_pubKey.pub ## try to decrypt file=Enc_Mssg
>A private key is needed for this operation
I am wondering if I'm just using openssl in a wrong way or it must be done in a different way, something like using -sign
instead of encrypting the Message like I did.