How to apply DES Sbox 1?

9 views (last 30 days)
lilly lord
lilly lord on 28 Jun 2023
Commented: lilly lord on 29 Jun 2023
Hi. I want to apply DES Sbox1.
S-box1= [ 14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7 ...
0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8 ...
4 1 14 8 13 6 2 11 15 12 9 7 3 10 5 0 ...
15 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13 ];
num=[15 23 19 12 8];
N=de2bi(num,6,'left-msb');
I want to apply sbox on N.
If any one can help...

Answers (1)

Image Analyst
Image Analyst on 29 Jun 2023
You can't have a subtraction operation on the left wide of an equals sign:
S-box1 = ...............
The right side of the equals sign needs to be put into a variable, not an expression (a subtraction operation, like S minus box1)
What is sbox? And what does it mean to "apply" sbox on N?
  2 Comments
lilly lord
lilly lord on 29 Jun 2023
Yes you are right . Its should be S_box1. The image below, shows the entries of S_box1.
If we want to replace 15. Then first convert into 6-bit binary i.e 001111.
The left most bit 0 and the right most bit 1 together become 01 determines the row, which is 1.
the inner bits 0111 (which is 7) determines the coloumn.
By looking at the table , the entry at (1,7) gives 1.
The above example takes 6-bit input i.e 110010, The left and right most bits 10 means row number 2 and the inner bits are 1001 means 9 so the col number is 9. the corresponding value at (2,9) is 12 so the six bit number is replaced by 12.
What is sbox?
Sbox or the substitution box used in block ciphers to hide any linear relationship between input and output bits. The Sbox shared is a part of the first modern block cipher. And it is not classified. One can find the implementation of the whole algorithm in https://www.mathworks.com/matlabcentral/fileexchange/37847-data-encryption-standard-des
I want to only use one Sbox and the above algorithm shared is very complicated.
lilly lord
lilly lord on 29 Jun 2023
DES is not classified. And it doesnot violate any laws. Rather it is used to for teaching purpose.

Sign in to comment.

Categories

Find more on Encryption / Cryptography in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!