16.04.2020

S-des Key Generation Method

S-des Key Generation Method 7,5/10 8785 votes

To enhance the key connectivity, a novel key generation method based on system of equations is proposed. The proposed method utilizes the system of equations and its solutions to establish secret keys. Then, key management schemes can distribute these keys to nodes and efficiently protect the network. Aug 26, 2016 شرح كامل لطريقة و خطوات عمل المفتاح لشيفرة S-DES (Simplified Data Encryption Standard) بطريقة مبسطة مع حل مثال. Key Generation. Generate secret key using the selected algorithm (DES, 3DES, AES etc) generate secure random number of seed bytes which is computed with available the seed generation algorithm probably text message to be encrypted is not the multiples of 8 byte blocks that's why message must be padded with additional bytes to make the text message to be. SDES.java is an implementation of SDES. The constructor takes the key and initializes the key schedule. The constructor takes the key and initializes the key schedule. Methods are provided to encrypt and decrypt a byte, and a static method to print a byte in binary is also provided.

Basic but pure DES implementation in PythonI have written it for fun because nothing else.

How it works ?

The Data Encryption Standard (DES) is a symmetric-key block cipher published by the National Institute of Standards and Technology (NIST). DES is an implementation of a Feistel Cipher. It uses 16 round Feistel structure. The block size is 64-bit. Though, key length is 64-bit, DES has an effective key length of 56 bits.

Everything is made within a class called 'des'. This class can be instanciated once and used to cipher and decipher multiple datas.It also support padding using the PKCS5 specification. (So the data is padding even if it is multiple of 8 to be sure that the last byte il be padding data).The generation of all the keys used is made in the method generatekeys and substitute apply the SBOX permutation.The main method is run which is called by both encrypt and decrypt but in a different mode. This method do basically all the stuff, it loopthrought all the blocks and for each do the 16th rounds.

  1. The Data Encryption Standard (DES) is a symmetric-key block cipher published by the National Institute of Standards and Technology (NIST). DES is an implementation of a Feistel Cipher. It uses 16 round Feistel structure. The block size is 64-bit. Though, key length is 64-bit, DES has an effective key.
  2. Determine another row and column. For this second row, combine bits 5 and 8; for this second column, bits 6 and 7. Identify the entry in s-box S0 at the first row/first column you determined. S0 shows it in decimal; convert it to binary (two bits). Enter those bits as the first half of the 4-bit number at right.

Be careful: This module implement DES in ECB mode, so you can't make it weaker. I didn't made it to be strong but for fun.

How to use it ?

I have not done any interface to take argument in command line so this module can't be used as a script. (feel free to modify it).To use it from python shell or in another module do:

S-des Key Generation Method

Note: In this exemple no padding is specified so you have to provide a text which is multiple of 8 bytes. The key is cut to 8 bytes if longer.

To use padding:

S-DES ENCRYPTION SAMPLE

Key Generation Software

To the input (plaintext), apply initial permutation IP:

IP

2

6

3

1

4

8

5

7

In the next steps, we will develop 4 bits with which to replace the left half of this 'blue' result.

Input:
01101101
11100110
To right 4 bits of above result, apply expansion/permutation E/P (generating 8 bits from 4). The bit numbering is that of the 4-bit right-nibble, not of the 8-bit byte (e.g., indicated bit 2 refers to byte's bit 6).

E/P

41232341
00111100
Upon above result, perform binary XOR operation with
subkey K1:

K1

10100100
10011000
Determine a row and a column from above XOR result. For the row, combine bits 1 and 4 and convert to decimal. For the column, combine bits 2 and 3 and convert to decimal.

Determine another row and column. For this second row, combine bits 5 and 8; for this second column, bits 6 and 7.

Identify the entry in s-box S0 at the first row/first column you determined. S0 shows it in decimal; convert it to binary (two bits). Enter those bits as the first half of the 4-bit number at right. Identify the entry in s-box S1 at the second row/second column you determined. Convert it to binary; enter those two bits as the second half of the number at right.

S0 =

c0c1c2c3

r0

1032

r1

3210

r2

0213

r3

3132

S1 =

c0c1c2c3

r0

0123

r1

2013

r2

Generate

3010

r3

2103
left nibble:
bits 1 & 4 -> 11 -> 3
bits 2 & 3 -> 00 -> 0
therefore, get from S0 row 3 col 0
result is 3 -> 11

right nibble:
bits 1 & 4 -> 10 -> 2
bits 2 & 3 -> 00 -> 0
therefore, get from S1 row 2 col 0
result is 3 -> 11

1111
To above result, apply permutation P4:

P4

2431
1111
Upon the above P4 result, perform binary XOR operation, combining it with the left 4-bits of our first result (application of IP to original plaintext input, blue cell above).

We are trying to replace the left half of that first result. These XOR result bits are the replacement bits for it.

XOR with 1110

0001
Rewrite that 'blue' first result with its left half replaced. (Look it up, keep/copy its right half, use the preceding result as the new left half.)
00010110
Swap the two 4-bit halves of the above (previous) result.

In the next steps, we will again develop 4 replacement bits, and with them replace the left half of this 'green' swap result. The steps will be the same ones used for that purpose already.

01100001
To right 4 bits of above swap result, apply expansion/permutation E/P (generating 8 bits from 4):

E/P

41232341
10000010
Upon above result, perform binary XOR operation with
subkey K2:

K2

01000011
11000001
Determine a row and a column from above result. For the row, combine bits 1 and 4 and convert to decimal. For the column, combine bits 2 and 3 and convert to decimal.

Determine another row and column. For this second row, combine bits 5 and 8; for this second column, bits 6 and 7.

Identify the entry in s-box S0 at the first row/first column you determined. It's given in decimal; convert it to binary (two bits). Enter those bits as the first half of the 4-bit number at right. Identify the entry in s-box S1 at the second row/second column you determined. Convert it to binary; enter those two bits as the second half of the number at right.

S0 =

c0c1c2c3

r0

1032

r1

3210

r2

0213

r3

3132

S1 =

c0c1c2c3

r0

0123

r1

2013

r2

3010

r3

2103
left nibble:
bits 1 & 4 -> 10 -> 2
bits 2 & 3 -> 10 -> 2
therefore, get from S0 row 2 col 2
result is 1 -> 01

right nibble:
bits 1 & 4 -> 01 -> 1
bits 2 & 3 -> 00 -> 0
therefore, get from S1 row 1 col 0
result is 2 -> 10

0110
To above result, apply permutation P4:

P4

2431
1010
Upon the above P4 result, perform binary XOR operation, combining it with the left 4-bits of the earlier swap result (green cell above).

We are trying to replace the left half of that swap result. These XOR result bits are the replacement bits for it.

XOR with 0110

1100
Rewrite that 'green' swap result with its left half replaced. (Look it up, keep/copy its right half, use the preceding result as the new left half.)
11000001

To above result, apply reverse of initial permutation IP, which is IP-1:

IP-1

4 1 3 5 7 2 8 6

This result is ciphertext. It is the S-DES encryption of the plaintext input.

01000110

S-des Key Generation Method Download