diff --git a/cryptography_s_des_exploring/sdes/keys.py b/cryptography_s_des_exploring/sdes/keys.py new file mode 100644 index 0000000..58d4a9a --- /dev/null +++ b/cryptography_s_des_exploring/sdes/keys.py @@ -0,0 +1,24 @@ +from cryptography_s_des_exploring.sdes.sdes import apply_table, left_shift, p8_table, p10_table + + +def generate_subkeys(key: str): + """ + Returns generated two subkeys: K1, K2 - from the 10-bit key + + key is a binary which represented with a 10 character string. + """ + + temp = apply_table(key, p10_table) + left = temp[:5] + right = temp[5:] + left = left_shift(left) + right = left_shift(right) + key1 = apply_table(left + right, p8_table) + left = left_shift(left) + right = left_shift(right) + left = left_shift(left) + right = left_shift(right) + key2 = apply_table(left + right, p8_table) + + return key1, key2 +