VirtualMailManager/password.py
branchv0.7.x
changeset 725 300b76de5ad0
parent 722 e37f60b0e3b5
child 731 77561c118f42
equal deleted inserted replaced
724:348cd2cf9c18 725:300b76de5ad0
   155     if encoding:
   155     if encoding:
   156         if encoding == 'HEX':
   156         if encoding == 'HEX':
   157             encrypted = b2a_hex(encrypted.encode()).decode()
   157             encrypted = b2a_hex(encrypted.encode()).decode()
   158         else:
   158         else:
   159             encrypted = b64encode(encrypted.encode()).decode()
   159             encrypted = b64encode(encrypted.encode()).decode()
   160     if scheme in ('BLF-CRYPT', 'SHA256-CRYPT', 'SHA512-CRYPT') and \
       
   161        cfg_dget('misc.dovecot_version') < 0x20000b06:
       
   162         scheme = 'CRYPT'
       
   163     return _format_digest(encrypted, scheme, encoding)
   160     return _format_digest(encrypted, scheme, encoding)
   164 
   161 
   165 
   162 
   166 def _md4_hash(password, scheme, encoding):
   163 def _md4_hash(password, scheme, encoding):
   167     """Generates encoded PLAIN-MD4 hashes."""
   164     """Generates encoded PLAIN-MD4 hashes."""
   401 9qrb1jehe7hn4'
   398 9qrb1jehe7hn4'
   402     _sha512 = '$6$rounds=1000$0123456789abcdef$ZIAd5WqfyLkpvsVCVUU1GrvqaZTqvh\
   399     _sha512 = '$6$rounds=1000$0123456789abcdef$ZIAd5WqfyLkpvsVCVUU1GrvqaZTqvh\
   403 JoouxdSqJO71l9Ld3tVrfOatEjarhghvEYADkq//LpDnTeO90tcbtHR1'
   400 JoouxdSqJO71l9Ld3tVrfOatEjarhghvEYADkq//LpDnTeO90tcbtHR1'
   404 
   401 
   405     if crypt('08/15!test~4711', '$2a$04$0123456789abcdefABCDEF$') == _blowfish:
   402     if crypt('08/15!test~4711', '$2a$04$0123456789abcdefABCDEF$') == _blowfish:
   406         _scheme_info['BLF-CRYPT'] = (_crypt_hash, 0x10000f00)
   403         _scheme_info['BLF-CRYPT'] = (_crypt_hash, 0x20000b06)
   407     if crypt('08/15!test~4711', '$5$rounds=1000$0123456789abcdef$') == _sha256:
   404     if crypt('08/15!test~4711', '$5$rounds=1000$0123456789abcdef$') == _sha256:
   408         _scheme_info['SHA256-CRYPT'] = (_crypt_hash, 0x10000f00)
   405         _scheme_info['SHA256-CRYPT'] = (_crypt_hash, 0x20000b06)
   409     if crypt('08/15!test~4711', '$6$rounds=1000$0123456789abcdef$') == _sha512:
   406     if crypt('08/15!test~4711', '$6$rounds=1000$0123456789abcdef$') == _sha512:
   410         _scheme_info['SHA512-CRYPT'] = (_crypt_hash, 0x10000f00)
   407         _scheme_info['SHA512-CRYPT'] = (_crypt_hash, 0x20000b06)
   411 
   408 
   412 _test_crypt_algorithms()
   409 _test_crypt_algorithms()
   413 del _, cfg_dget, _test_crypt_algorithms
   410 del _, cfg_dget, _test_crypt_algorithms