12345678910111213 |
- def _crypt_secret_to_key(secret):
- """convert secret to 64-bit DES key.
- this only uses the first 8 bytes of the secret,
- and discards the high 8th bit of each byte at that.
- a null parity bit is inserted after every 7th bit of the output.
- """
- # NOTE: this would set the parity bits correctly,
- # but des_encrypt_int_block() would just ignore them...
- ##return sum(expand_7bit(byte_elem_value(c) & 0x7f) << (56-i*8)
- ## for i, c in enumerate(secret[:8]))
- return sum((byte_elem_value(c) & 0x7f) << (57-i*8)
- for i, c in enumerate(secret[:8]))
|