From a3b4e8101d6ad369e599833319a1ea565436a846 Mon Sep 17 00:00:00 2001 From: kkrentz Date: Wed, 12 Nov 2014 11:09:13 -0800 Subject: [PATCH] llsec: Fixed MIC length; reject unsupported security levels --- core/net/llsec/llsec802154.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/net/llsec/llsec802154.h b/core/net/llsec/llsec802154.h index b8eb93121..5d81d9cb4 100644 --- a/core/net/llsec/llsec802154.h +++ b/core/net/llsec/llsec802154.h @@ -62,7 +62,16 @@ #define LLSEC802154_SECURITY_LEVEL FRAME802154_SECURITY_LEVEL_NONE #endif /* LLSEC802154_CONF_SECURITY_LEVEL */ -#define LLSEC802154_MIC_LENGTH ((LLSEC802154_SECURITY_LEVEL & 3) * 4) +#if ((LLSEC802154_SECURITY_LEVEL < 0) || (LLSEC802154_SECURITY_LEVEL > 7)) +#error "unsupported security level" +#endif + +#define LLSEC802154_SECURITY_LEVEL_MIC (LLSEC802154_SECURITY_LEVEL & 3) +#if LLSEC802154_SECURITY_LEVEL_MIC +#define LLSEC802154_MIC_LENGTH (2 << LLSEC802154_SECURITY_LEVEL_MIC) +#else +#define LLSEC802154_MIC_LENGTH 0 +#endif #ifdef LLSEC802154_CONF_USES_ENCRYPTION #define LLSEC802154_USES_ENCRYPTION LLSEC802154_CONF_USES_ENCRYPTION