#ifndef DRIVER_H
#define DRIVER_H
+#include "defs.h"
#include "sta_flags.h"
struct hostapd_data;
*/
int (*set_privacy)(const char *ifname, void *priv, int enabled);
- int (*set_encryption)(const char *ifname, void *priv, const char *alg,
- const u8 *addr, int idx,
- const u8 *key, size_t key_len, int txkey);
+ int (*set_key)(const char *ifname, void *priv, wpa_alg alg,
+ const u8 *addr, int key_idx, int set_tx, const u8 *seq,
+ size_t seq_len, const u8 *key, size_t key_len);
int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
int idx, u8 *seq);
int (*get_seqnum_igtk)(const char *ifname, void *priv, const u8 *addr,
}
static int
-madwifi_set_key(const char *ifname, void *priv, const char *alg,
- const u8 *addr, int key_idx,
- const u8 *key, size_t key_len, int txkey)
+madwifi_set_key(const char *ifname, void *priv, wpa_alg alg, const u8 *addr,
+ int key_idx, int set_tx, const u8 *seq, size_t seq_len,
+ const u8 *key, size_t key_len)
{
struct madwifi_driver_data *drv = priv;
struct ieee80211req_key wk;
u_int8_t cipher;
int ret;
- if (strcmp(alg, "none") == 0)
+ if (alg == WPA_ALG_NONE)
return madwifi_del_key(drv, addr, key_idx);
- wpa_printf(MSG_DEBUG, "%s: alg=%s addr=%s key_idx=%d",
+ wpa_printf(MSG_DEBUG, "%s: alg=%d addr=%s key_idx=%d",
__func__, alg, ether_sprintf(addr), key_idx);
- if (strcmp(alg, "WEP") == 0)
+ switch (alg) {
+ case WPA_ALG_WEP:
cipher = IEEE80211_CIPHER_WEP;
- else if (strcmp(alg, "TKIP") == 0)
+ break;
+ case WPA_ALG_TKIP:
cipher = IEEE80211_CIPHER_TKIP;
- else if (strcmp(alg, "CCMP") == 0)
+ break;
+ case WPA_ALG_CCMP:
cipher = IEEE80211_CIPHER_AES_CCM;
- else {
- printf("%s: unknown/unsupported algorithm %s\n",
+ break;
+ default:
+ printf("%s: unknown/unsupported algorithm %d\n",
__func__, alg);
return -1;
}
ret = set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk));
if (ret < 0) {
wpa_printf(MSG_DEBUG, "%s: Failed to set key (addr %s"
- " key_idx %d alg '%s' key_len %lu txkey %d)",
+ " key_idx %d alg %d key_len %lu set_tx %d)",
__func__, ether_sprintf(wk.ik_macaddr), key_idx,
- alg, (unsigned long) key_len, txkey);
+ alg, (unsigned long) key_len, set_tx);
}
return ret;
.deinit = madwifi_deinit,
.set_ieee8021x = madwifi_set_ieee8021x,
.set_privacy = madwifi_set_privacy,
- .set_encryption = madwifi_set_key,
+ .set_key = madwifi_set_key,
.get_seqnum = madwifi_get_seqnum,
.flush = madwifi_flush,
.set_generic_elem = madwifi_set_opt_ie,
}
static int
-bsd_set_key(const char *ifname, void *priv, const char *alg,
- const u8 *addr, int key_idx,
- const u8 *key, size_t key_len, int txkey)
+bsd_set_key(const char *ifname, void *priv, wpa_alg alg,
+ const u8 *addr, int key_idx, int set_tx, const u8 *seq,
+ size_t seq_len, const u8 *key, size_t key_len)
{
struct bsd_driver_data *drv = priv;
struct ieee80211req_key wk;
u_int8_t cipher;
- if (strcmp(alg, "none") == 0)
+ if (alg == WPA_ALG_NONE)
return bsd_del_key(drv, addr, key_idx);
- wpa_printf(MSG_DEBUG, "%s: alg=%s addr=%s key_idx=%d",
+ wpa_printf(MSG_DEBUG, "%s: alg=%d addr=%s key_idx=%d",
__func__, alg, ether_sprintf(addr), key_idx);
- if (strcmp(alg, "WEP") == 0)
+ if (alg == WPA_ALG_WEP)
cipher = IEEE80211_CIPHER_WEP;
- else if (strcmp(alg, "TKIP") == 0)
+ else if (alg == WPA_ALG_TKIP)
cipher = IEEE80211_CIPHER_TKIP;
- else if (strcmp(alg, "CCMP") == 0)
+ else if (alg == WPA_ALG_CCMP)
cipher = IEEE80211_CIPHER_AES_CCM;
else {
- printf("%s: unknown/unsupported algorithm %s\n",
+ printf("%s: unknown/unsupported algorithm %d\n",
__func__, alg);
return -1;
}
.deinit = bsd_deinit,
.set_ieee8021x = bsd_set_ieee8021x,
.set_privacy = bsd_set_privacy,
- .set_encryption = bsd_set_key,
+ .set_key = bsd_set_key,
.get_seqnum = bsd_get_seqnum,
.flush = bsd_flush,
.set_generic_elem = bsd_set_opt_ie,
}
-static int hostap_set_encryption(const char *ifname, void *priv,
- const char *alg, const u8 *addr,
- int idx, const u8 *key, size_t key_len,
- int txkey)
+static int hostap_set_key(const char *ifname, void *priv, wpa_alg alg,
+ const u8 *addr, int key_idx, int set_tx,
+ const u8 *seq, size_t seq_len, const u8 *key,
+ size_t key_len)
{
struct hostap_driver_data *drv = priv;
struct prism2_hostapd_param *param;
memset(param->sta_addr, 0xff, ETH_ALEN);
else
memcpy(param->sta_addr, addr, ETH_ALEN);
- os_strlcpy((char *) param->u.crypt.alg, alg,
- HOSTAP_CRYPT_ALG_NAME_LEN);
- param->u.crypt.flags = txkey ? HOSTAP_CRYPT_FLAG_SET_TX_KEY : 0;
- param->u.crypt.idx = idx;
+ switch (alg) {
+ case WPA_ALG_NONE:
+ os_strlcpy((char *) param->u.crypt.alg, "NONE",
+ HOSTAP_CRYPT_ALG_NAME_LEN);
+ break;
+ case WPA_ALG_WEP:
+ os_strlcpy((char *) param->u.crypt.alg, "WEP",
+ HOSTAP_CRYPT_ALG_NAME_LEN);
+ break;
+ case WPA_ALG_TKIP:
+ os_strlcpy((char *) param->u.crypt.alg, "TKIP",
+ HOSTAP_CRYPT_ALG_NAME_LEN);
+ break;
+ case WPA_ALG_CCMP:
+ os_strlcpy((char *) param->u.crypt.alg, "CCMP",
+ HOSTAP_CRYPT_ALG_NAME_LEN);
+ break;
+ default:
+ os_free(buf);
+ return -1;
+ }
+ param->u.crypt.flags = set_tx ? HOSTAP_CRYPT_FLAG_SET_TX_KEY : 0;
+ param->u.crypt.idx = key_idx;
param->u.crypt.key_len = key_len;
memcpy((u8 *) (param + 1), key, key_len);
.wireless_event_deinit = hostap_wireless_event_deinit,
.set_ieee8021x = hostap_set_ieee8021x,
.set_privacy = hostap_set_privacy,
- .set_encryption = hostap_set_encryption,
+ .set_key = hostap_set_key,
.get_seqnum = hostap_get_seqnum,
.flush = hostap_flush,
.set_generic_elem = hostap_set_generic_elem,
}
static inline int
-hostapd_set_encryption(const char *ifname, struct hostapd_data *hapd,
- const char *alg, const u8 *addr, int idx,
- u8 *key, size_t key_len, int txkey)
+hostapd_set_key(const char *ifname, struct hostapd_data *hapd,
+ wpa_alg alg, const u8 *addr, int key_idx,
+ int set_tx, const u8 *seq, size_t seq_len,
+ const u8 *key, size_t key_len)
{
- if (hapd->driver == NULL || hapd->driver->set_encryption == NULL)
+ if (hapd->driver == NULL || hapd->driver->set_key == NULL)
return 0;
- return hapd->driver->set_encryption(ifname, hapd->drv_priv, alg, addr,
- idx, key, key_len, txkey);
+ return hapd->driver->set_key(ifname, hapd->drv_priv, alg, addr,
+ key_idx, set_tx, seq, seq_len, key,
+ key_len);
}
static inline int
}
static int
-madwifi_set_key(const char *ifname, void *priv, const char *alg,
- const u8 *addr, int key_idx,
- const u8 *key, size_t key_len, int txkey)
+madwifi_set_key(const char *ifname, void *priv, wpa_alg alg,
+ const u8 *addr, int key_idx, int set_tx, const u8 *seq,
+ size_t seq_len, const u8 *key, size_t key_len)
{
struct madwifi_driver_data *drv = priv;
struct ieee80211req_key wk;
u_int8_t cipher;
int ret;
- if (strcmp(alg, "none") == 0)
+ if (alg == WPA_ALG_NONE)
return madwifi_del_key(drv, addr, key_idx);
- wpa_printf(MSG_DEBUG, "%s: alg=%s addr=%s key_idx=%d",
+ wpa_printf(MSG_DEBUG, "%s: alg=%d addr=%s key_idx=%d",
__func__, alg, ether_sprintf(addr), key_idx);
- if (strcmp(alg, "WEP") == 0)
+ if (alg == WPA_ALG_WEP)
cipher = IEEE80211_CIPHER_WEP;
- else if (strcmp(alg, "TKIP") == 0)
+ else if (alg == WPA_ALG_TKIP)
cipher = IEEE80211_CIPHER_TKIP;
- else if (strcmp(alg, "CCMP") == 0)
+ else if (alg == WPA_ALG_CCMP)
cipher = IEEE80211_CIPHER_AES_CCM;
else {
- printf("%s: unknown/unsupported algorithm %s\n",
+ printf("%s: unknown/unsupported algorithm %d\n",
__func__, alg);
return -1;
}
ret = set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk));
if (ret < 0) {
wpa_printf(MSG_DEBUG, "%s: Failed to set key (addr %s"
- " key_idx %d alg '%s' key_len %lu txkey %d)",
+ " key_idx %d alg %d key_len %lu set_tx %d)",
__func__, ether_sprintf(wk.ik_macaddr), key_idx,
- alg, (unsigned long) key_len, txkey);
+ alg, (unsigned long) key_len, set_tx);
}
return ret;
.deinit = madwifi_deinit,
.set_ieee8021x = madwifi_set_ieee8021x,
.set_privacy = madwifi_set_privacy,
- .set_encryption = madwifi_set_key,
+ .set_key = madwifi_set_key,
.get_seqnum = madwifi_get_seqnum,
.flush = madwifi_flush,
.set_generic_elem = madwifi_set_opt_ie,
static int nl_set_encr(int ifindex, struct i802_driver_data *drv,
- const char *alg, const u8 *addr, int idx, const u8 *key,
+ wpa_alg alg, const u8 *addr, int idx, const u8 *key,
size_t key_len, int txkey)
{
struct nl_msg *msg;
if (!msg)
return -ENOMEM;
- if (strcmp(alg, "none") == 0) {
+ if (alg == WPA_ALG_NONE) {
genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
0, NL80211_CMD_DEL_KEY, 0);
} else {
genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
0, NL80211_CMD_NEW_KEY, 0);
NLA_PUT(msg, NL80211_ATTR_KEY_DATA, key_len, key);
- if (strcmp(alg, "WEP") == 0) {
+ switch (alg) {
+ case WPA_ALG_WEP:
if (key_len == 5)
NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER,
0x000FAC01);
else
NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER,
0x000FAC05);
- } else if (strcmp(alg, "TKIP") == 0)
+ break;
+ case WPA_ALG_TKIP:
NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC02);
- else if (strcmp(alg, "CCMP") == 0)
+ break;
+ case WPA_ALG_CCMP:
NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC04);
- else if (strcmp(alg, "IGTK") == 0)
+ break;
+ case WPA_ALG_IGTK:
NLA_PUT_U32(msg, NL80211_ATTR_KEY_CIPHER, 0x000FAC06);
- else {
+ break;
+ default:
wpa_printf(MSG_ERROR, "%s: Unsupported encryption "
- "algorithm '%s'", __func__, alg);
+ "algorithm %d", __func__, alg);
nlmsg_free(msg);
return -1;
}
0, NL80211_CMD_SET_KEY, 0);
NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, idx);
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
- if (strcmp(alg, "IGTK") == 0)
+ if (alg == WPA_ALG_IGTK)
NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT_MGMT);
else
NLA_PUT_FLAG(msg, NL80211_ATTR_KEY_DEFAULT);
}
-static int i802_set_encryption(const char *iface, void *priv, const char *alg,
- const u8 *addr, int idx, const u8 *key,
- size_t key_len, int txkey)
+static int i802_set_key(const char *iface, void *priv, wpa_alg alg,
+ const u8 *addr, int key_idx, int set_tx, const u8 *seq,
+ size_t seq_len, const u8 *key, size_t key_len)
{
struct i802_driver_data *drv = priv;
int ret;
- ret = nl_set_encr(if_nametoindex(iface), drv, alg, addr, idx, key,
- key_len, txkey);
+ ret = nl_set_encr(if_nametoindex(iface), drv, alg, addr, key_idx, key,
+ key_len, set_tx);
if (ret < 0)
return ret;
.wireless_event_deinit = i802_wireless_event_deinit,
.set_ieee8021x = i802_set_ieee8021x,
.set_privacy = i802_set_privacy,
- .set_encryption = i802_set_encryption,
+ .set_key = i802_set_key,
.get_seqnum = i802_get_seqnum,
.flush = i802_flush,
.read_sta_data = i802_read_sta_data,
}
-/* set per station key */
-static int prism54_set_encryption(const char *ifname, void *priv,
- const char *alg, const u8 *addr,
- int idx, const u8 *key, size_t key_len,
- int txkey)
+static int prism54_set_key(const char *ifname, void *priv, wpa_alg alg,
+ const u8 *addr, int key_idx, int set_tx,
+ const u8 *seq, size_t seq_len,
+ const u8 *key, size_t key_len)
{
struct prism54_driver_data *drv = priv;
pimdev_hdr *hdr;
} else {
memcpy(&keys->address[0], addr, ETH_ALEN);
}
- if (!strcmp(alg, "WEP")) {
+ switch (alg) {
+ case WPA_ALG_WEP:
keys->type = DOT11_PRIV_WEP;
- } else if (!strcmp(alg, "TKIP")) {
+ break;
+ case WPA_ALG_TKIP:
keys->type = DOT11_PRIV_TKIP;
- } else if (!strcmp(alg, "none")) {
+ break;
+ case WPA_ALG_NONE:
/* the only way to clear the key is to deauth it */
/* and prism54 is capable to receive unencrypted packet */
/* so we do nothing here */
free(hdr);
return 0;
- } else {
- printf("bad auth type: %s\n", alg);
+ default:
+ printf("bad auth type: %d\n", alg);
+ free(hdr);
+ return -1;
}
buf = (u8 *) &keys->key[0];
keys->length = key_len;
- keys->keyid = idx;
+ keys->keyid = key_idx;
keys->options = htons(DOT11_STAKEY_OPTION_DEFAULTKEY);
keys->reserved = 0;
.deinit = prism54_driver_deinit,
/* .set_ieee8021x = prism54_init_1x, */
.set_privacy = prism54_set_privacy_invoked,
- .set_encryption = prism54_set_encryption,
+ .set_key = prism54_set_key,
.get_seqnum = prism54_get_seqnum,
.flush = prism54_flush,
.set_generic_elem = prism54_set_generic_elem,
}
-static int test_driver_set_encryption(const char *iface, void *priv,
- const char *alg, const u8 *addr, int idx,
- const u8 *key, size_t key_len, int txkey)
+static int test_driver_set_key(const char *iface, void *priv, wpa_alg alg,
+ const u8 *addr, int key_idx, int set_tx,
+ const u8 *seq, size_t seq_len,
+ const u8 *key, size_t key_len)
{
- wpa_printf(MSG_DEBUG, "%s(iface=%s alg=%s idx=%d txkey=%d)",
- __func__, iface, alg, idx, txkey);
+ wpa_printf(MSG_DEBUG, "%s(iface=%s alg=%d idx=%d set_tx=%d)",
+ __func__, iface, alg, key_idx, set_tx);
if (addr)
wpa_printf(MSG_DEBUG, " addr=" MACSTR, MAC2STR(addr));
if (key)
.valid_bss_mask = test_driver_valid_bss_mask,
.set_ssid = test_driver_set_ssid,
.set_privacy = test_driver_set_privacy,
- .set_encryption = test_driver_set_encryption,
+ .set_key = test_driver_set_key,
.set_sta_vlan = test_driver_set_sta_vlan,
.sta_add = test_driver_sta_add,
.send_ether = test_driver_send_ether,
int i;
for (i = 0; i < NUM_WEP_KEYS; i++) {
- if (hostapd_set_encryption(ifname, hapd, "none", NULL, i, NULL,
- 0, i == 0 ? 1 : 0)) {
+ if (hostapd_set_key(ifname, hapd, WPA_ALG_NONE, NULL, i,
+ i == 0 ? 1 : 0, NULL, 0, NULL, 0)) {
wpa_printf(MSG_DEBUG, "Failed to clear default "
"encryption keys (ifname=%s keyidx=%d)",
ifname, i);
#ifdef CONFIG_IEEE80211W
if (hapd->conf->ieee80211w) {
for (i = NUM_WEP_KEYS; i < NUM_WEP_KEYS + 2; i++) {
- if (hostapd_set_encryption(ifname, hapd, "none", NULL,
- i, NULL, 0,
- i == 0 ? 1 : 0)) {
+ if (hostapd_set_key(ifname, hapd, WPA_ALG_NONE, NULL,
+ i, i == 0 ? 1 : 0, NULL, 0,
+ NULL, 0)) {
wpa_printf(MSG_DEBUG, "Failed to clear "
"default mgmt encryption keys "
"(ifname=%s keyidx=%d)", ifname, i);
idx = ssid->wep.idx;
if (ssid->wep.default_len &&
- hostapd_set_encryption(hapd->conf->iface,
- hapd, "WEP", NULL, idx,
- ssid->wep.key[idx],
- ssid->wep.len[idx],
- idx == ssid->wep.idx)) {
+ hostapd_set_key(hapd->conf->iface,
+ hapd, WPA_ALG_WEP, NULL, idx, idx == ssid->wep.idx,
+ NULL, 0, ssid->wep.key[idx], ssid->wep.len[idx])) {
wpa_printf(MSG_WARNING, "Could not set WEP encryption.");
errors++;
}
continue;
idx = key->idx;
- if (hostapd_set_encryption(ifname, hapd, "WEP", NULL,
- idx, key->key[idx],
- key->len[idx],
- idx == key->idx)) {
+ if (hostapd_set_key(ifname, hapd, WPA_ALG_WEP, NULL,
+ idx, idx == key->idx, NULL, 0,
+ key->key[idx], key->len[idx])) {
wpa_printf(MSG_WARNING, "Could not set "
"dynamic VLAN WEP encryption.");
errors++;
for (i = 0; i < 4; i++) {
if (hapd->conf->ssid.wep.key[i] &&
- hostapd_set_encryption(iface, hapd, "WEP", NULL,
- i, hapd->conf->ssid.wep.key[i],
- hapd->conf->ssid.wep.len[i],
- i == hapd->conf->ssid.wep.idx)) {
+ hostapd_set_key(iface, hapd, WPA_ALG_WEP, NULL, i,
+ i == hapd->conf->ssid.wep.idx, NULL, 0,
+ hapd->conf->ssid.wep.key[i],
+ hapd->conf->ssid.wep.len[i])) {
wpa_printf(MSG_WARNING, "Could not set WEP "
"encryption.");
return -1;
}
-static int hostapd_wpa_auth_set_key(void *ctx, int vlan_id, const char *alg,
+static int hostapd_wpa_auth_set_key(void *ctx, int vlan_id, wpa_alg alg,
const u8 *addr, int idx, u8 *key,
size_t key_len)
{
return -1;
}
- return hostapd_set_encryption(ifname, hapd, alg, addr, idx,
- key, key_len, 1);
+ return hostapd_set_key(ifname, hapd, alg, addr, idx, 1, NULL, 0,
+ key, key_len);
}
wpa_hexdump_key(MSG_DEBUG, "Default WEP key (dynamic VLAN)",
key->key[key->idx], key->len[key->idx]);
- if (hostapd_set_encryption(ifname, hapd, "WEP", NULL, key->idx,
- key->key[key->idx], key->len[key->idx], 1))
+ if (hostapd_set_key(ifname, hapd, WPA_ALG_WEP, NULL, key->idx, 1,
+ NULL, 0, key->key[key->idx], key->len[key->idx]))
printf("Could not set dynamic VLAN WEP encryption key.\n");
hostapd_set_ieee8021x(ifname, hapd, 1);
/* TODO: set encryption in TX callback, i.e., only after STA
* has ACKed EAPOL-Key frame */
- if (hostapd_set_encryption(hapd->conf->iface, hapd, "WEP",
- sta->addr, 0, ikey,
- hapd->conf->individual_wep_key_len,
- 1)) {
+ if (hostapd_set_key(hapd->conf->iface, hapd, WPA_ALG_WEP,
+ sta->addr, 0, 1, NULL, 0, ikey,
+ hapd->conf->individual_wep_key_len)) {
wpa_printf(MSG_ERROR, "Could not set individual WEP "
"encryption.");
}
/* TODO: Could setup key for RX here, but change default TX keyid only
* after new broadcast key has been sent to all stations. */
- if (hostapd_set_encryption(hapd->conf->iface, hapd, "WEP", NULL,
- hapd->default_wep_key_idx,
- hapd->default_wep_key,
- hapd->conf->default_wep_key_len, 1)) {
+ if (hostapd_set_key(hapd->conf->iface, hapd, WPA_ALG_WEP, NULL,
+ hapd->default_wep_key_idx, 1, NULL, 0,
+ hapd->default_wep_key,
+ hapd->conf->default_wep_key_len)) {
hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE8021X,
HOSTAPD_LEVEL_WARNING, "failed to configure a "
"new broadcast key");
hostapd_set_privacy(hapd, 1);
for (i = 0; i < 4; i++)
- hostapd_set_encryption(hapd->conf->iface, hapd,
- "none", NULL, i, NULL, 0, 0);
+ hostapd_set_key(hapd->conf->iface, hapd, WPA_ALG_NONE,
+ NULL, i, 0, NULL, 0, NULL, 0);
ieee802_1x_rekey(hapd, NULL);
* functions for setting up dynamic broadcast keys. */
for (i = 0; i < 4; i++) {
if (mssid->wep.key[i] &&
- hostapd_set_encryption(dyn_vlan, hapd, "WEP", NULL,
- i, mssid->wep.key[i],
- mssid->wep.len[i],
- i == mssid->wep.idx)) {
+ hostapd_set_key(dyn_vlan, hapd, WPA_ALG_WEP, NULL, i,
+ i == mssid->wep.idx, NULL, 0,
+ mssid->wep.key[i], mssid->wep.len[i])) {
printf("VLAN: Could not set WEP encryption for "
"dynamic VLAN.\n");
return -1;
static inline int wpa_auth_set_key(struct wpa_authenticator *wpa_auth,
int vlan_id,
- const char *alg, const u8 *addr, int idx,
+ wpa_alg alg, const u8 *addr, int idx,
u8 *key, size_t key_len)
{
if (wpa_auth->cb.set_key == NULL)
{
sm->PTK_valid = FALSE;
os_memset(&sm->PTK, 0, sizeof(sm->PTK));
- wpa_auth_set_key(sm->wpa_auth, 0, "none", sm->addr, 0, (u8 *) "", 0);
+ wpa_auth_set_key(sm->wpa_auth, 0, WPA_ALG_NONE, sm->addr, 0, (u8 *) "",
+ 0);
sm->pairwise_set = FALSE;
eloop_cancel_timeout(wpa_rekey_ptk, sm->wpa_auth, sm);
}
}
-static const char * wpa_alg_txt(int alg)
+static wpa_alg wpa_alg_enum(int alg)
{
switch (alg) {
case WPA_CIPHER_CCMP:
- return "CCMP";
+ return WPA_ALG_CCMP;
case WPA_CIPHER_TKIP:
- return "TKIP";
+ return WPA_ALG_TKIP;
case WPA_CIPHER_WEP104:
case WPA_CIPHER_WEP40:
- return "WEP";
+ return WPA_ALG_WEP;
default:
- return "";
+ return WPA_ALG_NONE;
}
}
SM_ENTRY_MA(WPA_PTK, PTKINITDONE, wpa_ptk);
sm->EAPOLKeyReceived = FALSE;
if (sm->Pair) {
- char *alg;
+ wpa_alg alg;
int klen;
if (sm->pairwise == WPA_CIPHER_TKIP) {
- alg = "TKIP";
+ alg = WPA_ALG_TKIP;
klen = 32;
} else {
- alg = "CCMP";
+ alg = WPA_ALG_CCMP;
klen = 16;
}
if (wpa_auth_set_key(sm->wpa_auth, 0, alg, sm->addr, 0,
group->changed = TRUE;
group->wpa_group_state = WPA_GROUP_SETKEYSDONE;
wpa_auth_set_key(wpa_auth, group->vlan_id,
- wpa_alg_txt(wpa_auth->conf.wpa_group),
+ wpa_alg_enum(wpa_auth->conf.wpa_group),
NULL, group->GN, group->GTK[group->GN - 1],
group->GTK_len);
#ifdef CONFIG_IEEE80211W
if (wpa_auth->conf.ieee80211w != WPA_NO_IEEE80211W) {
- wpa_auth_set_key(wpa_auth, group->vlan_id, "IGTK",
+ wpa_auth_set_key(wpa_auth, group->vlan_id, WPA_ALG_IGTK,
NULL, group->GN_igtk,
group->IGTK[group->GN_igtk - 4],
WPA_IGTK_LEN);
#ifndef WPA_AUTH_H
#define WPA_AUTH_H
+#include "defs.h"
#include "eapol_common.h"
#include "wpa_common.h"
int (*get_eapol)(void *ctx, const u8 *addr, wpa_eapol_variable var);
const u8 * (*get_psk)(void *ctx, const u8 *addr, const u8 *prev_psk);
int (*get_msk)(void *ctx, const u8 *addr, u8 *msk, size_t *len);
- int (*set_key)(void *ctx, int vlan_id, const char *alg, const u8 *addr,
+ int (*set_key)(void *ctx, int vlan_id, wpa_alg alg, const u8 *addr,
int idx, u8 *key, size_t key_len);
int (*get_seqnum)(void *ctx, const u8 *addr, int idx, u8 *seq);
int (*get_seqnum_igtk)(void *ctx, const u8 *addr, int idx, u8 *seq);
static inline int wpa_auth_set_key(struct wpa_authenticator *wpa_auth,
int vlan_id,
- const char *alg, const u8 *addr, int idx,
+ wpa_alg alg, const u8 *addr, int idx,
u8 *key, size_t key_len)
{
if (wpa_auth->cb.set_key == NULL)
static void wpa_ft_install_ptk(struct wpa_state_machine *sm)
{
- char *alg;
+ wpa_alg alg;
int klen;
/* MLME-SETKEYS.request(PTK) */
if (sm->pairwise == WPA_CIPHER_TKIP) {
- alg = "TKIP";
+ alg = WPA_ALG_TKIP;
klen = 32;
} else if (sm->pairwise == WPA_CIPHER_CCMP) {
- alg = "CCMP";
+ alg = WPA_ALG_CCMP;
klen = 16;
} else
return;