SLAA547C July 2013 – July 2021 MSP430FR5739
The following code example shows a full encryption then decryption process on a single block of data. The key scheduler is set to populate both key schedules. The results of the operations are stored in the original data array.
#include "msp430xxxx.h"
#include "TI_DES.h"
int main( void )
{
des_ctx dc1; // Key schedule structure
unsigned char *cp;
unsigned char data[] = {0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0xd4, 0x30};
unsigned char key[8] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xfe};
cp = data;
Des_Key(&dc1, key, ENDE); // Sets up key schedule for Encryption and
Decryption
Des_Enc(&dc, cp, 1); //Encrypt Data, Result is stored back into Data
Des_Dec(&dc, cp, 1); //Decrypt Data, Result is stored back into Data
return 0;
}