Private key encrypted with password

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
Uwe_M
Posts: 2
Joined: Thu 08 Aug 2013 06:32

Private key encrypted with password

Post by Uwe_M » Thu 08 Aug 2013 06:47

Hello,

I try to use password encrypted private keys with TScFileStorage.

If I export a private key generated by puttygen (0.62) which has no password set as openSSH-Key then I can import it in TScFileStorage without any problems.

Then I tried to set a password (i.e.: "test") and exported this key again.

I set the password-property of TScFileStorage to "test" but if I try to import the encrypted key I get "Key is broken".

I've read the corresponding postings but I can't get it to work.

What am I missing?

Thanks in advance,
Uwe

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Private key encrypted with password

Post by DemetrionQ » Thu 08 Aug 2013 15:58

Hello.

SecureBridge uses the TScFileStorage.Password property for file encryption/decryption in its own storage. This property doesn't affect key import in any way. If you need to import a key encrypted with the PuTTYgen program, you should do this using the ImportFrom method in the following way:

Code: Select all

Key.ImportFrom(Filename, Password);

Uwe_M
Posts: 2
Joined: Thu 08 Aug 2013 06:32

Re: Private key encrypted with password

Post by Uwe_M » Fri 09 Aug 2013 04:31

Hello DemetrionQ,

thanks for your quick reply.

I've tried it and now i get "Wrong data format" when I use Key.ImportFrom(File, Password) with the original key created by puttygen.

The key generated by puttygen looks like this (I've deleted some lines to post it here. Originally it has the correct number of lines).

Code: Select all

PuTTY-User-Key-File-2: ssh-rsa
Encryption: aes256-cbc
Comment: 
Public-Lines: 6
AAAAB3NzaC1yc2EAAAADAQABAAABAQCp7gritx5MRveqDi+kumjHSARXzeTH8Kcn
cSntSsYQNpVLOe0LF6WgWOxDP+UhtNfpAyLvMz1H7JRvlWpHyPhqeCXGQA+by4fM
k+H/Iy+t0UNuX0FxhdLrN+lfGqQdEyimKq3vkGEak23kLKO9UiqwCWi1YrTCggl6
ygMbo83LhNyA234hYkBDVHsR6NbWCrNY+IEkXVjE+tuy4+YUzclx
Private-Lines: 14
RL537U0L8c5BBY7fd2NnF+EhK3yszux7IVz93tuq+3ewk9wBcH8z/e8lnZ9CrmqI
VPIvAkSPjhmvtFA+Bdo5qkiqLrc0SWUQVxTBDv4CEa0w3EfboPNsLpz4Xv002xfT
+5QR/eWt5dU1dDFDpk4oCwasB8SswpQd5xBzVYPg7VFtMGN06tu3pIq325yAhfon
oNqnW3zrCgGFmqphadvnw4+ZT3MD/xwN5j9jkyvcdPffyn+GS2LmTjnJyNcfzNXZ
cUvGK31cirKOcKshjfMbRv0b1qiB7DJohDxW8GsVCV3+ekWaBI3Imp6YVkP/OHm2
WE6GwzhfvnK5dH0ixjBUt5Wjd/opGrUHBnKhJqFMd277r5ztQbFNOCmjIAYbp5Ri
FcIrZQPDsEENNkPrfwYqtd2W/CbLV8Dv9hWQVXgPD+HCtWq6hNOjsQr+EGwuF5fm
jBBIkv7BExFHPALLJVU47WCzS51H2GxO+6kDC7zl9Zi3fh21volZlVI1NRfzWCK/
Private-MAC: da96cfdb1ee78ef7fe6ad4b851bd25bcba76f9ba
Anything wrong with it that would cause the exception "Wrong data format"?

Then I tried to export this key again with puttygen to an openssh-keyfile. Then I get the exception "Key is broken" as mentioned above.

In that last two tests the TScFileStorage-password-property was empty and the password was given directly to the ImportFrom-method.

Thanks again in advance,
Uwe

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Private key encrypted with password

Post by DemetrionQ » Mon 12 Aug 2013 12:54

1) The fact is that PuTTY saves keys in its own format. SecureBridge doesn't support this format. You should export the Putty key in the OpenSSH or SSH2 format to use it with SecureBridge. For that, you should load your private key in PuTTY Key Generator and export it to any available format using the Conversions menu. After that you can import your key in TScFileStorage.

2) The "Key is broken" error means that you are using an incorrect password when importing the OpenSSH key. Make sure you have specified the correct password in the Key.ImportFrom method.

Post Reply