hierynomus / hierynomus/sshj

Problem using PuTTYKeyFile

Open
#460 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.7k
Forks
620
Avg merge
3d 23h
Merged PRs (30d)
11

Description

Hi

I recently noticed the support for PuTTY Key File handling in SSHJ and am now using it.

However I have a further requirement to look at Putty Key file handling outside of SSHJ e.g. extract public key.

For this I have been looking at using the PuTTYKeyFile class directly, but I hit a few problems.

So is PuTTYKeyFile intended for API usage? I appreciate this is possibly engineering to be used under the covers within SSHJ.

If so then can I make a few observations that would improve it?

My main issue is when check a file (.ppk) to determine if it is encrypted.

I see that init() and isEncrypted() methods are public so should I be able to do this?
```
PuTTYKeyFile pkf = new PuTTYKeyFile();
pkf.init(new File("C:/myEncryptedPuttyFile.ppk"));
System.out.println("File is encrypted["+pkf.isEncrypted()+"]");
```

However with this I always get false.

The reason appears to be that isEncrypted() (which is public) inspects "headers" map, but used this way this map is empty. Digging a bit deeper I can see that "headers" is populated in "parseKeyPair()", but this is protected and therefore can't be directly called.

Now, as I say, it's possible that you never intended this class to be used externally from SSHJ, so should isEncrytped() should be "protected" scope rather than "public"?

But I think with a few tweaks this could be a very useful utility - if you agree then I could possibly take a deeper look and provide a pull request.

For my requirement I need to check the file is encrypted, before prompting user then supplying calling "init(File location, PasswordFinder pwdf)" to specify the password later.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.