Skip to content

OPENSSH KeyReader for more keys - #614

Merged
drieseng merged 3 commits into
sshnet:developfrom
darinkes:openssh_format_rsa
Apr 18, 2021
Merged

OPENSSH KeyReader for more keys#614
drieseng merged 3 commits into
sshnet:developfrom
darinkes:openssh_format_rsa

Conversation

@darinkes

Copy link
Copy Markdown
Collaborator

Add support to parse OpenSSH Keys with ECDSA 256/384/521 and RSA.

Change-Id: Iaa9cce0f2522e5fee377a82cb252f81f0b7cc563

@huobazi

huobazi commented Jul 22, 2020

Copy link
Copy Markdown

+1

@xivk

xivk commented Sep 18, 2020

Copy link
Copy Markdown

Anything I can do to help with this pull request? Willing to put in some work, this is something I need.

@jons

jons commented Sep 30, 2020

Copy link
Copy Markdown

seconded for needing this feature.

@aibars

aibars commented Nov 3, 2020

Copy link
Copy Markdown

Any idea when does a new release including these changes will be released?

@epenet

epenet commented Dec 23, 2020

Copy link
Copy Markdown

@darinkes there is a conflict on the branch. Could you maybe rebase it?

@darinkes
darinkes force-pushed the openssh_format_rsa branch 3 times, most recently from 040ae97 to 4b11594 Compare January 2, 2021 09:45
@epenet

epenet commented Jan 5, 2021

Copy link
Copy Markdown

@drieseng is there anything we can do to help getting this merged in?

Comment thread src/Renci.SshNet/PrivateKeyFile.cs Outdated
Comment thread src/Renci.SshNet/PrivateKeyFile.cs Outdated
Comment thread src/Renci.SshNet/PrivateKeyFile.cs Outdated
Comment thread src/Renci.SshNet/PrivateKeyFile.cs
Comment thread src/Renci.SshNet/PrivateKeyFile.cs
Comment thread src/Renci.SshNet/PrivateKeyFile.cs Outdated
Comment thread src/Renci.SshNet/PrivateKeyFile.cs Outdated
Comment thread src/Renci.SshNet/PrivateKeyFile.cs Outdated
Comment thread src/Renci.SshNet/PrivateKeyFile.cs Outdated
@drieseng

Copy link
Copy Markdown
Member

@darinkes LGTM, with some comments. Please update README.md as well.

Some other things I'd like to discuss:

KeyHostAlgorithm

To me, either:

  • KeyHostAlgorithm remains public, and we update PrivateKeyFile.HostKey to return KeyHostAlgorithm.
    -or-
  • We change KeyHostAlgorithm to internal.

IDisposable

In PrivateKeyFile, we currently keep a "copy" of Key around to be able to dispose it.
We could instead implement IDisposable on KeyHostAlgorithm.

Regardless where we dispose the key, we should also check if the key effectively implements IDisposable instead of always casting to IDisposable like we do now. This allows us to remove the dummy IDisposable implementation from EcdsaKey and ED25519Key.

PrivateKeyFile unit tests

Right now, the unit tests for PrivateKeyFile are limited to verifying whether we do not throw an exception when loading a given key format. Shouldn't we verify whether the key information is correctly read, and cover more failure conditions?

@chrduc

chrduc commented Jan 21, 2021

Copy link
Copy Markdown

@drieseng @darinkes what is the ETA for your openssh_format_rsa PR? We are wanting this change ASAP

@darinkes

Copy link
Copy Markdown
Collaborator Author

@drieseng @darinkes what is the ETA for your openssh_format_rsa PR? We are wanting this change ASAP

I hope to have some spare time this weekend to include the comments of @drieseng

@drieseng

Copy link
Copy Markdown
Member

@chrduc Don't forget that we all have day jobs. Consider sponsoring @darinkes and/or SSH.NET to show us your appreciation :p

@chrduc

chrduc commented Jan 29, 2021

Copy link
Copy Markdown

@drieseng @darinkes what is the ETA for your openssh_format_rsa PR? We are wanting this change ASAP

I hope to have some spare time this weekend to include the comments of @drieseng

Thanks @darinkes

@darinkes

Copy link
Copy Markdown
Collaborator Author

Updated the PR with suggestions from @drieseng.
Would be awesome if someone could take this PR for a test-ride.

@darinkes

Copy link
Copy Markdown
Collaborator Author

@darinkes LGTM, with some comments. Please update README.md as well.

PrivateKeyFile unit tests

Right now, the unit tests for PrivateKeyFile are limited to verifying whether we do not throw an exception when loading a given key format. Shouldn't we verify whether the key information is correctly read, and cover more failure conditions?

I would also like to use new keys on each run instead of hardcoded resources.

@drieseng

drieseng commented Feb 1, 2021

Copy link
Copy Markdown
Member

I would also like to use new keys on each run instead of hardcoded resources.

I don't see a problem with the hardcoded resources. They should also allow for predictable results to verify against.
What would the advantage be of using new keys?

@drieseng

drieseng commented Feb 1, 2021

Copy link
Copy Markdown
Member

@darinkes Can you have a look at my other comments here?

@drieseng

drieseng commented Feb 1, 2021

Copy link
Copy Markdown
Member

Would be awesome if someone could take this PR for a test-ride.

When I have some time, I'll add integrations tests. For now these integration tests are still closed source :(
I should also find time to open source these.

@darinkes

darinkes commented Feb 1, 2021

Copy link
Copy Markdown
Collaborator Author

Some other things I'd like to discuss:

KeyHostAlgorithm

To me, either:

  • KeyHostAlgorithm remains public, and we update PrivateKeyFile.HostKey to return KeyHostAlgorithm.
    -or-
  • We change KeyHostAlgorithm to internal.

No opinion on that.

IDisposable

In PrivateKeyFile, we currently keep a "copy" of Key around to be able to dispose it.
We could instead implement IDisposable on KeyHostAlgorithm.

Regardless where we dispose the key, we should also check if the key effectively implements IDisposable instead of always casting to IDisposable like we do now. This allows us to remove the dummy IDisposable implementation from EcdsaKey and ED25519Key.

Ack, makes sense.

PrivateKeyFile unit tests

Right now, the unit tests for PrivateKeyFile are limited to verifying whether we do not throw an exception when loading a given key format. Shouldn't we verify whether the key information is correctly read, and cover more failure conditions?

Ack, this should be added as well.

I would also like to use new keys on each run instead of hardcoded resources.

I don't see a problem with the hardcoded resources. They should also allow for predictable results to verify against.
What would the advantage be of using new keys?

My concern is the padding, to ensure its done right hardcoded resources just test it works for those keys.
But maybe just overthinking it.

This was referenced Aug 12, 2026
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.