I read about 3DES encryption but I don't understand exactly what the specific meaning of key size is. For example I found that 3DES supports 64, 128, 192, and 256 bits key size. What are all the possible key sizes supported by 3DES? Is there any function to determine if a key is valid for 3DES or not ?
1 Answer
The triple DES (3DES) block cipher works by essentially running the block through DES three times. Triple DES is also known as "DES EDE" (encrypt-decrypt-encrypt) and under the name given by the standard document: "TDEA". The TDEA algorithm is described in FIPS NIST Special Publication 800-67 Revision 1 where paragraph 3.2 describes the TDEA Keying Options.
In triple DES you take the block and then:
- Send it through DES once with a DES key $k_1$
- Send the result of that through DES a second time with a DES key $k_2$ (for this second time we generally run DES backwards; in decrypt rather than encrypt mode, however, that's not important for this question)
- Send the result of that through DES a third time with DES key $k_3$.
The result of that is the result of the 3DES block operation.
Now, 3DES comes in two main flavors:
The "2 key" version; in this version, the 3DES key consists of two DES keys; $k_1$ and $k_2$, and we implicitly assume that $k_1 = k_3$. DES keys are typically represented in 64 bits, and so this version of 3DES has 128 bit keys.
The "3 key" version; in this version, the 3DES key consists of three DES keys; $k_1$, $k_2$ and $k_3$. Because all three 3 DES keys are explicitly represented, this version of 3DES has 192 bit keys.
The keys are sometimes also referred to as key A, B and C. The key for the 2 key version is then referred to as an ABA key and for the 3 key version as ABC key.
Those are the only standard versions of 3DES; you might have an API which allows 64 bit keys (which likely emulates DES in that case); if it allows 256 bit keys, I have no idea what it would do with them.
In case you're wondering whether DES keys are 56 bits or 64 bits, well, they are considered 56 bits of cryptographic strength (because we can run through all possible DES encryption operations by trying $2^{56}$ different values); however when we represent a key, we typically express it as 8 bytes (or 64 bits). In that case we essentially ignore the least significant bit of each byte (originally, they were "parity bits" for each byte, however since no one manually enters DES keys anymore, most implementations end up ignoring them instead). That's the way the DES designers did things; most everyone follows tradition.
So sometimes the (triple) DES key lengths are referred to as 56 bit, 112 bit or 168 bits instead of 64, 128 or 192 bits respectively. Usually cryptographic API's still require you to enter 8, 16 or 24 bytes despite of this. AES fortunately does away with all this.
-
$\begingroup$ If I remember correctly the idea that 3DES would emulate DES when used with a single 64 bit key for key 1, 2 and 3 (or key A, B and C if I remember the specs correctly) was meant as specific property of 3DES as you could use the same circuitry to accomplish both. $\endgroup$– Maarten Bodewes ♦Commented Mar 27, 2015 at 12:58
-
$\begingroup$ @MaartenBodewes: that is the reason for EDE mode (actually, it's a bit more complicated); however personally I don't consider the $k_1 = k_2 = k_3$ case as 3DES; instead, that's DES (which just happens to be implemented by circuitry that can implement 3DES as well) $\endgroup$– ponchoCommented Mar 27, 2015 at 13:34
-
1$\begingroup$ I guess I can agree on that. The keys should be indistinguishable from random for ciphers, so as long as that pre-condition is taken into account DES AAA is not triple DES. To be completely fair a check should be really present to check that situation though, otherwise the name of the algorithm would depend on the input, which is kind of weird. Or we could just stop using the frickin' 3DES algorithm of course ;) $\endgroup$– Maarten Bodewes ♦Commented Mar 27, 2015 at 13:42