mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 10:18:21 -05:00
mka: Pass full structures down to macsec drivers' packet number ops
Clean up the driver interface by passing pointers to structs transmit_sa and receive_sa down the stack to get_receive_lowest_pn(), get_transmit_next_pn(), and set_transmit_next_pn() ops, instead of passing the individual arguments. Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
This commit is contained in:
parent
f75f6e2b03
commit
7fa5eff8ab
@ -3336,35 +3336,26 @@ struct wpa_driver_ops {
|
||||
/**
|
||||
* get_receive_lowest_pn - Get receive lowest pn
|
||||
* @priv: Private driver interface data
|
||||
* @channel: secure channel
|
||||
* @an: association number
|
||||
* @lowest_pn: lowest accept pn
|
||||
* @sa: secure association
|
||||
* Returns: 0 on success, -1 on failure (or if not supported)
|
||||
*/
|
||||
int (*get_receive_lowest_pn)(void *priv, u32 channel, u8 an,
|
||||
u32 *lowest_pn);
|
||||
int (*get_receive_lowest_pn)(void *priv, struct receive_sa *sa);
|
||||
|
||||
/**
|
||||
* get_transmit_next_pn - Get transmit next pn
|
||||
* @priv: Private driver interface data
|
||||
* @channel: secure channel
|
||||
* @an: association number
|
||||
* @next_pn: next pn
|
||||
* @sa: secure association
|
||||
* Returns: 0 on success, -1 on failure (or if not supported)
|
||||
*/
|
||||
int (*get_transmit_next_pn)(void *priv, u32 channel, u8 an,
|
||||
u32 *next_pn);
|
||||
int (*get_transmit_next_pn)(void *priv, struct transmit_sa *sa);
|
||||
|
||||
/**
|
||||
* set_transmit_next_pn - Set transmit next pn
|
||||
* @priv: Private driver interface data
|
||||
* @channel: secure channel
|
||||
* @an: association number
|
||||
* @next_pn: next pn
|
||||
* @sa: secure association
|
||||
* Returns: 0 on success, -1 on failure (or if not supported)
|
||||
*/
|
||||
int (*set_transmit_next_pn)(void *priv, u32 channel, u8 an,
|
||||
u32 next_pn);
|
||||
int (*set_transmit_next_pn)(void *priv, struct transmit_sa *sa);
|
||||
|
||||
/**
|
||||
* get_available_receive_sc - get available receive channel
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "utils/eloop.h"
|
||||
#include "common/defs.h"
|
||||
#include "common/ieee802_1x_defs.h"
|
||||
#include "pae/ieee802_1x_kay.h"
|
||||
#include "driver.h"
|
||||
|
||||
#include "nss_macsec_secy.h"
|
||||
@ -515,16 +516,16 @@ static int macsec_qca_enable_controlled_port(void *priv, Boolean enabled)
|
||||
}
|
||||
|
||||
|
||||
static int macsec_qca_get_receive_lowest_pn(void *priv, u32 channel, u8 an,
|
||||
u32 *lowest_pn)
|
||||
static int macsec_qca_get_receive_lowest_pn(void *priv, struct receive_sa *sa)
|
||||
{
|
||||
struct macsec_qca_data *drv = priv;
|
||||
int ret = 0;
|
||||
u32 next_pn = 0;
|
||||
bool enabled = FALSE;
|
||||
u32 win;
|
||||
u32 channel = sa->sc->channel;
|
||||
|
||||
ret += nss_macsec_secy_rx_sa_next_pn_get(drv->secy_id, channel, an,
|
||||
ret += nss_macsec_secy_rx_sa_next_pn_get(drv->secy_id, channel, sa->an,
|
||||
&next_pn);
|
||||
ret += nss_macsec_secy_rx_sc_replay_protect_get(drv->secy_id, channel,
|
||||
&enabled);
|
||||
@ -532,40 +533,42 @@ static int macsec_qca_get_receive_lowest_pn(void *priv, u32 channel, u8 an,
|
||||
channel, &win);
|
||||
|
||||
if (enabled)
|
||||
*lowest_pn = (next_pn > win) ? (next_pn - win) : 1;
|
||||
sa->lowest_pn = (next_pn > win) ? (next_pn - win) : 1;
|
||||
else
|
||||
*lowest_pn = next_pn;
|
||||
sa->lowest_pn = next_pn;
|
||||
|
||||
wpa_printf(MSG_DEBUG, "%s: lpn=0x%x", __func__, *lowest_pn);
|
||||
wpa_printf(MSG_DEBUG, "%s: lpn=0x%x", __func__, sa->lowest_pn);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int macsec_qca_get_transmit_next_pn(void *priv, u32 channel, u8 an,
|
||||
u32 *next_pn)
|
||||
static int macsec_qca_get_transmit_next_pn(void *priv, struct transmit_sa *sa)
|
||||
{
|
||||
struct macsec_qca_data *drv = priv;
|
||||
int ret = 0;
|
||||
u32 channel = sa->sc->channel;
|
||||
|
||||
ret += nss_macsec_secy_tx_sa_next_pn_get(drv->secy_id, channel, an,
|
||||
next_pn);
|
||||
ret += nss_macsec_secy_tx_sa_next_pn_get(drv->secy_id, channel, sa->an,
|
||||
&sa->next_pn);
|
||||
|
||||
wpa_printf(MSG_DEBUG, "%s: npn=0x%x", __func__, *next_pn);
|
||||
wpa_printf(MSG_DEBUG, "%s: npn=0x%x", __func__, sa->next_pn);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int macsec_qca_set_transmit_next_pn(void *priv, u32 channel, u8 an, u32 next_pn)
|
||||
int macsec_qca_set_transmit_next_pn(void *priv, struct transmit_sa *sa)
|
||||
{
|
||||
struct macsec_qca_data *drv = priv;
|
||||
int ret = 0;
|
||||
u32 channel = sa->sc->channel;
|
||||
|
||||
ret += nss_macsec_secy_tx_sa_next_pn_set(drv->secy_id, channel, an,
|
||||
next_pn);
|
||||
|
||||
wpa_printf(MSG_INFO, "%s: npn=0x%x", __func__, next_pn);
|
||||
ret += nss_macsec_secy_tx_sa_next_pn_set(drv->secy_id, channel, sa->an,
|
||||
sa->next_pn);
|
||||
|
||||
wpa_printf(MSG_INFO, "%s: npn=0x%x", __func__, sa->next_pn);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -142,11 +142,9 @@ struct ieee802_1x_kay_ctx {
|
||||
int (*set_replay_protect)(void *ctx, Boolean enabled, u32 window);
|
||||
int (*set_current_cipher_suite)(void *ctx, u64 cs);
|
||||
int (*enable_controlled_port)(void *ctx, Boolean enabled);
|
||||
int (*get_receive_lowest_pn)(void *ctx, u32 channel, u8 an,
|
||||
u32 *lowest_pn);
|
||||
int (*get_transmit_next_pn)(void *ctx, u32 channel, u8 an,
|
||||
u32 *next_pn);
|
||||
int (*set_transmit_next_pn)(void *ctx, u32 channel, u8 an, u32 next_pn);
|
||||
int (*get_receive_lowest_pn)(void *ctx, struct receive_sa *sa);
|
||||
int (*get_transmit_next_pn)(void *ctx, struct transmit_sa *sa);
|
||||
int (*set_transmit_next_pn)(void *ctx, struct transmit_sa *sa);
|
||||
int (*get_available_receive_sc)(void *ctx, u32 *channel);
|
||||
int (*create_receive_sc)(void *ctx, u32 channel,
|
||||
struct ieee802_1x_mka_sci *sci,
|
||||
|
@ -130,10 +130,7 @@ int secy_get_receive_lowest_pn(struct ieee802_1x_kay *kay,
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ops->get_receive_lowest_pn(ops->ctx,
|
||||
rxsa->sc->channel,
|
||||
rxsa->an,
|
||||
&rxsa->lowest_pn);
|
||||
return ops->get_receive_lowest_pn(ops->ctx, rxsa);
|
||||
}
|
||||
|
||||
|
||||
@ -154,10 +151,7 @@ int secy_get_transmit_next_pn(struct ieee802_1x_kay *kay,
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ops->get_transmit_next_pn(ops->ctx,
|
||||
txsa->sc->channel,
|
||||
txsa->an,
|
||||
&txsa->next_pn);
|
||||
return ops->get_transmit_next_pn(ops->ctx, txsa);
|
||||
}
|
||||
|
||||
|
||||
@ -178,10 +172,7 @@ int secy_set_transmit_next_pn(struct ieee802_1x_kay *kay,
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ops->set_transmit_next_pn(ops->ctx,
|
||||
txsa->sc->channel,
|
||||
txsa->an,
|
||||
txsa->next_pn);
|
||||
return ops->set_transmit_next_pn(ops->ctx, txsa);
|
||||
}
|
||||
|
||||
|
||||
|
@ -749,33 +749,27 @@ static inline int wpa_drv_enable_controlled_port(struct wpa_supplicant *wpa_s,
|
||||
}
|
||||
|
||||
static inline int wpa_drv_get_receive_lowest_pn(struct wpa_supplicant *wpa_s,
|
||||
u32 channel, u8 an,
|
||||
u32 *lowest_pn)
|
||||
struct receive_sa *sa)
|
||||
{
|
||||
if (!wpa_s->driver->get_receive_lowest_pn)
|
||||
return -1;
|
||||
return wpa_s->driver->get_receive_lowest_pn(wpa_s->drv_priv, channel,
|
||||
an, lowest_pn);
|
||||
return wpa_s->driver->get_receive_lowest_pn(wpa_s->drv_priv, sa);
|
||||
}
|
||||
|
||||
static inline int wpa_drv_get_transmit_next_pn(struct wpa_supplicant *wpa_s,
|
||||
u32 channel, u8 an,
|
||||
u32 *next_pn)
|
||||
struct transmit_sa *sa)
|
||||
{
|
||||
if (!wpa_s->driver->get_transmit_next_pn)
|
||||
return -1;
|
||||
return wpa_s->driver->get_transmit_next_pn(wpa_s->drv_priv, channel,
|
||||
an, next_pn);
|
||||
return wpa_s->driver->get_transmit_next_pn(wpa_s->drv_priv, sa);
|
||||
}
|
||||
|
||||
static inline int wpa_drv_set_transmit_next_pn(struct wpa_supplicant *wpa_s,
|
||||
u32 channel, u8 an,
|
||||
u32 next_pn)
|
||||
struct transmit_sa *sa)
|
||||
{
|
||||
if (!wpa_s->driver->set_transmit_next_pn)
|
||||
return -1;
|
||||
return wpa_s->driver->set_transmit_next_pn(wpa_s->drv_priv, channel,
|
||||
an, next_pn);
|
||||
return wpa_s->driver->set_transmit_next_pn(wpa_s->drv_priv, sa);
|
||||
}
|
||||
|
||||
static inline int wpa_drv_get_available_receive_sc(struct wpa_supplicant *wpa_s,
|
||||
|
@ -62,24 +62,21 @@ static int wpas_enable_controlled_port(void *wpa_s, Boolean enabled)
|
||||
}
|
||||
|
||||
|
||||
static int wpas_get_receive_lowest_pn(void *wpa_s, u32 channel,
|
||||
u8 an, u32 *lowest_pn)
|
||||
static int wpas_get_receive_lowest_pn(void *wpa_s, struct receive_sa *sa)
|
||||
{
|
||||
return wpa_drv_get_receive_lowest_pn(wpa_s, channel, an, lowest_pn);
|
||||
return wpa_drv_get_receive_lowest_pn(wpa_s, sa);
|
||||
}
|
||||
|
||||
|
||||
static int wpas_get_transmit_next_pn(void *wpa_s, u32 channel,
|
||||
u8 an, u32 *next_pn)
|
||||
static int wpas_get_transmit_next_pn(void *wpa_s, struct transmit_sa *sa)
|
||||
{
|
||||
return wpa_drv_get_transmit_next_pn(wpa_s, channel, an, next_pn);
|
||||
return wpa_drv_get_transmit_next_pn(wpa_s, sa);
|
||||
}
|
||||
|
||||
|
||||
static int wpas_set_transmit_next_pn(void *wpa_s, u32 channel,
|
||||
u8 an, u32 next_pn)
|
||||
static int wpas_set_transmit_next_pn(void *wpa_s, struct transmit_sa *sa)
|
||||
{
|
||||
return wpa_drv_set_transmit_next_pn(wpa_s, channel, an, next_pn);
|
||||
return wpa_drv_set_transmit_next_pn(wpa_s, sa);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user