From e31daf1583cc266cabbf557fe1dc778fcfbafbef Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Fri, 29 Jan 2021 16:45:35 +0100 Subject: [PATCH] net/ieee802154: remove dependency of radio HAL in security --- sys/include/net/ieee802154/radio.h | 100 -------------------------- sys/include/net/ieee802154_security.h | 4 -- 2 files changed, 104 deletions(-) diff --git a/sys/include/net/ieee802154/radio.h b/sys/include/net/ieee802154/radio.h index 721703e871..5304ae5597 100644 --- a/sys/include/net/ieee802154/radio.h +++ b/sys/include/net/ieee802154/radio.h @@ -732,64 +732,6 @@ struct ieee802154_radio_ops { int (*set_rx_mode)(ieee802154_dev_t *dev, ieee802154_rx_mode_t mode); }; -/** - * @brief Forward declaration of the radio cipher ops structure - */ -typedef struct ieee802154_radio_cipher_ops ieee802154_radio_cipher_ops_t; - -/** - * @brief Forward declaration of the IEEE802.15.4 security device descriptor - */ -typedef struct ieee802154_sec_dev ieee802154_sec_dev_t; - -/** - * @brief IEEE802.15.4 security device descriptor - */ -struct ieee802154_sec_dev { - /** - * @brief Pointer to the operations of the device - */ - const struct ieee802154_radio_cipher_ops *cipher_ops; - /** - * @brief pointer to the context of the device - */ - void *ctx; -}; - -struct ieee802154_radio_cipher_ops { - /** - * @brief Function to set the encryption key for the - * next cipher operation - * - * @param[in] dev Security device descriptor - * @param[in] key Key to be used for the next cipher operation - * @param[in] key_size key size in bytes - */ - void (*set_key)(ieee802154_sec_dev_t *dev, - const uint8_t *key, uint8_t key_size); - /** - * @brief Function to perform ECB encryption - * - * @param[in] dev Security device descriptor - * @param[out] cipher Output cipher blocks - * @param[in] plain Input plain blocks - * @param[in] nblocks Number of blocks - */ - void (*ecb)(const ieee802154_sec_dev_t *dev, uint8_t *cipher, - const uint8_t *plain, uint8_t nblocks); - /** - * @brief Function to compute CBC-MAC - * - * @param[in] dev Security device descriptor - * @param[in] cipher Output cipher blocks - * @param[in, out] iv in: IV; out: computed MIC - * @param[in] plain Input plain blocks - * @param[in] nblocks Number of blocks - */ - void (*cbc)(const ieee802154_sec_dev_t *dev, uint8_t *cipher, - uint8_t *iv, const uint8_t *plain, uint8_t nblocks); -}; - /** * @brief Shortcut to @ref ieee802154_radio_ops::write * @@ -1229,48 +1171,6 @@ static inline int ieee802154_radio_set_rx_mode(ieee802154_dev_t *dev, return dev->driver->set_rx_mode(dev, mode); } -/** - * @brief Shortcut to ieee802154_sec_dev_t::ieee802154_radio_cipher_ops_t::set_key - * - * @param[in] dev IEEE802.15.4 security device descriptor - * @param[in] key Encryption key - * @param[in] key_size Size of the key in bytes - */ -static inline void ieee802154_radio_cipher_set_key(ieee802154_sec_dev_t *dev, - const uint8_t *key, uint8_t key_size) -{ - dev->cipher_ops->set_key(dev->ctx, key, key_size); -} - -/** - * @brief Shortcut to ieee802154_sec_dev_t::ieee802154_radio_cipher_ops_t::ecb - * - * @param[in] dev IEEE802.15.4 security device descriptor - * @param[out] cipher Output cipher blocks - * @param[in] plain Input plain blocks - * @param[in] nblocks Number of blocks - */ -static inline void ieee802154_radio_cipher_ecb(const ieee802154_sec_dev_t *dev, uint8_t *cipher, - const uint8_t *plain, uint8_t nblocks) -{ - dev->cipher_ops->ecb(dev->ctx, cipher, plain, nblocks); -} - -/** - * @brief Shortcut to ieee802154_sec_dev_t::ieee802154_radio_cipher_ops_t::cbc - * - * @param[in] dev IEEE802.15.4 security device descriptor - * @param[out] cipher Output cipher blocks - * @param[in] iv Initial vector to be XOR´ed to the first plain block - * @param[in] plain Input plain blocks - * @param[in] nblocks Number of blocks - */ -static inline void ieee802154_radio_cipher_cbc(const ieee802154_sec_dev_t *dev, uint8_t *cipher, - uint8_t *iv, const uint8_t *plain, uint8_t nblocks) -{ - dev->cipher_ops->cbc(dev->ctx, cipher, iv, plain, nblocks); -} - #ifdef __cplusplus } #endif diff --git a/sys/include/net/ieee802154_security.h b/sys/include/net/ieee802154_security.h index 777ce2dcc8..09c2094694 100644 --- a/sys/include/net/ieee802154_security.h +++ b/sys/include/net/ieee802154_security.h @@ -33,9 +33,6 @@ extern "C" { #endif -#if IS_USED(MODULE_IEEE802154_RADIO_HAL) -#include "net/ieee802154/radio.h" -#else /** * @brief Forward declaration of an IEEE802.15.4 abstract security device */ @@ -97,7 +94,6 @@ struct ieee802154_sec_dev { */ void *ctx; }; -#endif #if !defined(IEEE802154_DEFAULT_KEY) || defined(DOXYGEN) /**