OpenSSL, private key decryption

Ok, so I have a text file called Kryptert that is encrypted. A key file called private with a private key. I want the result to be in a Klartext text file.

I'm going to rip my hair off because I can't figure it out.

openssl rsautl -decrypt -inkey C:\private.key -in C:\Kryptert.txt -out C:\Klartext.txt

The command above is what I use, and I get the following output in CMD windows:

C:\Users\Marco>openssl rsautl -decrypt -inkey C:\private.key -in C:\Kryptert.txt -out C:\Klartext.txt
Loading 'screen' into random state - done
RSA operation error
8560:error:0407106B:rsa routines:RSA_padding_check_PKCS1_type_2:block type is not 02:.\crypto\rsa\rsa_pk1.c:190:
8560:error:04065072:rsa routines:RSA_EAY_PRIVATE_DECRYPT:padding check failed:.\crypto\rsa\rsa_eay.c:592:

Anyone who can help me figure out what is wrong and how can I fix it? Thank.

+4
source share
1 answer

Here you have the commands needed to encrypt or decrypt using openssl:

Decrypt:

$ openssl rsautl -decrypt -in $ENCRYPTED -out $PLAINTEXT -inkey keys/privkey.pem

Encryption:

$ openssl rsautl -encrypt -in $PLAINTEXT -out $PLAINTEXT.encrypt -pubin -inkey keys/pubkey.pem

Hope this helps! :)

+7
source

Source: https://habr.com/ru/post/1670079/


All Articles