Repository navigation
Fix #834: Keep RSA signature algorithm per connection for shared keys - #835
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #835 +/- ##
===========================================
+ Coverage 99.85% 99.87% +0.02%
===========================================
Files 95 102 +7
Lines 27784 32576 +4792
Branches 2908 3125 +217
===========================================
+ Hits 27743 32535 +4792
Misses 38 38
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Owner
|
Thanks very much for the analysis and fix! This change will be part of the next AsyncSSH release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #834.
set_sig_algorithmchanges the keypair object it is called on, and those objects are shared:listen()prepares oneSSHServerConnectionOptionsand hands it to every connection fromconn_factory(), so all connections on a listener shareoptions.server_host_keys. Thersa-sha2-256,rsa-sha2-512andssh-rsaentries are one keypair object.choose_server_host_keysets the negotiated algorithm on it, so a connection that negotiated one RSA algorithm can sign its exchange hash with the algorithm another connection negotiated in the meantime, and its client rejects the signature._choose_signature_algdoes the same to client keys and client host keys, which can be shared through a reusedSSHClientConnectionOptionsor passed in asSSHKeyPairobjects.Copying in
load_keypairs()gives one copy per options object, which is still shared by every connection on a listener, so this copies per connection instead:choose_server_host_keywhen it has to change the signature algorithm (a key used with its default algorithm is never changed, so it can stay shared);set_sig_algorithmonly sets instance attributes, so a shallow copy is enough.Tests:
test_server_host_key_signature_alg_per_connectionholds arsa-sha2-256connection open while arsa-sha2-512connection is made on the same listener and checks each connection's host key; without the fix both reportrsa-sha2-512.test_shared_client_key_signature_algandtest_shared_client_host_key_signature_algcheck that a shared client keypair is unchanged after signing. All three fail without the fix and pass with it.I'm OK with releasing this code under the Eclipse Public License v2.0. Please list me as Zoltan Csizmadia in the contributors list.