comparison MoinMoin/support/passlib/handlers/des_crypt.py @ 6096:86a41c2bedec

upgrade passlib from 1.6.2 to 1.6.5
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 05 Sep 2016 23:44:04 +0200
parents efd7c0be3339
children 7f0616feeae9
comparison
equal deleted inserted replaced
6095:465cb6f5c6d7 6096:86a41c2bedec
38 ## for i, c in enumerate(secret[:8])) 38 ## for i, c in enumerate(secret[:8]))
39 return sum((byte_elem_value(c) & 0x7f) << (57-i*8) 39 return sum((byte_elem_value(c) & 0x7f) << (57-i*8)
40 for i, c in enumerate(secret[:8])) 40 for i, c in enumerate(secret[:8]))
41 41
42 def _raw_des_crypt(secret, salt): 42 def _raw_des_crypt(secret, salt):
43 "pure-python backed for des_crypt" 43 """pure-python backed for des_crypt"""
44 assert len(salt) == 2 44 assert len(salt) == 2
45 45
46 # NOTE: some OSes will accept non-HASH64 characters in the salt, 46 # NOTE: some OSes will accept non-HASH64 characters in the salt,
47 # but what value they assign these characters varies wildy, 47 # but what value they assign these characters varies wildy,
48 # so just rejecting them outright. 48 # so just rejecting them outright.
71 71
72 # run h64 encode on result 72 # run h64 encode on result
73 return h64big.encode_int64(result) 73 return h64big.encode_int64(result)
74 74
75 def _bsdi_secret_to_key(secret): 75 def _bsdi_secret_to_key(secret):
76 "covert secret to DES key used by bsdi_crypt" 76 """covert secret to DES key used by bsdi_crypt"""
77 key_value = _crypt_secret_to_key(secret) 77 key_value = _crypt_secret_to_key(secret)
78 idx = 8 78 idx = 8
79 end = len(secret) 79 end = len(secret)
80 while idx < end: 80 while idx < end:
81 next = idx+8 81 next = idx+8
83 key_value = des_encrypt_int_block(key_value, key_value) ^ tmp_value 83 key_value = des_encrypt_int_block(key_value, key_value) ^ tmp_value
84 idx = next 84 idx = next
85 return key_value 85 return key_value
86 86
87 def _raw_bsdi_crypt(secret, rounds, salt): 87 def _raw_bsdi_crypt(secret, rounds, salt):
88 "pure-python backend for bsdi_crypt" 88 """pure-python backend for bsdi_crypt"""
89 89
90 # decode salt 90 # decode salt
91 try: 91 try:
92 salt_value = h64.decode_int24(salt) 92 salt_value = h64.decode_int24(salt)
93 except ValueError: # pragma: no cover - always caught by class 93 except ValueError: # pragma: no cover - always caught by class