cfg80211: use key size constants
Instead of hardcoding the key length for validation, use the constants Zhu Yi recently added and add one for AES_CMAC too. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
362a415dce
commit
8fc0fee092
2 changed files with 6 additions and 6 deletions
|
@ -1092,6 +1092,7 @@ enum ieee80211_key_len {
|
||||||
WLAN_KEY_LEN_WEP104 = 13,
|
WLAN_KEY_LEN_WEP104 = 13,
|
||||||
WLAN_KEY_LEN_CCMP = 16,
|
WLAN_KEY_LEN_CCMP = 16,
|
||||||
WLAN_KEY_LEN_TKIP = 32,
|
WLAN_KEY_LEN_TKIP = 32,
|
||||||
|
WLAN_KEY_LEN_AES_CMAC = 16,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -157,26 +157,25 @@ int cfg80211_validate_key_settings(struct key_params *params, int key_idx,
|
||||||
params->cipher != WLAN_CIPHER_SUITE_WEP104)
|
params->cipher != WLAN_CIPHER_SUITE_WEP104)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* TODO: add definitions for the lengths to linux/ieee80211.h */
|
|
||||||
switch (params->cipher) {
|
switch (params->cipher) {
|
||||||
case WLAN_CIPHER_SUITE_WEP40:
|
case WLAN_CIPHER_SUITE_WEP40:
|
||||||
if (params->key_len != 5)
|
if (params->key_len != WLAN_KEY_LEN_WEP40)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
break;
|
||||||
case WLAN_CIPHER_SUITE_TKIP:
|
case WLAN_CIPHER_SUITE_TKIP:
|
||||||
if (params->key_len != 32)
|
if (params->key_len != WLAN_KEY_LEN_TKIP)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
break;
|
||||||
case WLAN_CIPHER_SUITE_CCMP:
|
case WLAN_CIPHER_SUITE_CCMP:
|
||||||
if (params->key_len != 16)
|
if (params->key_len != WLAN_KEY_LEN_CCMP)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
break;
|
||||||
case WLAN_CIPHER_SUITE_WEP104:
|
case WLAN_CIPHER_SUITE_WEP104:
|
||||||
if (params->key_len != 13)
|
if (params->key_len != WLAN_KEY_LEN_WEP104)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
break;
|
||||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||||
if (params->key_len != 16)
|
if (params->key_len != WLAN_KEY_LEN_AES_CMAC)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue