@@ -204,7 +204,6 @@ class Transport(threading.Thread, ClosingContextManager):
204204 "ecdsa-sha2-nistp521" ,
205205 "rsa-sha2-512" ,
206206 "rsa-sha2-256" ,
207- "ssh-rsa" ,
208207 )
209208 # ~= PubkeyAcceptedAlgorithms
210209 _preferred_pubkeys = (
@@ -214,7 +213,6 @@ class Transport(threading.Thread, ClosingContextManager):
214213 "ecdsa-sha2-nistp521" ,
215214 "rsa-sha2-512" ,
216215 "rsa-sha2-256" ,
217- "ssh-rsa" ,
218216 )
219217 _preferred_kex = (
220218 "ecdh-sha2-nistp256" ,
@@ -307,12 +305,18 @@ class Transport(threading.Thread, ClosingContextManager):
307305 }
308306
309307 _key_info = {
310- # TODO: at some point we will want to drop this as it's no longer
311- # considered secure due to using SHA-1 for signatures. OpenSSH 8.8 no
312- # longer supports it. Question becomes at what point do we want to
313- # prevent users with older setups from using this?
314- "ssh-rsa" : RSAKey ,
315- "ssh-rsa-cert-v01@openssh.com" : RSAKey ,
308+ # TODO: do some downstream uses of this need to be able to 'see'
309+ # ssh-rsa in not-using-SHA1 contexts?
310+ # TODO: NO!!! good.
311+ # TODO: it's used in:
312+ # - Transport._verify_key - verification - do not want ssh-rsa
313+ # - SecurityOptions - only really uses this as a filter for what's
314+ # allowed to be overwritten into its .key_types (which ==
315+ # transport._preferred_keys), and since the latter doesn't want ssh-rsa
316+ # in it, this use case doesn't require that string in here either.
317+ # - AuthHandler._generate_key_from_request - server-side auth
318+ # support - is looking at the 'algorithm' field in the request when it
319+ # references this structure, so yup, do not want ssh-rsa
316320 "rsa-sha2-256" : RSAKey ,
317321 "rsa-sha2-256-cert-v01@openssh.com" : RSAKey ,
318322 "rsa-sha2-512" : RSAKey ,
@@ -1396,11 +1400,13 @@ def connect(
13961400 # TODO: a more robust implementation would be to ask each key class
13971401 # for its nameS plural, and just use that.
13981402 # TODO: that could be used in a bunch of other spots too
1403+ # TODO: don't we have that now, lol
1404+ # TODO: either way this is ~= like using SecurityOptions.key_types
1405+ # = xxx, but different, which sucks sigh
13991406 if isinstance (hostkey , RSAKey ):
14001407 self ._preferred_keys = [
14011408 "rsa-sha2-512" ,
14021409 "rsa-sha2-256" ,
1403- "ssh-rsa" ,
14041410 ]
14051411 else :
14061412 self ._preferred_keys = [hostkey .get_name ()]
@@ -2002,6 +2008,8 @@ def _verify_key(self, host_key, sig):
20022008 key : PKey = self ._key_info [self .host_key_type ](Message (host_key ))
20032009 if key is None :
20042010 raise SSHException ("Unknown host key type" )
2011+ # TODO: like, here, can a host offer "ssh-rsa" but request SHA2, or are
2012+ # those baked in?
20052013 if not key .verify_ssh_sig (self .H , Message (sig )):
20062014 raise SSHException (
20072015 "Signature verification ({}) failed." .format (
@@ -3232,6 +3240,14 @@ def key_types(self):
32323240
32333241 @key_types .setter
32343242 def key_types (self , x ):
3243+ # TODO: so this reads Transport._key_info.keys(), yells if any values
3244+ # in `x` /aren't/ in that list, then overwrites
3245+ # Transport._preferred_keys with `x`...
3246+ # TODO: so you can read this pretty simply as "replace
3247+ # transport._preferred_keys with x".
3248+ # TODO: which is...bad...in cases where SSHClient is trying to simply
3249+ # load up known_hosts or system known hosts, and use those to determine
3250+ # which hostkey /algorithms/ it is willing to accept
32353251 self ._set ("_preferred_keys" , "_key_info" , x )
32363252
32373253 @property
0 commit comments