
The project implements a DES encryption block controlled via I2C (1-byte SMBus protocol).
Since the I2C module does not require a sampling clock, it was decided to clock DES module's from the SCL line. This works because, after writing the bit to start encryption, the actual reading of the result occurs only after at least 18 clock cycles (8 for the device address + 8 for the memory index + 2 N(ACK) bits). This is more than enough ticks for a complete encryption/decryption cycle.
The structure of the I2C module is largely inspired by the work of Daniel Beer[1]. DES was implemented according to the description provided in Bruce Schneier’s book[2]. The test vectors were found on the Stack Exchange[3].
Memory[0x00..0x07] = (R) Result
Memory[0x08..0x0F] = (RW) Input data
Memory[0x10..0x17] = (RW) Key
Memory[0x18][0] = (RW) Type of operation (0 - encryption; 1 - decryption)
Memory[0x18][1] = (RW) Encryption/decryption start signal
Memory[0x18][2] = (R) Ready flag
Memory[0x18][3..7] = (-) Reserved

Write 0x4E6F772069732074 as data (0x8..0xF), 0x0123456789ABCDEF as key (0x10..0x17). Then write 0x2 (encryption + enable) to control register (0x18). Check that result (0x0..0x7) is 0x3FA40E8A984D4815 and control register now holds 0x6 (encryption + enable + ready). Reset control register to 0x0. Then write 0x3FA40E8A984D4815 as data, use the same key and write 0x3 in control (decryption + enable). Check that result is 0x4E6F772069732074.
Any device that supports the I2C protocol can be used as a controller. During testing, a Raspberry Pi 4 was used.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | scl | sda | |
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 | |||
| 7 |