According to the DES specification, the last bit of each byte of the secret key is used to detect errors (each byte must have odd parity). Therefore, the effective key length is 56 bits, not 64 bits.
However, in many use cases, these parity bits are not checked. Sometimes they are even used for a completely different purpose: Mifare DESFire cards store the key version in these bits, for example, even if the original goal of error correction is lost.
How does the implementation of Java cards handle these bits? Let's look at this code:
DESKey desKey = ...
byte[] inputKey = new byte[8];
inputKey[7] = (byte) 0x03;
desKey.setKey(inputKey, (short) 0);
byte[] outputKey = new byte[8];
desKey.getKey(outputKey, (short) 0);
It is guaranteed that the massifs inputKeyand outputKeywill contain the same data at the end, even with an invalid parity bits in inputKey? I have done several experiments with several types of cards, and all of them store any data that I put in these parity bits, but I did not find mention in the Java Card specification that this behavior is guaranteed.
This information is very important to me; otherwise, I would have to store my "invalid parity bits" separated from the key instance.
source
share