This is the quick start guide for the SAM4C/4E/V71/V70/S70/E70 Advanced Encryption Standard (AES) Driver, with step-by-step instructions on how to configure and use the driver for a specific use case.
The code examples can be copied into any function that needs to control the AES module, such as the main application loop, for example.
This use case will demonstrate how to initialize the AES module to perform encryption or decryption of data.
This module requires the following service:
Add this to the main loop or a setup function:
struct aes_config g_aes_cfg; aes_get_config_defaults(&g_aes_cfg); aes_init(AES, &g_aes_cfg); aes_enable();
aes_enable();
aes_set_callback(AES, AES_INTERRUPT_DATA_READY, aes_callback, 1);
g_aes_cfg.encrypt_mode = AES_ENCRYPTION; g_aes_cfg.key_size = AES_KEY_SIZE_128; g_aes_cfg.start_mode = AES_AUTO_MODE; g_aes_cfg.opmode = AES_ECB_MODE; g_aes_cfg.cfb_size = AES_CFB_SIZE_128; g_aes_cfg.lod = false; aes_set_config(AES, &g_aes_cfg);
Plain text can be encrypted by:
aes_write_key(AES, key128); aes_write_input_data(AES, ref_plain_text);
The cipher text can be retrieved after it's been encrypted by:
aes_read_output_data(AES, output_data);