Skip to content

Commit

Permalink
Merge branch '2.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
bitprophet committed Mar 18, 2022
2 parents b924489 + b9292e0 commit 6b31705
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions paramiko/auth_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ def _finalize_pubkey_algorithm(self, key_type):
DEBUG,
"NOTE: you may use the 'disabled_algorithms' SSHClient/Transport init kwarg to disable that or other algorithms if your server does not support them!", # noqa
)
if key_type.endswith("[email protected]"):
pubkey_algo += "[email protected]"
self.transport._agreed_pubkey_algorithm = pubkey_algo
return pubkey_algo

Expand Down
2 changes: 1 addition & 1 deletion paramiko/rsakey.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def sign_ssh_data(self, data, algorithm="ssh-rsa"):
algorithm=self.HASHES[algorithm](),
)
m = Message()
m.add_string(algorithm)
m.add_string(algorithm.replace("[email protected]", ""))
m.add_string(sig)
return m

Expand Down
3 changes: 3 additions & 0 deletions sites/www/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog
=========

- :bug:`1963` (via :issue:`1977`) Certificate-based pubkey auth was
inadvertently broken when adding SHA2 support; this has been fixed. Reported
by Erik Forsberg and fixed by Jun Omae.
- :bug:`2002` (via :issue:`2003`) Switch from module-global to thread-local
storage when recording thread IDs for a logging helper; this should avoid one
flavor of memory leak for long-running processes. Catch & patch via Richard
Expand Down
19 changes: 19 additions & 0 deletions tests/test_pkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,3 +754,22 @@ def test_new_keyfiles_avoid_descriptor_race_integration(self):
finally:
if os.path.exists(new):
os.unlink(new)

def test_sign_rsa_with_certificate(self):
data = b"ice weasels"
key_path = _support(os.path.join("cert_support", "test_rsa.key"))
key = RSAKey.from_private_key_file(key_path)
msg = key.sign_ssh_data(data, "rsa-sha2-256")
msg.rewind()
assert "rsa-sha2-256" == msg.get_text()
sign = msg.get_binary()
cert_path = _support(
os.path.join("cert_support", "test_rsa.key-cert.pub")
)
key.load_certificate(cert_path)
msg = key.sign_ssh_data(data, "[email protected]")
msg.rewind()
assert "rsa-sha2-256" == msg.get_text()
assert sign == msg.get_binary()
msg.rewind()
assert key.verify_ssh_sig(b"ice weasels", msg)

0 comments on commit 6b31705

Please sign in to comment.