Skip to content

add support for aes256-gcm and aes128-gcm - #2444

Closed
cmason3 wants to merge 2 commits into
paramiko:mainfrom
cmason3:main
Closed

cmason3 wants to merge 2 commits into
paramiko:mainfrom
cmason3:main

Conversation

@cmason3

@cmason3 cmason3 commented Sep 11, 2024

Copy link
Copy Markdown
Contributor

Updated pull request which should provide a clean merge against the main branch - it is basically the same as #2157

@adiroiban

Copy link
Copy Markdown

Thanks for the PR.

I guess that in order to have this merged, it will need automated tests and some sort of documenation or mention in the release notes that GCM support was added.

@tuxmaster5000

Copy link
Copy Markdown

Thanks this patch will works again the master. But I think the patch must also patch the tests, because the tests now fails with:

tests/test_transport.py ...s...................................s........ [ 87%]
.................................................F..                     [ 98%]
=================================== FAILURES ===================================
_______ TestStrictKex.test_sequence_numbers_reset_on_newkeys_when_strict _______

self = <tests.test_transport.TestStrictKex object at 0x7f0b18869460>

    def test_sequence_numbers_reset_on_newkeys_when_strict(self):
        with server(defer=True) as (tc, ts):
            # When in strict mode, these should all be zero or close to it
            # (post-kexinit, pre-auth).
            # Server->client will be 1 (EXT_INFO got sent after NEWKEYS)
>           assert tc.packetizer._Packetizer__sequence_number_in == 1
E           assert 0 == 1
E            +  where 0 = <paramiko.packet.Packetizer object at 0x7f0b16d72a50>._Packetizer__sequence_number_in
E            +    where <paramiko.packet.Packetizer object at 0x7f0b16d72a50> = <paramiko.Transport at 0x16d70ef0 (cipher aes128-ctr, 128 bits) (connected; awaiting auth)>.packetizer

tests/test_transport.py:1397: AssertionError
----------------------------- Captured stderr call -----------------------------
[101935.11724472046]	DEBUG:paramiko.transport:starting thread (server mode): 0x16d706e0
[101935.45150756836]	DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_3.4.1
[101935.73451042175]	DEBUG:paramiko.transport:starting thread (client mode): 0x16d70ef0
[101936.03992462158]	DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_3.4.1
[101936.203956604]	DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-paramiko_3.4.1
[101936.3260269165]	INFO:paramiko.transport:Connected (version 2.0, client paramiko_3.4.1)
[101936.58900260925]	DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-paramiko_3.4.1
[101936.74635887146]	INFO:paramiko.transport:Connected (version 2.0, client paramiko_3.4.1)
[101937.40844726562]	DEBUG:paramiko.transport:read message from sock
[101937.85309791565]	DEBUG:paramiko.transport:read message from sock
[101938.03453445435]	DEBUG:paramiko.transport:raw data length[8]
[101938.24195861816]	DEBUG:paramiko.transport:=== Key exchange possibilities ===
[101938.36712837219]	DEBUG:paramiko.transport:kex algos: [email protected], ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group16-sha512, diffie-hellman-group-exchange-sha256, diffie-hellman-group14-sha256, diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1, diffie-hellman-group1-sha1, ext-info-c, [email protected]
[101938.48085403442]	DEBUG:paramiko.transport:server key: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, rsa-sha2-512, rsa-sha2-256, ssh-rsa, ssh-dss, [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
[101938.58766555786]	DEBUG:paramiko.transport:client encrypt: aes128-ctr, aes192-ctr, aes256-ctr, aes128-cbc, aes192-cbc, aes256-cbc, 3des-cbc, [email protected], [email protected]
[101938.68851661682]	DEBUG:paramiko.transport:server encrypt: aes128-ctr, aes192-ctr, aes256-ctr, aes128-cbc, aes192-cbc, aes256-cbc, 3des-cbc, [email protected], [email protected]
[101938.78531455994]	DEBUG:paramiko.transport:client mac: hmac-sha2-256, hmac-sha2-512, [email protected], [email protected], hmac-sha1, hmac-md5, hmac-sha1-96, hmac-md5-96
[101938.884973526]	DEBUG:paramiko.transport:server mac: hmac-sha2-256, hmac-sha2-512, [email protected], [email protected], hmac-sha1, hmac-md5, hmac-sha1-96, hmac-md5-96
[101938.98844718933]	DEBUG:paramiko.transport:raw data length[8]
[101939.1360282898]	DEBUG:paramiko.transport:client compress: none
[101939.39304351807]	DEBUG:paramiko.transport:=== Key exchange possibilities ===
[101939.55302238464]	DEBUG:paramiko.transport:server compress: none
[101939.71586227417]	DEBUG:paramiko.transport:kex algos: [email protected], ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group16-sha512, diffie-hellman-group-exchange-sha256, diffie-hellman-group14-sha256, diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1, diffie-hellman-group1-sha1, [email protected]
[101939.870595932]	DEBUG:paramiko.transport:client lang: <none>
[101940.03772735596]	DEBUG:paramiko.transport:server key: rsa-sha2-512, rsa-sha2-256, ssh-rsa
[101940.18697738647]	DEBUG:paramiko.transport:server lang: <none>
[101940.3350353241]	DEBUG:paramiko.transport:client encrypt: aes128-ctr, aes192-ctr, aes256-ctr, aes128-cbc, aes192-cbc, aes256-cbc, 3des-cbc, [email protected], [email protected]
[101940.4866695404]	DEBUG:paramiko.transport:kex follows: False
[101940.63353538513]	DEBUG:paramiko.transport:server encrypt: aes128-ctr, aes192-ctr, aes256-ctr, aes128-cbc, aes192-cbc, aes256-cbc, 3des-cbc, [email protected], [email protected]
[101940.77610969543]	DEBUG:paramiko.transport:=== Key exchange agreements ===
[101940.92178344727]	DEBUG:paramiko.transport:client mac: hmac-sha2-256, hmac-sha2-512, [email protected], [email protected], hmac-sha1, hmac-md5, hmac-sha1-96, hmac-md5-96
[101941.08152389526]	DEBUG:paramiko.transport:Strict kex mode: True
[101941.21527671814]	DEBUG:paramiko.transport:server mac: hmac-sha2-256, hmac-sha2-512, [email protected], [email protected], hmac-sha1, hmac-md5, hmac-sha1-96, hmac-md5-96
[101941.39337539673]	DEBUG:paramiko.transport:Kex: [email protected]
[101941.5397644043]	DEBUG:paramiko.transport:client compress: none
[101941.73550605774]	DEBUG:paramiko.transport:HostKey: rsa-sha2-512
[101941.8830871582]	DEBUG:paramiko.transport:server compress: none
[101942.07286834717]	DEBUG:paramiko.transport:Cipher: aes128-ctr
[101942.2218799591]	DEBUG:paramiko.transport:client lang: <none>
[101942.82150268555]	DEBUG:paramiko.transport:server lang: <none>
[101942.9292678833]	DEBUG:paramiko.transport:kex follows: False
[101943.08567047119]	DEBUG:paramiko.transport:=== Key exchange agreements ===
[101943.36533546448]	DEBUG:paramiko.transport:Strict kex mode: True
[101943.53890419006]	DEBUG:paramiko.transport:Kex: [email protected]
[101943.69435310364]	DEBUG:paramiko.transport:HostKey: rsa-sha2-512
[101943.84241104126]	DEBUG:paramiko.transport:Cipher: aes128-ctr
[101944.00119781494]	DEBUG:paramiko.transport:MAC: hmac-sha2-256
[101944.13328170776]	DEBUG:paramiko.transport:Compression: none
[101944.24295425415]	DEBUG:paramiko.transport:=== End of kex handshake ===
[101944.73218917847]	DEBUG:paramiko.transport:read message from sock
[101945.36066055298]	DEBUG:paramiko.transport:MAC: hmac-sha2-256
[101945.62149047852]	DEBUG:paramiko.transport:Compression: none
[101945.74856758118]	DEBUG:paramiko.transport:=== End of kex handshake ===
[101946.16508483887]	DEBUG:paramiko.transport:read message from sock
[101946.3062286377]	DEBUG:paramiko.transport:raw data length[8]
[101947.53527641296]	DEBUG:paramiko.transport:EOF in transport thread
[101948.86112213135]	DEBUG:paramiko.transport:Resetting outbound seqno after NEWKEYS due to strict mode
[101949.07426834106]	DEBUG:paramiko.transport:raw data length[8]
[101949.37920570374]	DEBUG:paramiko.transport:kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256>
[101950.45399665833]	DEBUG:paramiko.transport:read message from sock
[101951.40671730042]	DEBUG:paramiko.transport:Resetting outbound seqno after NEWKEYS due to strict mode
[101951.5323638916]	DEBUG:paramiko.transport:raw data length[8]
[101951.75194740295]	DEBUG:paramiko.transport:kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256>
[101951.97176933289]	DEBUG:paramiko.transport:Switch to new keys ...
[101952.7018070221]	DEBUG:paramiko.transport:read message from sock
[101952.87799835205]	DEBUG:paramiko.transport:raw data length[8]
[101953.05156707764]	DEBUG:paramiko.transport:Switch to new keys ...
[101953.87077331543]	DEBUG:paramiko.transport:Resetting inbound seqno after NEWKEYS due to strict mode
[101954.21528816223]	DEBUG:paramiko.transport:Resetting inbound seqno after NEWKEYS due to strict mode
[101954.41222190857]	DEBUG:paramiko.transport:read message from sock
[101954.78129386902]	DEBUG:paramiko.transport:read message from sock
[101956.0329914093]	DEBUG:paramiko.transport:raw data length[16]
[101956.30383491516]	DEBUG:paramiko.transport:Got EXT_INFO: {'server-sig-algs': b'ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss'}
[101956.43520355225]	DEBUG:paramiko.transport:read message from sock
------------------------------ Captured log call -------------------------------
DEBUG    paramiko.transport:transport.py:1947 starting thread (server mode): 0x16d706e0
DEBUG    paramiko.transport:transport.py:1947 Local version/idstring: SSH-2.0-paramiko_3.4.1
DEBUG    paramiko.transport:transport.py:1947 starting thread (client mode): 0x16d70ef0
DEBUG    paramiko.transport:transport.py:1947 Local version/idstring: SSH-2.0-paramiko_3.4.1
DEBUG    paramiko.transport:transport.py:1947 Remote version/idstring: SSH-2.0-paramiko_3.4.1
INFO     paramiko.transport:transport.py:1947 Connected (version 2.0, client paramiko_3.4.1)
DEBUG    paramiko.transport:transport.py:1947 Remote version/idstring: SSH-2.0-paramiko_3.4.1
INFO     paramiko.transport:transport.py:1947 Connected (version 2.0, client paramiko_3.4.1)
DEBUG    paramiko.transport:packet.py:645 read message from sock
DEBUG    paramiko.transport:packet.py:645 read message from sock
DEBUG    paramiko.transport:packet.py:645 raw data length[8]
DEBUG    paramiko.transport:transport.py:1947 === Key exchange possibilities ===
DEBUG    paramiko.transport:transport.py:1947 kex algos: [email protected], ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group16-sha512, diffie-hellman-group-exchange-sha256, diffie-hellman-group14-sha256, diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1, diffie-hellman-group1-sha1, ext-info-c, [email protected]
DEBUG    paramiko.transport:transport.py:1947 server key: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, rsa-sha2-512, rsa-sha2-256, ssh-rsa, ssh-dss, [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
DEBUG    paramiko.transport:transport.py:1947 client encrypt: aes128-ctr, aes192-ctr, aes256-ctr, aes128-cbc, aes192-cbc, aes256-cbc, 3des-cbc, [email protected], [email protected]
DEBUG    paramiko.transport:transport.py:1947 server encrypt: aes128-ctr, aes192-ctr, aes256-ctr, aes128-cbc, aes192-cbc, aes256-cbc, 3des-cbc, [email protected], [email protected]
DEBUG    paramiko.transport:transport.py:1947 client mac: hmac-sha2-256, hmac-sha2-512, [email protected], [email protected], hmac-sha1, hmac-md5, hmac-sha1-96, hmac-md5-96
DEBUG    paramiko.transport:transport.py:1947 server mac: hmac-sha2-256, hmac-sha2-512, [email protected], [email protected], hmac-sha1, hmac-md5, hmac-sha1-96, hmac-md5-96
DEBUG    paramiko.transport:packet.py:645 raw data length[8]
DEBUG    paramiko.transport:transport.py:1947 client compress: none
DEBUG    paramiko.transport:transport.py:1947 === Key exchange possibilities ===
DEBUG    paramiko.transport:transport.py:1947 server compress: none
DEBUG    paramiko.transport:transport.py:1947 kex algos: [email protected], ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group16-sha512, diffie-hellman-group-exchange-sha256, diffie-hellman-group14-sha256, diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1, diffie-hellman-group1-sha1, [email protected]
DEBUG    paramiko.transport:transport.py:1947 client lang: <none>
DEBUG    paramiko.transport:transport.py:1947 server key: rsa-sha2-512, rsa-sha2-256, ssh-rsa
DEBUG    paramiko.transport:transport.py:1947 server lang: <none>
DEBUG    paramiko.transport:transport.py:1947 client encrypt: aes128-ctr, aes192-ctr, aes256-ctr, aes128-cbc, aes192-cbc, aes256-cbc, 3des-cbc, [email protected], [email protected]
DEBUG    paramiko.transport:transport.py:1947 kex follows: False
DEBUG    paramiko.transport:transport.py:1947 server encrypt: aes128-ctr, aes192-ctr, aes256-ctr, aes128-cbc, aes192-cbc, aes256-cbc, 3des-cbc, [email protected], [email protected]
DEBUG    paramiko.transport:transport.py:1947 === Key exchange agreements ===
DEBUG    paramiko.transport:transport.py:1947 client mac: hmac-sha2-256, hmac-sha2-512, [email protected], [email protected], hmac-sha1, hmac-md5, hmac-sha1-96, hmac-md5-96
DEBUG    paramiko.transport:transport.py:1947 Strict kex mode: True
DEBUG    paramiko.transport:transport.py:1947 server mac: hmac-sha2-256, hmac-sha2-512, [email protected], [email protected], hmac-sha1, hmac-md5, hmac-sha1-96, hmac-md5-96
DEBUG    paramiko.transport:transport.py:1947 Kex: [email protected]
DEBUG    paramiko.transport:transport.py:1947 client compress: none
DEBUG    paramiko.transport:transport.py:1947 HostKey: rsa-sha2-512
DEBUG    paramiko.transport:transport.py:1947 server compress: none
DEBUG    paramiko.transport:transport.py:1947 Cipher: aes128-ctr
DEBUG    paramiko.transport:transport.py:1947 client lang: <none>
DEBUG    paramiko.transport:transport.py:1947 server lang: <none>
DEBUG    paramiko.transport:transport.py:1947 kex follows: False
DEBUG    paramiko.transport:transport.py:1947 === Key exchange agreements ===
DEBUG    paramiko.transport:transport.py:1947 Strict kex mode: True
DEBUG    paramiko.transport:transport.py:1947 Kex: [email protected]
DEBUG    paramiko.transport:transport.py:1947 HostKey: rsa-sha2-512
DEBUG    paramiko.transport:transport.py:1947 Cipher: aes128-ctr
DEBUG    paramiko.transport:transport.py:1947 MAC: hmac-sha2-256
DEBUG    paramiko.transport:transport.py:1947 Compression: none
DEBUG    paramiko.transport:transport.py:1947 === End of kex handshake ===
DEBUG    paramiko.transport:packet.py:645 read message from sock
DEBUG    paramiko.transport:transport.py:1947 MAC: hmac-sha2-256
DEBUG    paramiko.transport:transport.py:1947 Compression: none
DEBUG    paramiko.transport:transport.py:1947 === End of kex handshake ===
DEBUG    paramiko.transport:packet.py:645 read message from sock
DEBUG    paramiko.transport:packet.py:645 raw data length[8]
DEBUG    paramiko.transport:transport.py:1947 EOF in transport thread
DEBUG    paramiko.transport:transport.py:1947 Resetting outbound seqno after NEWKEYS due to strict mode
DEBUG    paramiko.transport:packet.py:645 raw data length[8]
DEBUG    paramiko.transport:transport.py:1947 kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256>
DEBUG    paramiko.transport:packet.py:645 read message from sock
DEBUG    paramiko.transport:transport.py:1947 Resetting outbound seqno after NEWKEYS due to strict mode
DEBUG    paramiko.transport:packet.py:645 raw data length[8]
DEBUG    paramiko.transport:transport.py:1947 kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256>
DEBUG    paramiko.transport:transport.py:1947 Switch to new keys ...
DEBUG    paramiko.transport:packet.py:645 read message from sock
DEBUG    paramiko.transport:packet.py:645 raw data length[8]
DEBUG    paramiko.transport:transport.py:1947 Switch to new keys ...
DEBUG    paramiko.transport:transport.py:1947 Resetting inbound seqno after NEWKEYS due to strict mode
DEBUG    paramiko.transport:transport.py:1947 Resetting inbound seqno after NEWKEYS due to strict mode
DEBUG    paramiko.transport:packet.py:645 read message from sock
DEBUG    paramiko.transport:packet.py:645 read message from sock
DEBUG    paramiko.transport:packet.py:645 raw data length[16]
DEBUG    paramiko.transport:transport.py:1947 Got EXT_INFO: {'server-sig-algs': b'ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss'}
DEBUG    paramiko.transport:packet.py:645 read message from sock
--------------------------- Captured stderr teardown ---------------------------
[101984.63320732117]	DEBUG:paramiko.transport:EOF in transport thread

@cmason3

cmason3 commented Sep 11, 2024

Copy link
Copy Markdown
Contributor Author

I fixed the Style and Lint errors that the CircleCI tests were throwing up.

I am not that familiar with Unit Tests - How are you executing those - when I run python3 -m unittest tests/test_transport.py I am getting failures on the main branch without the patch?

The following is failing with the CircleCI test (Test 3.6 w/ cryptography==3.3.2 - Failed), but this looks like it isn't going to work regardless of what I change:

Writing SSH key for checkout to "/home/circleci/.ssh/id_rsa"
Writing SSH public key for checkout to "/home/circleci/.ssh/id_rsa.pub"
Cloning git repository
Cloning into '.'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
error running git clone "[email protected]:paramiko/paramiko.git": exit status 128

error running git clone "[email protected]:paramiko/paramiko.git": exit status 128

@cmason3

cmason3 commented Sep 11, 2024

Copy link
Copy Markdown
Contributor Author

If I run the following from a clean clone of the main branch then I get the following failures before I even change anything - is this expected (Python 3.11)?

(python) cmason3@rocket:~/paramiko$ python3 -m unittest
...........ss.Exception (client): Error reading SSH protocol banner
Traceback (most recent call last):
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2341, in _check_banner
    buf = self.packetizer.readline(timeout)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cmason3/paramiko/paramiko/packet.py", line 381, in readline
    buf += self._read_timeout(timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cmason3/paramiko/paramiko/packet.py", line 626, in _read_timeout
    raise socket.timeout()
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2157, in run
    self._check_banner()
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2345, in _check_banner
    raise SSHException(
paramiko.ssh_exception.SSHException: Error reading SSH protocol banner

...............s.Socket exception: Connection reset by peer (104)
..../home/cmason3/paramiko/paramiko/pkey.py:508: ResourceWarning: unclosed <socket.socket fd=6, family=1, type=1, proto=0, raddr=/tmp/ssh-XXXXoP19Tp/agent.815526>
  with open(filename, "r") as f:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/cmason3/paramiko/paramiko/pkey.py:508: ResourceWarning: unclosed <socket.socket fd=20, family=1, type=1, proto=0, raddr=/tmp/ssh-XXXXoP19Tp/agent.815526>
  with open(filename, "r") as f:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
....Socket exception: Connection reset by peer (104)
.s.../home/cmason3/paramiko/tests/test_client.py:692: DeprecationWarning: isSet() is deprecated, use is_set() instead
  self.assertTrue(self.event.isSet())
............E...s...............Socket exception: Connection reset by peer (104)
...............s................................................................s.....Secsh channel 0 open FAILED: : Administratively prohibited
.E..Oops, unhandled type 3 ('unimplemented')
........./usr/lib/python3.11/unittest/case.py:579: ResourceWarning: unclosed <socket.socket fd=5, family=2, type=1, proto=0, laddr=('127.0.0.1', 56555)>
  if method() is not None:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/usr/lib/python3.11/unittest/case.py:579: ResourceWarning: unclosed <socket.socket fd=6, family=2, type=1, proto=0, laddr=('127.0.0.1', 57194), raddr=('127.0.0.1', 56555)>
  if method() is not None:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
.Unknown exception: TransportTest.test_rekey_deadlock.<locals>._negotiate_keys_wrapper() missing 1 required positional argument: 'm'
Traceback (most recent call last):
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2208, in run
    self._handler_table[ptype](m)
TypeError: TransportTest.test_rekey_deadlock.<locals>._negotiate_keys_wrapper() missing 1 required positional argument: 'm'

.........Oops, unhandled type 3 ('unimplemented')
..Oops, unhandled type 52 ('userauth-success')
.Secsh channel 0 open FAILED: : Administratively prohibited
..Oops, unhandled type 52 ('userauth-success')
Oops, unhandled type 51 ('userauth-failure')
Oops, unhandled type 53 ('userauth--banner')
Oops, unhandled type 60 ('userauth-gssapi-response')
.........Exception (server): Incompatible ssh peer (no acceptable host key)
Exception (client): Incompatible ssh peer (no acceptable host key)
Traceback (most recent call last):
Traceback (most recent call last):
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2208, in run
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2208, in run
    self._handler_table[ptype](m)
    self._handler_table[ptype](m)
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2328, in _negotiate_keys
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2328, in _negotiate_keys
    self._parse_kex_init(m)
    self._parse_kex_init(m)
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2580, in _parse_kex_init
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2580, in _parse_kex_init
    raise IncompatiblePeer(
    raise IncompatiblePeer(
paramiko.ssh_exception.IncompatiblePeer: Incompatible ssh peer (no acceptable host key)
paramiko.ssh_exception.IncompatiblePeer: Incompatible ssh peer (no acceptable host key)


.Exception (client): Incompatible ssh peer (no acceptable host key)
Exception (server): Incompatible ssh peer (no acceptable host key)
Traceback (most recent call last):
Traceback (most recent call last):
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2208, in run
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2208, in run
    self._handler_table[ptype](m)
    self._handler_table[ptype](m)
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2328, in _negotiate_keys
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2328, in _negotiate_keys
    self._parse_kex_init(m)
    self._parse_kex_init(m)
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2580, in _parse_kex_init
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2580, in _parse_kex_init
    raise IncompatiblePeer(
    raise IncompatiblePeer(
paramiko.ssh_exception.IncompatiblePeer: Incompatible ssh peer (no acceptable host key)
paramiko.ssh_exception.IncompatiblePeer: Incompatible ssh peer (no acceptable host key)


......Secsh channel 0 open FAILED: : Administratively prohibited
.E..Oops, unhandled type 3 ('unimplemented')
........./usr/lib/python3.11/unittest/case.py:579: ResourceWarning: unclosed <socket.socket fd=5, family=2, type=1, proto=0, laddr=('127.0.0.1', 51879)>
  if method() is not None:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/usr/lib/python3.11/unittest/case.py:579: ResourceWarning: unclosed <socket.socket fd=6, family=2, type=1, proto=0, laddr=('127.0.0.1', 60354), raddr=('127.0.0.1', 51879)>
  if method() is not None:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
.Unknown exception: TransportTest.test_rekey_deadlock.<locals>._negotiate_keys_wrapper() missing 1 required positional argument: 'm'
Traceback (most recent call last):
  File "/home/cmason3/paramiko/paramiko/transport.py", line 2208, in run
    self._handler_table[ptype](m)
TypeError: TransportTest.test_rekey_deadlock.<locals>._negotiate_keys_wrapper() missing 1 required positional argument: 'm'

.........Oops, unhandled type 3 ('unimplemented')
..Oops, unhandled type 52 ('userauth-success')
.Secsh channel 0 open FAILED: : Administratively prohibited
..Oops, unhandled type 6 ('service-accept')
Oops, unhandled type 52 ('userauth-success')
Oops, unhandled type 51 ('userauth-failure')
Oops, unhandled type 53 ('userauth--banner')
Oops, unhandled type 60 ('userauth-gssapi-response')
...........
======================================================================
ERROR: test_write_buffer (tests.test_file.BufferedFileTest.test_write_buffer)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/cmason3/paramiko/tests/test_file.py", line 209, in test_write_buffer
    f.write(buffer(data, offset, 8))  # noqa
            ^^^^^^
NameError: name 'buffer' is not defined

======================================================================
ERROR: test_channel_send_buffer (tests.test_transport.ServiceRequestingTransportTest.test_channel_send_buffer)
verify sending buffer instances to a channel
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/cmason3/paramiko/tests/test_transport.py", line 932, in test_channel_send_buffer
    sent += chan.send(buffer(data, sent, 8))  # noqa
                      ^^^^^^
NameError: name 'buffer' is not defined

======================================================================
ERROR: test_channel_send_buffer (tests.test_transport.TransportTest.test_channel_send_buffer)
verify sending buffer instances to a channel
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/cmason3/paramiko/tests/test_transport.py", line 932, in test_channel_send_buffer
    sent += chan.send(buffer(data, sent, 8))  # noqa
                      ^^^^^^
NameError: name 'buffer' is not defined

----------------------------------------------------------------------
Ran 242 tests in 27.270s

FAILED (errors=3, skipped=7)

@tuxmaster5000

Copy link
Copy Markdown

I fixed the Style and Lint errors that the CircleCI tests were throwing up.

I am not that familiar with Unit Tests - How are you executing those - when I run python3 -m unittest tests/test_transport.py I am getting failures on the main branch without the patch?

The following is failing with the CircleCI test (Test 3.6 w/ cryptography==3.3.2 - Failed), but this looks like it isn't going to work regardless of what I change:

Writing SSH key for checkout to "/home/circleci/.ssh/id_rsa"
Writing SSH public key for checkout to "/home/circleci/.ssh/id_rsa.pub"
Cloning git repository
Cloning into '.'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
error running git clone "[email protected]:paramiko/paramiko.git": exit status 128

error running git clone "[email protected]:paramiko/paramiko.git": exit status 128

This I think is not an real error, it looks like more an defective pipieline config.

@tuxmaster5000

Copy link
Copy Markdown

I have run it again on my side. 4/5 run's will pass. So I don't know why it sometimes fails.
my test environment:

platform linux -- Python 3.12.5, pytest-7.4.3, pluggy-1.3.0
packaging-23.2
idna-3.7
urllib3-1.26.19
rpm-generators
docutils-0.20.1
imagesize-1.4.1
pygments-2.17.2
snowballstemmer-2.2.0
sphinx-theme
iniconfig-1.1.1
pluggy-1.3.0
charset-normalizer
requests-2.31.0
ply-3.11
pycparser-2.20
cffi-1.16.0
babel-2.16.0
markupsafe-2.1.3
jinja2-3.1.4
sphinx-1:7.2.6
cryptography-41.0.7
pynacl-1.5.0
pytest-7.4.3
devel-3.12.5
lexicon-2.0.1
pyasn1-0.5.1
bcrypt-4.0.1
setuptools-69.0.3

Using an chroot without network external network access.

@bitprophet

Copy link
Copy Markdown
Member

I and some other, crypto-knowing, folks will try to find time to review this sometime in the not too distant future. Thanks for updating the original PR this way.

Also linking the true OG feature ticket for this, #982

@bitprophet

Copy link
Copy Markdown
Member

Got a preliminary thumbs up from a cryptopal, so that's a good sign. I'll do my own RFC reading/code reviewing sometime as well.

I see @adiroiban tested the original PR against OpenSSH 9.6 server. I've got 9.6 available here, as well as a macOS-deployed 9.0. Both appear to have GCM ciphers enabled by default on both client and server configs.

What version(s) are you targeting on your end, @cmason3 and @tuxmaster5000?

@cmason3

cmason3 commented Sep 14, 2024

Copy link
Copy Markdown
Contributor Author

Thanks! I have updated our version if Paramiko with this patch and I have been running it for the past week successfully against JunOS 21.4R3, 22.2R3 and 23.2R2 as well as Cisco IOS XR 6.7.3 and 7.8.2.

@bitprophet

Copy link
Copy Markdown
Member

Awesome, also good to see successful tests against non-OpenSSH targets (we mostly just get complaints there, w/o anyone sticking around to help test fixes 🙃).

Will report back once I've had time to verify & tidy up the branch.

@bitprophet

bitprophet commented Sep 15, 2024 •

Copy link
Copy Markdown
Member

Have reviewed the code, updated inline comments, and made some notes-to-self about necessary cleanup. Next up I need to test it out in the real (both before and after any non-comment changes I make). Then it's just changelog/docs/etc time and hopefully we're good.

(Also need to identify what's up with CircleCI - it was passing the suites without too much issue last time I did a bugfix release...and things pass locally for me still, on this branch.)

bitprophet added a commit that referenced this pull request Sep 15, 2024
@bitprophet

bitprophet commented Sep 15, 2024 •

Copy link
Copy Markdown
Member

Did all that. Bit more testing (and poking CI) but then it's release time.

Minor note for future: if we wanna get super technical about this we should probably update the logic or at least the logging around MAC algorithm agreement, since AES-GCM technically doesn't "do any" (its 'tag' functions as a MAC). This didn't strike me as likely to mess anybody up too bad so I'm leaving well enough alone for now...

bitprophet added a commit that referenced this pull request Sep 15, 2024
@bitprophet

Copy link
Copy Markdown
Member

As usual, GH doesn't like it when I rebase folks' PRs, so I gotta close this manually. Commit log will show that I phrased my changes as additional commits on top of everyone else's 😇

@bitprophet bitprophet closed this Sep 15, 2024
@bitprophet

Copy link
Copy Markdown
Member

Paramiko 3.5 is now out on PyPI with this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants