Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with partial initialization of a decrypted private key in open SSH format #55

Merged
merged 1 commit into from
Aug 5, 2021

Conversation

pavelsher
Copy link

Attempt to decrypt an RSA key stored in an encrypted form in an OpenSSH format and then fetch private key throws an exception:
Exception in thread "main" java.lang.NullPointerException
at com.jcraft.jsch.KeyPairRSA.getPrivateKey(KeyPairRSA.java:105)

This happens because ep_array and eq_array are not initialized when KeyPairRSA is created.

…was in the open ssh format - ep_array and eq_array were not initialized and it was impossible to obtain a private key byte array because of NullPointerException on attempt to read these arrays length.

Not sure if it is possible to read these arrays from the Buffer, but it seems the same approach as for putty & fsecure keys also works fine.
orybak pushed a commit to JetBrains/teamcity-git that referenced this pull request Jul 29, 2021
@norrisjeremy
Copy link
Contributor

I would have to defer to @mwiede as I'm not as familiar with the various ssh key file formats.

mwiede added a commit that referenced this pull request Aug 5, 2021
mwiede added a commit that referenced this pull request Aug 5, 2021
@mwiede mwiede merged commit 2c91f25 into mwiede:master Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants