Language: python3
on pyCharm
Requirements: sympy
to install: pip install sympy
Code's logic: For both LAT & DDT there are similarities in the code: 1 big global variable holding the necessary information. Next on get_values, check_value, print_table, traverse, print_DDT/print_LAT functions the input from the user is taken and shown in tables. The difference is on calc_value function:
For LAT:
- get the inputmask and outputmask from traverse function.
- get the sboxinput and sboxoutput values
- then take single bits from the both the inputs and outputs
- xor and compare them
- if the result is true increment the
total
variable - finally return
total - 2**(n-1) [2**(4-1) = 8]
[2**(n-1) - 2**(n/2 - 1) / 2**(n-1) - |max|]
returns the percentage ofnlm
For DDT:
- get a and b from traverse function
- then get the value for S(x ^ a) as variable x.
- finally xOR it with S(X) which is sboxo
- if the S(X) xOR S(X xOR a) == b returns true increment total
- return total