Skip to content
Snippets Groups Projects
Commit c66ce33e authored by dario.genga's avatar dario.genga
Browse files

Add missing modulos

parent b8494214
No related branches found
No related tags found
No related merge requests found
......@@ -179,7 +179,7 @@ def get_bezout_coefficients(a, b):
y = [0, 1]
while True:
r.append(r[i - 2] % r[i - 1])
r.append(modulo(r[i - 2], r[i - 1]))
# Continue until the rest is equal to 0
if r[i] == 0:
......@@ -215,7 +215,7 @@ def modular_inverse(a, b):
return None
if bezout == 1 and modulo(a * x, b) == 1:
return format(x % b, STRING_BINARY_FORMAT)
return format(modulo(x, b), STRING_BINARY_FORMAT)
return None
......@@ -231,7 +231,7 @@ def inverse_add_mod(a):
if type(a) == str:
a = int(a, BINARY_BASE)
res = NIBBLE_BIT_SIZE - a
res = modulo(-a, NIBBLE_BIT_SIZE)
return format(res, STRING_BINARY_FORMAT)
......@@ -373,15 +373,14 @@ def encrypt(plaintext, subkeys):
res_10 = add_mod(res_7, res_9)
# 11. Bitwise XOR the results of steps 1 and 9
res_11 = xor(res_1, res_9)
# 12. Bitwise XOR the results of steps 3 and 9
res_12 = xor(res_3, res_9)
# 13. Bitwise XOR the results of steps 2 and 10
res_13 = xor(res_2, res_10)
# 12. Bitwise XOR the results of steps 2 and 10
res_12 = xor(res_2, res_10)
# 13. Bitwise XOR the results of steps 3 and 9
res_13 = xor(res_3, res_9)
# 14. Bitwise XOR the results of steps 4 and 10
res_14 = xor(res_4, res_10)
# Create the input for the next round with the final results
# The results of the steps 12 and 13 are swapped
input_block = res_11 + res_13 + res_12 + res_14
input_block = res_11 + res_12 + res_13 + res_14
current_round += 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment