43#define LOG_MODULE "cc26xx-aes"
44#define LOG_LEVEL LOG_LEVEL_MAIN
46static uint32_t skey[AES_128_KEY_LENGTH /
sizeof(uint32_t)];
52 memcpy(skey, key, AES_128_KEY_LENGTH);
56encrypt_decrypt(uint8_t *plaintext_and_result,
bool do_encrypt)
58 uint32_t result[AES_128_BLOCK_SIZE /
sizeof(uint32_t)];
63 ti_lib_prcm_power_domain_on(PRCM_DOMAIN_PERIPH);
64 while((ti_lib_prcm_power_domain_status(PRCM_DOMAIN_PERIPH)
65 != PRCM_DOMAIN_POWER_ON));
68 ti_lib_prcm_peripheral_run_enable(PRCM_PERIPH_CRYPTO);
69 ti_lib_prcm_load_set();
70 while(!ti_lib_prcm_load_get());
72 status = ti_lib_crypto_aes_load_key(skey, CRYPTO_KEY_AREA_0);
73 if(status != AES_SUCCESS) {
74 LOG_WARN(
"load key failed: %u\n", status);
77 status = ti_lib_crypto_aes_ecb((uint32_t *)plaintext_and_result, result, CRYPTO_KEY_AREA_0, do_encrypt,
false);
78 if(status != AES_SUCCESS) {
79 LOG_WARN(
"ecb failed: %u\n", status);
82 for(i = 0; i < 100; ++i) {
84 status = ti_lib_crypto_aes_ecb_status();
85 if(status != AES_DMA_BSY) {
90 ti_lib_crypto_aes_ecb_finish();
92 if(status != AES_SUCCESS) {
93 LOG_WARN(
"ecb get result failed: %u\n", status);
98 ti_lib_prcm_peripheral_run_disable(PRCM_PERIPH_CRYPTO);
99 ti_lib_prcm_load_set();
100 while(!ti_lib_prcm_load_get());
102 if(status == AES_SUCCESS) {
103 memcpy(plaintext_and_result, result, AES_128_BLOCK_SIZE);
106 plaintext_and_result[0] ^= 1;
113 encrypt_decrypt(plaintext_and_result,
true);
119 encrypt_decrypt(cyphertext_and_result,
false);
Header file of the AES-128 driver for the CC26xx SoC.
void cc26xx_aes_decrypt(uint8_t *cyphertext_and_result)
Decrypt a message using the SoC AES-128 hardware implementation.
void cc26xx_aes_set_key(const uint8_t *key)
Set a key to use in subsequent encryption & decryption operations.
void cc26xx_aes_encrypt(uint8_t *plaintext_and_result)
Encrypt a message using the SoC AES-128 hardware implementation.
Header file for the logging system.
Structure of AES drivers.
Header file with macros which rename TI CC26xxware functions.