Ticket #5776: randomhash_userauth2.patch

File randomhash_userauth2.patch, 1.9 KB (added by antoine, 2 years ago)
  • twisted/conch/ssh/userauth.py

    diff --git a/twisted/conch/ssh/userauth.py b/twisted/conch/ssh/userauth.py
    a b MSG_USERAUTH_REQUEST = 50 
    830830MSG_USERAUTH_FAILURE          = 51 
    831831MSG_USERAUTH_SUCCESS          = 52 
    832832MSG_USERAUTH_BANNER           = 53 
    833 MSG_USERAUTH_PASSWD_CHANGEREQ = 60 
    834 MSG_USERAUTH_INFO_REQUEST     = 60 
    835833MSG_USERAUTH_INFO_RESPONSE    = 61 
    836834MSG_USERAUTH_PK_OK            = 60 
    837835 
    838836messages = {} 
    839837for k, v in locals().items(): 
    840838    if k[:4]=='MSG_': 
    841         messages[v] = k # doesn't handle doubles 
     839        messages[v] = k 
    842840 
    843841SSHUserAuthServer.protocolMessages = messages 
    844842SSHUserAuthClient.protocolMessages = messages 
    845843del messages 
    846844del v 
     845 
     846# Doubles, not included in the protocols' mappings 
     847MSG_USERAUTH_PASSWD_CHANGEREQ = 60 
     848MSG_USERAUTH_INFO_REQUEST     = 60 
  • twisted/conch/test/test_userauth.py

    diff --git a/twisted/conch/test/test_userauth.py b/twisted/conch/test/test_userauth.py
    a b class LoopbackTestCase(unittest.TestCase 
    10601060        def check(ignored): 
    10611061            self.assertEqual(server.transport.service.name, 'TestService') 
    10621062        return d.addCallback(check) 
     1063 
     1064 
     1065 
     1066class ModuleInitializationTestCase(unittest.TestCase): 
     1067 
     1068 
     1069    def test_messages(self): 
     1070        # Several message types have value 60, check that MSG_USERAUTH_PK_OK 
     1071        # is always the one which is mapped. 
     1072        self.assertEqual(userauth.SSHUserAuthServer.protocolMessages[60], 
     1073                         'MSG_USERAUTH_PK_OK') 
     1074        self.assertEqual(userauth.SSHUserAuthClient.protocolMessages[60], 
     1075                         'MSG_USERAUTH_PK_OK') 
  • new file twisted/conch/topfiles/5776.bugfix

    diff --git a/twisted/conch/topfiles/5776.bugfix b/twisted/conch/topfiles/5776.bugfix
    new file mode 100644
    - +  
     1twisted.conch.ssh.userauth now works correctly with hash randomization enabled.