web-dev-qa-db-fra.com

OpenSSL, décryptage avec une clé privée

Bon, j'ai donc un fichier texte nommé Kryptert qui est chiffré . Un fichier de clé nommé privé avec la clé privée Je veux que la sortie soit dans un fichier texte nommé Klartext.

Je suis sur le point de m'arracher les cheveux, car je n'arrive pas à comprendre.

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

La commande ci-dessus correspond à ce que j'utilise et la sortie suivante s'affiche dans les fenêtres CMD:

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:

Toute personne capable de m'aider à comprendre ce qui ne va pas et comment je pourrais le réparer? Je vous remercie.

6
Exhausti

Vous avez ici les commandes dont vous avez besoin pour chiffrer ou déchiffrer à l'aide de openssl:

Décrypter:

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

Crypter:

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

J'espère que cela t'aides! :)

16
aicastell

Pour le cryptage: 

openssl rsautl -encrypt -in /path/to/your/file -out /path/to/your/encrypted -pubin -inkey /path/to/your/public_key.pem

Pour le décryptage: 

openssl rsautl -decrypt -in /path/to/your/encrypted -out /path/where/you/want/your/decrypted.txt -inkey /path/to/your/private_key.pem

Note: Si vous avez cette erreur de déchiffrement: RSA_EAY_PRIVATE_DECRYPT:data greater than mod len essayez cette commande avant de déchiffrer votre fichier: 

cat yourEncryptedFile| base64 -D > yourEncryptedRawFile

Plus d'informations ici

1
Pedro Trujillo