samuel-lucas6 / Kryptor

A simple, modern, and secure encryption and signing tool that aims to be a better version of age and Minisign.
https://www.kryptor.co.uk
GNU General Public License v3.0
414 stars 33 forks source link

Error: IOException - Unable to retrieve private key. #20

Closed ghost closed 3 years ago

samuel-lucas6 commented 3 years ago

Hi @NapokW, it sounds like Kryptor can't access the private key file. Here is the subroutine that gives that exception. There are lots of things that can cause IOExceptions, so I can't really be more specific than that without knowing more.

samuel-lucas6 commented 3 years ago

Is there a way to enter the private key directly in the cmd command ?

I'm afraid not. I could implement that, but the private key is meant to be kept secret, so I followed the tactic used by Minisign and made it file only.

You'll be able to get the private key file working. To figure out what's causing the exception, you could download the source code and remove the try catch that I linked above.

samuel-lucas6 commented 3 years ago

And last question . I create a file with notepad name encryption.private but the program doesn't work with . Do you know why ? ( it's not encryption.private.txt . Just encryption.private with the good pv key)

I really need more detail than that to be able to help. What error are you getting? Have you copied the private key string into it? Did you accidentally copy a signing private key into it? Did you accidentally modify the key? What's the size of the file?

samuel-lucas6 commented 3 years ago

Oh sorry I explain . To automatise the encryption of my folder I create a program in c# . This program was supposed to run krypton on one of my desktop folder . It work nicely and i'am grateful . But, I missclicked and delete it. No problem, I have copied the key (private and public ) in a notes . But now, I wan't to decrypt my folder to encrypt with a new key and I don't know who I can specify the private key path . I follow your tuto , I named my file " encryption.private", I add the path to my cmd command krypton -d c:/User/Napok/Desktop/Work -o -y "mykey" -x c:/User/Napok/Desktop/encryption.private

Thank you, I think I understand the issue now, although I'm not sure what you mean by 'delete it'. What did you delete? Your keys?

To specify your private key, you need to use the = symbol between -x and C:/... as explained here. Or you can move that private key to C:\Users\Napok\.kryptor and then you won't have to specify your private key at all because Kryptor will default to that location.

You also shouldn't be specifying your public key. You should only specify a public key if you're trying to send a file to someone else.

samuel-lucas6 commented 3 years ago

And just , to send a message with asymmetric encryption , can the sender just encrypt with public key ?

Nope, it requires using the sender's private key and the recipient's public key. This is because Kryptor performs a key exchange, meaning hybrid encryption is actually used rather than asymmetric encryption.

However, as I mentioned before, if the sender is using the default key location, then they never need to specify their private key. So to send a file to someone else, you can just do -e [-y RECIPIENT PUBLIC KEY] message.txt. This helps keep some commands simple :)

An important thing to note though is that the encrypted message can't be decrypted by the sender because this is one-way. You've just got to be careful with -o|--overwrite because you could accidentally lose access to your files that way. Perhaps I should add a confirmation message or something there.

Have you resolved the original issue you were having? If you have, I'll go ahead and close this issue.

samuel-lucas6 commented 3 years ago

And he's gone...