Philipp Hörist pushed to branch master at gajim / python-nbxmpp

Commits:

3 changed files:

Changes:

  • nbxmpp/auth.py
    ... ... @@ -119,7 +119,10 @@ class SASL:
    119 119
     
    
    120 120
             self._log.info('Chosen auth mechanism: %s', chosen_mechanism)
    
    121 121
     
    
    122
    -        if chosen_mechanism in ('SCRAM-SHA-256', 'SCRAM-SHA-1', 'PLAIN'):
    
    122
    +        if chosen_mechanism in ('SCRAM-SHA-512',
    
    123
    +                                'SCRAM-SHA-256',
    
    124
    +                                'SCRAM-SHA-1',
    
    125
    +                                'PLAIN'):
    
    123 126
                 if not self._password:
    
    124 127
                     self._on_sasl_finished(False, 'no-password')
    
    125 128
                     return
    
    ... ... @@ -134,7 +137,11 @@ class SASL:
    134 137
             #                                     channel_binding_data)
    
    135 138
             #     self._method.initiate(self._client.username, self._password)
    
    136 139
     
    
    137
    -        if chosen_mechanism == 'SCRAM-SHA-256':
    
    140
    +        if chosen_mechanism == 'SCRAM-SHA-512':
    
    141
    +            self._method = SCRAM_SHA_512(self._client, None)
    
    142
    +            self._method.initiate(self._client.username, self._password)
    
    143
    +
    
    144
    +        elif chosen_mechanism == 'SCRAM-SHA-256':
    
    138 145
                 self._method = SCRAM_SHA_256(self._client, None)
    
    139 146
                 self._method.initiate(self._client.username, self._password)
    
    140 147
     
    
    ... ... @@ -442,5 +449,12 @@ class SCRAM_SHA_256_PLUS(SCRAM_SHA_256):
    442 449
         _channel_binding = 'p=tls-unique,,'
    
    443 450
     
    
    444 451
     
    
    452
    +class SCRAM_SHA_512(SCRAM):
    
    453
    +
    
    454
    +    _mechanism = 'SCRAM-SHA-512'
    
    455
    +    _channel_binding = 'n,,'
    
    456
    +    _hash_method = 'sha512'
    
    457
    +
    
    458
    +
    
    445 459
     class AuthFail(Exception):
    
    446 460
         pass

  • nbxmpp/client.py
    ... ... @@ -284,7 +284,8 @@ class Client(Observable):
    284 284
     
    
    285 285
         @property
    
    286 286
         def mechs(self):
    
    287
    -        return set(self._allowed_mechs or set(['SCRAM-SHA-256',
    
    287
    +        return set(self._allowed_mechs or set(['SCRAM-SHA-512',
    
    288
    +                                               'SCRAM-SHA-256',
    
    288 289
                                                    'SCRAM-SHA-1',
    
    289 290
                                                    'PLAIN']))
    
    290 291
     
    

  • nbxmpp/protocol.py
    ... ... @@ -44,6 +44,7 @@ def ascii_upper(s):
    44 44
         return s.upper()
    
    45 45
     
    
    46 46
     SASL_AUTH_MECHS = [
    
    47
    +    'SCRAM-SHA-512',
    
    47 48
         'SCRAM-SHA-256-PLUS',
    
    48 49
         'SCRAM-SHA-256',
    
    49 50
         'SCRAM-SHA-1-PLUS',