First, we need to generate the SDES key using the given K1 and K2:

K1 = 0001 0011 (in binary) K2 = 0010 0100 (in binary)

We need to expand K1 to 8 bits using the P10 permutation:

P10: 3 5 2 7 4 10 1 9 8 6 K1 after P10: 0010 1110

Then we need to split the result into two halves and shift each half to the left by one bit:

Left shift (LS-1): LS-1: 1 0 0 1 1 1 0 1 LS-1: 0 0 1 0 1 1 1 0

Right shift (LS-1): LS-1: 1 0 0 1 1 1 0 1 LS-1: 0 1 0 0 1 1 1 1

We then combine the two halves and use the P8 permutation to generate the first SDES key:

P8: 6 3 7 4 8 5 10 9 K1 after P8: 0100 1011 (in binary)

We repeat the same process to generate the second SDES key using K2:

P10: 3 5 2 7 4 10 1 9 8 6 K2 after P10: 1001 0010

Left shift (LS-1): LS-1: 1 0 0 1 0 0 1 0 LS-1: 0 0 1 0 0 1 0 1

Right shift (LS-1): LS-1: 1 0 0 1 0 0 1 0 LS-1: 1 0 0 1 0 0 1 0

P8: 6 3 7 4 8 5 10 9 K2 after P8: 0100 1001 (in binary)

Now we can encrypt the plaintext using these two keys. The plaintext is 23 in hexadecimal, which is 0010 0011 in binary.

First, we need to apply the initial permutation IP:

IP: 2 6 3 1 4 8 5 7 Plaintext after IP: 0100 1000

Next, we apply the SDES rounds. There are two rounds in SDES, and we use a different key for each round. For each round, we first expand the 4-bit input to 8 bits using the EP permutation:

EP: 4 1 2 3 2 3 4 1 Right half after EP: 0010 0100

We then XOR the result with the current key:

Round 1: Key: 0100 1011 Result of XOR: 0110 1111

Next, we split the result into two 4-bit parts and apply the S-boxes:

S0: Row: 01 (binary) = 1 (decimal) Column: 111 (binary) = 7 (decimal) S0[1][7] = 01 (binary)

S1: Row: 101 (binary) = 5 (decimal) Column: 110 (binary) = 6 (decimal) S1[5][6] = 10 (binary)

We then combine the two 2-bit outputs from the S-boxes to get a 4-bit output:

S-box output: 0110

We apply the P4 permutation to get the final output of the first round:

P4: 2 4 3 1 S-box output after P4: 1001

We then XOR the result with the left half of the input:

Result of XOR: 1100

We swap the two halves of the result and repeat the process for the second round:

Left half: 1001 Right half: 1100

EP: 4 1 2 3 2 3 4 1 Right half after EP: 0110 0000

Round 2: Key: 0100 1001 Result of XOR: 0010 1001

S0: Row: 00 (binary) = 0 (decimal) Column: 100 (binary) = 4 (decimal) S0[0][4] = 11 (binary)

S1: Row: 101 (binary) = 5 (decimal) Column: 001 (binary) = 1 (decimal) S1[5][1] = 00 (binary)

S-box output: 1100

P4: 2 4 3 1 S-box output after P4: 0110

Result of XOR: 1011

Finally, we combine the left and right halves of the result and apply the inverse initial permutation IP-1:

Left half: 1011 Right half: 1001

IP-1: 4 1 3 5 7 2 8 6 Result after IP-1: 1100 0110

The final encrypted output is therefore CB in hexadecimal.

If K1= 13Hexa-Decimal and K2 = 24Hexa-decimal Then encrypt using SDES if Plaintext = 23Hexa-decimal convert all Hexadecimal numbers into Binary numbers

原文地址: https://www.cveoy.top/t/topic/bGHB 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录