LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   What is the correct way Making a DES key respect Parity? (http://www.linuxquestions.org/questions/programming-9/what-is-the-correct-way-making-a-des-key-respect-parity-4175424234/)

Lsatenstein 08-27-2012 11:04 AM

What is the correct way Making a DES key respect Parity?
 
In the algorithms for DES, it is stipulated that the keys are 56 bits in length, from a string of 64 bits (8 bytes).

rule 1 has the high order bit (0x80)toggled to make the parity of the byte odd.
This rule would change byte bits 00000011 to 10000011 (0x03|0x80);

rule 2 says to toggle the left most bit following the previous 1.
Here is a visual example of what is meant.
bits 00000011 (the value 0x03). The rule would change this to
bits 00000111 (the value 0x07). (0x03|0x04).

The latter would be implemented with a 256 byte table. The former with a
16 byte table.


Are there other options? Of the two methods indicated above, what is the correct one?

sundialsvcs 08-28-2012 08:59 AM

Either of the two.

The second rule, if mutually agreeable, is a slightly better rune for quickly detecting transmission errors.

In most pragmatic implementations that I have lately seen, this technique isn't used. The 56-bit key is exchanged in a packet that includes a true CRC checksum of the key material. Even an 8-bit CRC applied to 56 bits of data is much more likely to detect a garbled key than a byte-wise parity check. But it's more complex for a hardware device to perform, and if the DES implementation is in a hardware chip, the rules of that chip must in any case be followed.

Lsatenstein 09-02-2012 02:17 AM

Thank you for you feedback.

The 3DES software I used actually uses a mapping of bits 1-7 of each byte, so it matters not if I use the 0x80 toggle. As for the rule 2, It is really changing the key value, and I cant see why I should do it too.

Best to just take the encryption key as the 3*8 bytes and let the algorithm sort it out.


All times are GMT -5. The time now is 03:51 PM.