How to generate keys from a 56 bit using DES

First I just want to apologize for my lack of knowledge in this system.

The professor kind of gave us an exercise to solve before even going through the lessons. I tired to look at videos online but what I only know how to use a 64 bit initial key.

initial 56-bit hexadecimal key: 'B092EBA02E3798' Give the key K16 (on the last turn) to 64 bits in hexadecimal.

So my question is, do I have to turn my 56 bit to a 64 bit before doing an initial permutation. And if yes how can I do that. Thank you for your help.

• Welcome to Cryptography.SE. Wikipedia is the first step!. We have some Q/A for this, however, see on Wiki:DES The key ostensibly consists of 64 bits; however, only 56 of these are actually used by the algorithm. Eight bits are used solely for checking parity, and are thereafter discarded. Hence the effective key length is 56 bits. Commented Jun 19, 2021 at 22:00
• Does this answer your question? DES parity bits Commented Jun 20, 2021 at 12:31

The DES key is defined as 64 bits. 56 of them are the actual key and 8 are parity bits. This allows it to fit in 8 bytes.

K16 presumably referes to the last sub key, per the key schedule. Each DES sub key is 48 bits long.

Encoding a 56 bit key in 64 bits is done by adding a parity bit to each 7 bit byte. However I'm aware of no standard way of representing a 48 bit sub key as 64 bits.

• Thank you a lot for your help. I guess I'm just gonna try to solve the exercise with a 48 bit key. Commented Jun 20, 2021 at 11:52

There might not be enough information about where in the algorithm your 56 bit key is found.

If the 56 bit value B092EBA02E3798 represents the CD block following PC1 the keytab -s table shows selected key K16 is the result of applying PC2 to the CD block:

  Bit  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
KS
1  15 18 12 25  2  6  4  1 16  7 22 11 24 20 13  5 27  9 17  8 28 21 14  3
2  16 19 13 26  3  7  5  2 17  8 23 12 25 21 14  6 28 10 18  9  1 22 15  4
3  18 21 15 28  5  9  7  4 19 10 25 14 27 23 16  8  2 12 20 11  3 24 17  6
4  20 23 17  2  7 11  9  6 21 12 27 16  1 25 18 10  4 14 22 13  5 26 19  8
5  22 25 19  4  9 13 11  8 23 14  1 18  3 27 20 12  6 16 24 15  7 28 21 10
6  24 27 21  6 11 15 13 10 25 16  3 20  5  1 22 14  8 18 26 17  9  2 23 12
7  26  1 23  8 13 17 15 12 27 18  5 22  7  3 24 16 10 20 28 19 11  4 25 14
8  28  3 25 10 15 19 17 14  1 20  7 24  9  5 26 18 12 22  2 21 13  6 27 16
9   1  4 26 11 16 20 18 15  2 21  8 25 10  6 27 19 13 23  3 22 14  7 28 17
10   3  6 28 13 18 22 20 17  4 23 10 27 12  8  1 21 15 25  5 24 16  9  2 19
11   5  8  2 15 20 24 22 19  6 25 12  1 14 10  3 23 17 27  7 26 18 11  4 21
12   7 10  4 17 22 26 24 21  8 27 14  3 16 12  5 25 19  1  9 28 20 13  6 23
13   9 12  6 19 24 28 26 23 10  1 16  5 18 14  7 27 21  3 11  2 22 15  8 25
14  11 14  8 21 26  2 28 25 12  3 18  7 20 16  9  1 23  5 13  4 24 17 10 27
15  13 16 10 23 28  4  2 27 14  5 20  9 22 18 11  3 25  7 15  6 26 19 12  1
16  14 17 11 24  1  5  3 28 15  6 21 10 23 19 12  4 26  8 16  7 27 20 13  2

Bit 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
KS
1  42 53 32 38 48 56 31 41 52 46 34 49 45 50 40 29 35 54 47 43 51 37 30 33
2  43 54 33 39 49 29 32 42 53 47 35 50 46 51 41 30 36 55 48 44 52 38 31 34
3  45 56 35 41 51 31 34 44 55 49 37 52 48 53 43 32 38 29 50 46 54 40 33 36
4  47 30 37 43 53 33 36 46 29 51 39 54 50 55 45 34 40 31 52 48 56 42 35 38
5  49 32 39 45 55 35 38 48 31 53 41 56 52 29 47 36 42 33 54 50 30 44 37 40
6  51 34 41 47 29 37 40 50 33 55 43 30 54 31 49 38 44 35 56 52 32 46 39 42
7  53 36 43 49 31 39 42 52 35 29 45 32 56 33 51 40 46 37 30 54 34 48 41 44
8  55 38 45 51 33 41 44 54 37 31 47 34 30 35 53 42 48 39 32 56 36 50 43 46
9  56 39 46 52 34 42 45 55 38 32 48 35 31 36 54 43 49 40 33 29 37 51 44 47
10  30 41 48 54 36 44 47 29 40 34 50 37 33 38 56 45 51 42 35 31 39 53 46 49
11  32 43 50 56 38 46 49 31 42 36 52 39 35 40 30 47 53 44 37 33 41 55 48 51
12  34 45 52 30 40 48 51 33 44 38 54 41 37 42 32 49 55 46 39 35 43 29 50 53
13  36 47 54 32 42 50 53 35 46 40 56 43 39 44 34 51 29 48 41 37 45 31 52 55
14  38 49 56 34 44 52 55 37 48 42 30 45 41 46 36 53 31 50 43 39 47 33 54 29
15  40 51 30 36 46 54 29 39 50 44 32 47 43 48 38 55 33 52 45 41 49 35 56 31
16  41 52 31 37 47 55 30 40 51 45 33 48 44 49 39 56 34 53 46 42 50 36 29 32



where bits 1 to 24 are derived from the C register and bits 25 to 56 are derived from the D register.

A C Register value of B092EBA expanded out is

Bit  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
Val  1  0  1  1  0  0  0  0  1  0  0  1  0  0  1  0  1  1  1  0  1  0  1  1  1  0  1  0


Applying Permuted Choice 2 to the C Register gives:

PC2 14 17 11 24  1  5  3 28 15  6 21 10 23 19 12  4 26  8 16  7 27 20 13  2
0  1  0  1  1  0  1  0  1  0  1  0  1  0  1  1  0  0  0  0  1  0  0  0


or 5AA5B08.

A D Register value of 02E3798 expanded out is

Bit 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
Val  0  0  0  0  0  0  1  0  1  1  1  0  0  0  1  1  0  1  1  1  1  0  0  1  1  0  0  0


Applying Permuted Choice 2 to the D Register gives:

PC2 41 52 31 37 47 55 30 40 51 45 33 48 44 49 39 56 34 53 46 42 50 36 29 32
0  1  0  1  1  0  0  0  0  0  0  1  1  1  1  0  0  1  1  0  0  0  0  0


or 581E60.

That gives a selected Key value of 5AA5B08581E60 which is a 48 bit value. The key inputs to f(R,K) for the first 4 S boxes come from C while the last 4 come from D.

If on the other hand the 56 bit value B092EBA02E3798 represents bits 1 (MS) to 7 of 8(LS) of eight successive 8 bit bytes of input to PC1 that would expand out to a 64 bit value where the additional bits are used for parity but ignored here and set to zero:

                     P
1  0  1  1  0  0  0  0
0  1  0  0  1  0  0  0
1  0  1  1  1  0  1  0
0  1  1  1  0  1  0  0
0  0  0  0  0  0  1  0
0  1  1  1  0  0  0  0
1  1  0  1  1  1  1  0
0  0  1  1  0  0  0  0


or B048BA740270BE30.

This value can be entered into a copy of Eugene Steyer's Javascript DES Example which can be edited to allow input of arbitrary keys and data and produces:

KS[16]:  011100 001110 010011 001011 100000 101000 000111 101001


which would be 70E4CB8281E9, a 48 bit value.

Without seeing the context of your assignment I'd suspect if the second method shown here were intended you'd be required to show your work, which would imply demonstrating PC1 and PC2 as well as mention of the key schedule demonstrating selected key 16 is PC2 applied to the CD block.

It helps to understand the Digital Encryption Standard is an interoperability standard referencing the hardware implementation found in IBM's two DES patents using a big-endian bit ordering from 1 and having an 8 bit interface to a host.

The relationship between the input key bytes, PC1, PC2 and CD block are shown in this answer to another question.

For ex. this is your 64 bit $${key = AABB09182736CCDD}$$ you can convert to binary and then just arrange bits shown in keyp array and you will get new 56 bit key. new key as bitarray concatenated (bit5+bit49+bit41....+bit4), rest all bits are dropped. for Below array count starts from 0

• getting 56 bit key from 64 bit using the parity bits key = permute(key, keyp, 56)
• now after first permute PC1 above shown by Meir, the 56 bit key is '0xc3c033a33f0cfa'
• If I understand your question correctly, you need to find 64 bit key from the 56 bits key, as Meir mentioned it is not feasible. you can use this 56 bit key after initial permutation and generate 16 48bit subkeys and use them in the reverse order while decryption. Please look for Feistel Cipher, as DES is based on it.
• Thank you a lot, I will be looking into more details on the Fiestel Clipher, thank you. Commented Jun 20, 2021 at 13:33