Validity checking function for key_flag API

Add masks for each key type to define which flags can be combined and
add a helper function to validate key_flag values.

Signed-off-by: Alexander Wetzel <alexander@wetzel-home.de>
This commit is contained in:
Alexander Wetzel 2020-03-04 18:16:51 +01:00 committed by Jouni Malinen
parent 5eb1632569
commit e9e69221c1

View file

@ -447,8 +447,23 @@ enum key_flag {
KEY_FLAG_DEFAULT,
KEY_FLAG_PAIRWISE_RX_TX = KEY_FLAG_PAIRWISE | KEY_FLAG_RX_TX,
KEY_FLAG_PAIRWISE_RX = KEY_FLAG_PAIRWISE | KEY_FLAG_RX,
/* Max allowed flags for each key type */
KEY_FLAG_PAIRWISE_MASK = KEY_FLAG_PAIRWISE_RX_TX,
KEY_FLAG_GROUP_MASK = KEY_FLAG_GROUP_RX_TX_DEFAULT,
KEY_FLAG_PMK_MASK = KEY_FLAG_PMK,
};
static inline int check_key_flag(enum key_flag key_flag)
{
return !!(!key_flag ||
((key_flag & KEY_FLAG_PAIRWISE) &&
(key_flag & ~KEY_FLAG_PAIRWISE_MASK)) ||
((key_flag & KEY_FLAG_GROUP) &&
(key_flag & ~KEY_FLAG_GROUP_MASK)) ||
((key_flag & KEY_FLAG_PMK) &&
(key_flag & ~KEY_FLAG_PMK_MASK)));
}
enum ptk0_rekey_handling {
PTK0_REKEY_ALLOW_ALWAYS,
PTK0_REKEY_ALLOW_LOCAL_OK,