Skip to main content
. 2021 Jul 19;7:e587. doi: 10.7717/peerj-cs.587

Table 3. S-box and inverse S-box generation algorithm.

Dynamic key-dependent S-box and inverse S-box Generation Algorithm
Input: binary sequence input by user, where K = 128
Output: S-box[j] and InvS-box[j], where j = 0,1,2……..,255
Initialization:t = 0
Step 1: n count 1’s from K, perform nth time left circular shift.
Step 2: divide K into two halves → R64, L64
Step 3: new R← R64 XOR L64, new L ← prev R64
Step 4: convert new R into bytes, i.e. K1, K2, K3, K4, K5, K6, K7 and K8
Step 5: perform nibble swap on each byte.
Step 6: Store values in array a[i]
For t = 0 to 255
for i =1 to 8
a[i] = Ki
compare a[i] with values of S-box[j]
for j = 0 to t
If a[i] != S-box[j]
S-box[j] = a[i]
j = j + 1
t = t + 1
end if
end for
i = i + 1
end for
rejoin the two halves
goto step 1
end for
Step 7: generate InvS-box[j] by using indices of S-box[j]
End