function Out2 = ScaledDownSBox(In4, n) % Out2 = ScaledDownSBox(In4, n) % Inputs: In6 = a 6 bit binary vector , and n = an S-box number (between 1 % and 8). % Output: Out4= the 4 bit vector resulting from applying the nth S-box % from Table 6.8 to the 6 bit vector In6. %First we create a 3-dimensional array SBoxes for the 2 S-boxes. The nth %S-box will be SBoxes(:,:,n). if n < 1|n>2|floor(n)= 2, Out2(1) = 1; total = total - 2; else Out2(1) = 0; end if total >= 1, Out2(2) = 1; else Out2(2) = 0; end