48 #define MODULE_NAME "cc2538-aes-128" 52 #define PRINTF(...) printf(__VA_ARGS__) 68 restore_crypto(uint8_t enabled)
76 set_key(
const uint8_t *key)
78 uint8_t crypto_enabled, ret;
80 crypto_enabled = enable_crypto();
83 CC2538_AES_128_KEY_AREA);
84 if(ret != CRYPTO_SUCCESS) {
85 PRINTF(
"%s: aes_load_keys() error %u\n", MODULE_NAME, ret);
89 restore_crypto(crypto_enabled);
93 encrypt(uint8_t *plaintext_and_result)
95 uint8_t crypto_enabled, ret;
98 crypto_enabled = enable_crypto();
100 ret =
ecb_crypt_start(
true, CC2538_AES_128_KEY_AREA, plaintext_and_result,
101 plaintext_and_result, AES_128_BLOCK_SIZE, NULL);
102 if(ret != CRYPTO_SUCCESS) {
103 PRINTF(
"%s: ecb_crypt_start() error %u\n", MODULE_NAME, ret);
108 if(res != CRYPTO_SUCCESS) {
109 PRINTF(
"%s: ecb_crypt_check_status() error %d\n", MODULE_NAME, res);
113 restore_crypto(crypto_enabled);
uint8_t ecb_crypt_start(uint8_t encrypt, uint8_t key_area, const void *mdata_in, void *mdata_out, uint16_t mdata_len, struct process *process)
Starts an ECB crypto operation.
Header file for the cc2538 System Control driver.
#define AES_KEY_STORE_SIZE_KEY_SIZE_128
Key size: 128 bits.
Header file of the AES-128 driver for the CC2538 SoC.
Structure of AES drivers.
void(* encrypt)(uint8_t *plaintext_and_result)
Encrypts.
Header file for the cc2538 AES-ECB driver.
void crypto_enable(void)
Enables the AES/SHA cryptoprocessor.
int8_t ecb_crypt_check_status(void)
Checks the status of the ECB crypto operation.
#define CRYPTO_IS_ENABLED()
Indicates whether the AES/SHA cryptoprocessor is enabled.
void crypto_disable(void)
Disables the AES/SHA cryptoprocessor.
uint8_t aes_load_keys(const void *keys, uint8_t key_size, uint8_t count, uint8_t start_area)
Writes keys into the Key RAM.
void sys_ctrl_reset()
Generates a warm reset through the SYS_CTRL_PWRDBG register.
void(* set_key)(const uint8_t *key)
Sets the current key.