
Handshake Solutions
HT80C51 User Manual
Peripheral Modules – Triple-DES Converter
Page 84 of 132
© Philips Electronics N.V. 2005
5.8.5.
Software view
For an encryption or decryption using the Triple-DES module, the following steps are neccesary:
•
store the key in the key register (or both keys for triple-DES)
•
write the text into the DES module
•
start the encryption or decryption
•
read the encrypted or decrypted text
These steps are described in further detail below.
5.8.5.1.
Storing a key into auxiliary register KEY
The key
B1B2B3B4B5B6B7B8
can be stored in key register KEY0 or KEY1 by writing the sequence
B8 B7 B6 B5 B4 B3 B2 B1
to SFR DKEY. Then the contents of DKEY can be copied into KEY0, by writing 00H to DCON, or it can be
copied to KEY1 by writing 01H to DCON.
5.8.5.2.
Writing a text into the triple-DES module
The text
3D9D3FA9FC8AD337
can be transferred to the DES module by writing the sequence
37 D3 8A FC A9 3F 9D 3D
to SFR DTXT.
Alternatively the reverse sequence
3D 9D 3F A9 FC 8A D3 37
can be written to DTXT followed by the command 03H to DCON, which reverses the order of the bytes.
5.8.5.3.
DES encryption or decryption
All encryptions or decryptions, be it single-DES or triple-DES, can be simply performed by writing the
apporopiate command into the SFR DCON. The single-DES encryption or decryption uses KEY0 only.
The triple-DES encryption and decryption use first KEY0, then KEY1 and finally KEY0.
5.8.5.4.
Reading the text result from register the triple-DES module
If the generated text result is
3D9D3FA9FC8AD337
reading from DTXT will deliver the sequence
37 D3 8A FC A9 3F 9D 3D
after which the internal register will again contain the original text result.
The text can also be read in the reverse order by first giving the reverse-text command.