Use more consistent set_key seq value when nothing is being set
Use NULL instead of (u8 *) "" as the seq value and make sure the driver wrapper implementations can handle NULL value. This was previously already done in number of places, but not everywhere.
This commit is contained in:
parent
0a9ddd92cd
commit
da64c266e7
9 changed files with 15 additions and 10 deletions
|
@ -753,7 +753,7 @@ struct wpa_driver_ops {
|
|||
* @seq: sequence number/packet number, seq_len octets, the next
|
||||
* packet number to be used for in replay protection; configured
|
||||
* for Rx keys (in most cases, this is only used with broadcast
|
||||
* keys and set to zero for unicast keys)
|
||||
* keys and set to zero for unicast keys); %NULL if not set
|
||||
* @seq_len: length of the seq, depends on the algorithm:
|
||||
* TKIP: 6 octets, CCMP: 6 octets, IGTK: 6 octets
|
||||
* @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
|
||||
|
|
|
@ -248,7 +248,8 @@ static int wpa_driver_atmel_set_key(const char *ifname, void *priv,
|
|||
param->alg = alg_type;
|
||||
param->key_idx = key_idx;
|
||||
param->set_tx = set_tx;
|
||||
os_memcpy(param->seq, seq, seq_len);
|
||||
if (seq)
|
||||
os_memcpy(param->seq, seq, seq_len);
|
||||
param->seq_len = seq_len;
|
||||
param->key_len = key_len;
|
||||
os_memcpy((u8 *)param->key, key, key_len);
|
||||
|
|
|
@ -347,7 +347,8 @@ bsd_set_key(const char *ifname, void *priv, enum wpa_alg alg,
|
|||
if (wk.ik_keyix != IEEE80211_KEYIX_NONE && set_tx)
|
||||
wk.ik_flags |= IEEE80211_KEY_DEFAULT;
|
||||
wk.ik_keylen = key_len;
|
||||
os_memcpy(&wk.ik_keyrsc, seq, seq_len);
|
||||
if (seq)
|
||||
os_memcpy(&wk.ik_keyrsc, seq, seq_len);
|
||||
os_memcpy(wk.ik_keydata, key, key_len);
|
||||
|
||||
return set80211var(priv, IEEE80211_IOC_WPAKEY, &wk, sizeof(wk));
|
||||
|
|
|
@ -1307,7 +1307,8 @@ static int wpa_driver_hostap_set_key(const char *ifname, void *priv,
|
|||
HOSTAP_CRYPT_ALG_NAME_LEN);
|
||||
param->u.crypt.flags = set_tx ? HOSTAP_CRYPT_FLAG_SET_TX_KEY : 0;
|
||||
param->u.crypt.idx = key_idx;
|
||||
os_memcpy(param->u.crypt.seq, seq, seq_len);
|
||||
if (seq)
|
||||
os_memcpy(param->u.crypt.seq, seq, seq_len);
|
||||
param->u.crypt.key_len = key_len;
|
||||
os_memcpy((u8 *) (param + 1), key, key_len);
|
||||
|
||||
|
|
|
@ -264,7 +264,8 @@ static int wpa_driver_ipw_set_key(const char *ifname, void *priv,
|
|||
IPW_CRYPT_ALG_NAME_LEN);
|
||||
param->u.crypt.set_tx = set_tx ? 1 : 0;
|
||||
param->u.crypt.idx = key_idx;
|
||||
os_memcpy(param->u.crypt.seq, seq, seq_len);
|
||||
if (seq)
|
||||
os_memcpy(param->u.crypt.seq, seq, seq_len);
|
||||
param->u.crypt.key_len = key_len;
|
||||
os_memcpy((u8 *) (param + 1), key, key_len);
|
||||
|
||||
|
|
|
@ -1511,7 +1511,7 @@ wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
|
|||
wk.ik_keyix = key_idx;
|
||||
wk.ik_keylen = key_len;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
{
|
||||
if (seq) {
|
||||
size_t i;
|
||||
u8 tmp[WPA_KEY_RSC_LEN];
|
||||
os_memset(tmp, 0, sizeof(tmp));
|
||||
|
@ -1520,7 +1520,8 @@ wpa_driver_madwifi_set_key(const char *ifname, void *priv, enum wpa_alg alg,
|
|||
os_memcpy(&wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN);
|
||||
}
|
||||
#else /* WORDS_BIGENDIAN */
|
||||
os_memcpy(&wk.ik_keyrsc, seq, seq_len);
|
||||
if (seq)
|
||||
os_memcpy(&wk.ik_keyrsc, seq, seq_len);
|
||||
#endif /* WORDS_BIGENDIAN */
|
||||
os_memcpy(wk.ik_keydata, key, key_len);
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ static int wpa_ndiswrapper_set_key(const char *ifname, void *priv,
|
|||
wpa_key.addr = addr;
|
||||
wpa_key.key_index = key_idx;
|
||||
wpa_key.set_tx = set_tx;
|
||||
wpa_key.seq = seq;
|
||||
wpa_key.seq = seq ? seq : (u8 *) "";
|
||||
wpa_key.seq_len = seq_len;
|
||||
wpa_key.key = key;
|
||||
wpa_key.key_len = key_len;
|
||||
|
|
|
@ -134,7 +134,7 @@ int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
|
|||
set = 1;
|
||||
wpa_drv_set_key(wpa_s, WPA_ALG_WEP,
|
||||
(u8 *) "\xff\xff\xff\xff\xff\xff",
|
||||
i, i == ssid->wep_tx_keyidx, (u8 *) "", 0,
|
||||
i, i == ssid->wep_tx_keyidx, NULL, 0,
|
||||
ssid->wep_key[i], ssid->wep_key_len[i]);
|
||||
}
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ static int wpa_eapol_set_wep_key(void *ctx, int unicast, int keyidx,
|
|||
return wpa_drv_set_key(wpa_s, WPA_ALG_WEP,
|
||||
unicast ? wpa_s->bssid :
|
||||
(u8 *) "\xff\xff\xff\xff\xff\xff",
|
||||
keyidx, unicast, (u8 *) "", 0, key, keylen);
|
||||
keyidx, unicast, NULL, 0, key, keylen);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue