Microchip® Advanced Software Framework

des_example.c File Reference

AVR XMEGA Data Encryption Standard (DES) driver.

Copyright (c) 2010-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>

Macros

#define DES_BLOCK_COUNT   3
 AES data block count. More...
 
Unit test configuration
#define DES_BLOCK_LENGTH   8
 AES data, key block length. More...
 

Functions

int main (void)
 Main example doing DES encryption/decryption. More...
 

Variables

uint8_t block_ans [DES_BLOCK_LENGTH *DES_BLOCK_COUNT]
 Variable used to store decrypted plaintext from DES Cipher Block Chaining. More...
 
uint8_t cipher_block_ans [DES_BLOCK_LENGTH *DES_BLOCK_COUNT]
 Variable used to store ciphertext from DES Cipher Block Chaining. More...
 
uint8_t data [DES_BLOCK_LENGTH]
 Plaintext block used by DES and 3DES. More...
 
uint8_t data_block [DES_BLOCK_LENGTH *DES_BLOCK_COUNT]
 Plain text used during DES Cipher Block Chaining. More...
 
uint8_t init [DES_BLOCK_LENGTH]
 Initial vector used during DES Cipher Block Chaining. More...
 
uint8_t keys [DES_BLOCK_LENGTH *DES_BLOCK_COUNT]
 Keys used by all DES operations. More...
 
uint8_t single_ans [DES_BLOCK_LENGTH]
 Variable used to store DES and tripleDES results. More...
 

#define DES_BLOCK_COUNT   3

AES data block count.

Referenced by main().

uint8_t block_ans[DES_BLOCK_LENGTH *DES_BLOCK_COUNT]

Variable used to store decrypted plaintext from DES Cipher Block Chaining.

Note
It is not possible to use the same variable to store the plaintext after a Cipher Block Chaining operation, as the previous cipher block is used to decode the current data block.

Referenced by main().

uint8_t cipher_block_ans[DES_BLOCK_LENGTH *DES_BLOCK_COUNT]

Variable used to store ciphertext from DES Cipher Block Chaining.

uint8_t data[DES_BLOCK_LENGTH]
Initial value:
= {
0xAB, 0xBA, 0x00, 0xBE, 0xEF, 0x00, 0xDE, 0xAD}

Plaintext block used by DES and 3DES.

Note
The MSB in the block is byte 0, and LSB is byte 7.
uint8_t data_block[DES_BLOCK_LENGTH *DES_BLOCK_COUNT]
Initial value:
= {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00,
0xAB, 0xBA, 0x00, 0x00, 0xDE, 0xAD, 0x00, 0x00}

Plain text used during DES Cipher Block Chaining.

uint8_t init[DES_BLOCK_LENGTH]
Initial value:
= {
0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}

Initial vector used during DES Cipher Block Chaining.

Initial value:
= {
0x94, 0x74, 0xB8, 0xE8, 0xC7, 0x3B, 0xCA, 0x7D,
0x28, 0x34, 0x76, 0xAB, 0x38, 0xCF, 0x37, 0xC2,
0xFE, 0x98, 0x6C, 0x38, 0x23, 0xFC, 0x2D, 0x23}

Keys used by all DES operations.

(single DES only uses the first 64-bit key).

Note
The MSB of the 3 keys is byte 0,8 and 16. The LSB of each key is byte 7, 15 and 23.

Referenced by main(), run_3des_cbc_decryption_test(), run_3des_cbc_encryption_test(), run_3des_decryption(), run_3des_encryption(), run_3des_encryption_and_decryption_test(), run_des_cbc_decryption_test(), run_des_cbc_encryption_test(), run_des_decryption(), run_des_encryption(), and run_des_encryption_and_decryption_test().

uint8_t single_ans[DES_BLOCK_LENGTH]

Variable used to store DES and tripleDES results.