47 #define MODULE_NAME "cc2538-aes-128"
51 #define PRINTF(...) printf(__VA_ARGS__)
67 restore_crypto(uint8_t enabled)
75 set_key(
const uint8_t *key)
77 uint8_t crypto_enabled, ret;
79 crypto_enabled = enable_crypto();
82 CC2538_AES_128_KEY_AREA);
83 if(ret != CRYPTO_SUCCESS) {
84 PRINTF(
"%s: aes_load_keys() error %u\n", MODULE_NAME, ret);
87 restore_crypto(crypto_enabled);
91 encrypt(uint8_t *plaintext_and_result)
93 uint8_t crypto_enabled, ret;
96 crypto_enabled = enable_crypto();
98 ret =
ecb_crypt_start(
true, CC2538_AES_128_KEY_AREA, plaintext_and_result,
99 plaintext_and_result, AES_128_BLOCK_SIZE,
NULL);
100 if(ret != CRYPTO_SUCCESS) {
101 PRINTF(
"%s: ecb_crypt_start() error %u\n", MODULE_NAME, ret);
102 restore_crypto(crypto_enabled);
107 if(res != CRYPTO_SUCCESS) {
108 PRINTF(
"%s: ecb_crypt_check_status() error %d\n", MODULE_NAME, res);
111 restore_crypto(crypto_enabled);
int8_t ecb_crypt_check_status(void)
Checks the status of the ECB crypto operation.
Header file of the AES-128 driver for the CC2538 SoC.
Header file for the cc2538 AES-ECB driver.
void(* set_key)(const uint8_t *key)
Sets the current key.
void crypto_enable(void)
Enables the AES/SHA cryptoprocessor.
Structure of AES drivers.
#define AES_KEY_STORE_SIZE_KEY_SIZE_128
Key size: 128 bits.
void(* encrypt)(uint8_t *plaintext_and_result)
Encrypts.
void crypto_disable(void)
Disables the AES/SHA cryptoprocessor.
#define NULL
The null pointer.
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.
#define CRYPTO_IS_ENABLED()
Indicates whether the AES/SHA cryptoprocessor is 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.