Decryption of extensions using public key

I need to decrypt a file that is encrypted with a private key. I have a public key that I can use to decrypt this file. How can i do this. I did:

openssl rsautl -in file -inkey key.pem 

But that does not work. This shows an error like:

 unable to load Private Key 3074128072:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:696:Expecting: ANY PRIVATE KEY 
+1
source share
2 answers

Public keys cannot be used for decryption; they can only be used for encryption and to verify the encryption signature.

+5
source

Unlike everyone, you can actually decrypt using a public key, however, if your data has been encrypted using the corresponding Private Key.

As for how you are going to decrypt it, from what I see, the openssl utility does not come with this function. It seems you will need to use something that uses the OpenSSL C API ( https://www.openssl.org/docs/man1.0.2/crypto/RSA_public_decrypt.html ).

Either use the C API directly, or something like binding PHP to OpenSSL.

-1
source

All Articles