ieee802154_security: adapt to Kconfig

This commit is contained in:
Fabian Hüßler 2021-05-31 10:33:07 +02:00
parent d09ca43a84
commit 93759a747b
2 changed files with 5 additions and 7 deletions

View File

@ -101,17 +101,14 @@ struct ieee802154_sec_dev {
void *ctx;
};
#if !defined(IEEE802154_SEC_DEFAULT_KEY) || defined(DOXYGEN)
#if !defined(CONFIG_IEEE802154_SEC_DEFAULT_KEY) || defined(DOXYGEN)
/**
* @brief AES key that is used in the test vectors from the specification
* @brief AES default key
*
* @note Predefine it yourself,
* if you want another key to be set up on initialization
*/
#define IEEE802154_SEC_DEFAULT_KEY { 0xc0, 0xc1, 0xc2, 0xc3, \
0xc4, 0xc5, 0xc6, 0xc7, \
0xc8, 0xc9, 0xca, 0xcb, \
0xcc, 0xcd, 0xce, 0xcf }
#define CONFIG_IEEE802154_SEC_DEFAULT_KEY "pizza_margherita"
#endif
/**

View File

@ -401,7 +401,8 @@ void ieee802154_sec_init(ieee802154_sec_context_t *ctx)
memset(ctx->key_source, 0, sizeof(ctx->key_source));
ctx->key_index = 0;
ctx->frame_counter = 0;
uint8_t key[] = IEEE802154_SEC_DEFAULT_KEY;
uint8_t key[] = CONFIG_IEEE802154_SEC_DEFAULT_KEY;
assert(sizeof(key) >= IEEE802154_SEC_KEY_LENGTH);
assert(CIPHER_MAX_CONTEXT_SIZE >= IEEE802154_SEC_KEY_LENGTH);
cipher_init(&ctx->cipher, CIPHER_AES, key, IEEE802154_SEC_KEY_LENGTH);
}