Esempio n. 1
0
def _sdes_gen_key(k: BitString) -> List[BitString]:
    actual_key = bit_string.permutation_by_table(k, _sdes_gen_key_p10_table)

    result = []

    key_l = actual_key[:_sdes_key_length // 2]
    key_r = actual_key[_sdes_key_length // 2:]

    for i in range(_sdes_gen_key_rounds):
        key_l = bit_string.left_rshift(key_l,
                                       _sdes_gen_key_lshift_count_table[i])
        key_r = bit_string.left_rshift(key_r,
                                       _sdes_gen_key_lshift_count_table[i])

        result.append(
            bit_string.permutation_by_table(operator.add(key_l, key_r),
                                            _sdes_gen_key_p8_table))

    return result
Esempio n. 2
0
def _sdes_p4(bs: BitString) -> BitString:
    return bit_string.permutation_by_table(bs, _sdes_p4_table)
Esempio n. 3
0
def _des_gen_key_pc_2_inv(bs: BitString) -> BitString:
    return bit_string.permutation_by_table(bs, _des_gen_key_pc_2_inv_table)
Esempio n. 4
0
def _des_ip_inv(bs: BitString) -> BitString:
    return bit_string.permutation_by_table(bs, _des_ip_inv_table)
Esempio n. 5
0
def _des_ip(p: BitString) -> BitString:
    return bit_string.permutation_by_table(p, _des_ip_table)
Esempio n. 6
0
def _des_gen_key_pc_2(k: BitString) -> BitString:
    return bit_string.permutation_by_table(k, _des_gen_key_pc_2_table)