What are the separate single DES keys from a triple DES key?

Suppose my 192 bit triple DES key (in hex) is

0123456789ABCDEFFEDCBA987654321089ABCDEF01234567

What are the keys for the separate single DES operations? In this case the 168 bits triple DES key includes the parity bits to make the key size ($$64 \times 3 = 192$$ bits).

• Welcome to Cryptography. Have you ever consider to divide it into 3 equal pieces? Or check an implementation? – kelalaka May 12 at 9:45
• I tried that but am not sure whether it is the correct approach. Wanted someone to confirm it. Could not find much about it anyplace else. – user69127 May 12 at 9:47
• Wikipedia lists triple-DES as having a key size up to 168-bits. Where do you get 192-bits from? – Nat May 12 at 9:55
• By subkeys I mean the three keys . The 168 bits one is excluding the parity bits which have been included in this case to make the key size(64X3=192bits). – user69127 May 12 at 10:06
• Note that sub keys are commonly the expanded keys used within a block cipher such as DES for the separate rounds, created through key expansion within the key schedule. Hence the questions / confusion about sub keys. I've therefore removed the term from the question. – Maarten Bodewes May 12 at 17:31

The single DES keys are commonly just split in three keys, where the first key is used for the first encryption of the message block itself, the second one for the decryption of the previous result and the third one for encryption of the decryption result.

So basically you'd have: $$\newcommand{Enc}{\operatorname{Enc}}\newcommand{Dec}{\operatorname{Dec}}$$

$$\Enc'_{(k_1, k_2, k_3)} \equiv \Enc_{k_3}(\Dec_{k_2}(\Enc_{k_1}(m)))$$

and of course

$$\Dec'_{(k_1, k_2, k_3)} \equiv \Dec_{k_1}(\Enc_{k_2}(\Dec_{k_3}(m)))$$

where $$\Enc'$$ and $$\Dec'$$ are the encryption and decryption operations of TDEA, commonly called triple DES or DES EDE after the order of encryption / decryption. Note that of course the inner functions are performed first, i.e. the functions are executed from right to left.

In pseudo code the encryption function:

c1 = DES_encrypt(k1, m)
c2 = DES_decrypt(k2, c1)
c3 = DES_encrypt(k3, c2)
c = c3;

The keys are defined as separate keys, but most - if not all - libraries simply take the concatenation $$k = k_1 \| k_2 \| k_3$$ as key input.

So in your case your keys would be k1 = 0123456789ABCDEF, k2 = FEDCBA9876543210 and k3 = 89ABCDEF01234567 (which have the parity bits correctly set).

Most if not all libraries only accept the keys including parity bits. Most libraries do not check the validity of the parity bit, but there may be some that do. The bits commonly do need to be present though; a single DES key can usually not be represented by just 7 bytes.

Note that the least significant bit of a byte is the parity bit over that byte, which should be odd number of set (or indeed unset) bits in the byte. So both 00 and 01 would be equivalent byte values within the key, with 01 having correct parity. This means that each triple DES key with correct parity has $$2 ^ {192 / 8} - 1 = 2^{24} - 1 = 16,777,215$$ fully equivalent keys.

Sometimes key generators do act on the effective key size excluding parity bits, so you'd have a function such as $$k = \operatorname{Gen}(168)$$ to create a triple DES key rather than $$k = \operatorname{Gen}(192)$$, even though the output is 192 bits / 24 bytes in size.

For 2-key triple DES keys you'd have $$k_3 = k_1$$, so the key would be $$k = k_1 \| k_2$$ to get:

$$\Enc'_{(k_1, k_2)} \equiv \Enc_{k_1}(\Dec_{k_2}(\Enc_{k_1}(m)))$$

and to simulate single DES where only triple DES is available:

$$\Enc'_{k} \equiv \Enc_{k}(\Dec_{k}(\Enc_{k}(m)))$$

I'll spare you the decryption functions and pseudo code.

Neither 2 key triple DES or single DES is considered secure anymore, while triple DES still offers some security.

Sometimes the keys are lettered instead of numbered, in that case $$k_A = k_1$$, $$k_B = k_2$$ and $$k_C = k_3$$. So the concatenation of three keys is sometimes also called an ABC key, and the concatenation of two keys an ABA key.

If you don't want to deal with all this "complexity" then use AES instead, which has much better properties and speed compared to triple DES. A fast stream cipher such as ChaCha20 could also be considered.