mka: Get rid of struct ieee802_1x_cp_conf

Instead of copying from kay to a temporary struct, and then from the
struct to the sm, just copy from kay to cp.

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
This commit is contained in:
Sabrina Dubroca 2016-08-12 15:07:35 +02:00 committed by Jouni Malinen
parent 07a6bfe1d2
commit 95e9460d6a
4 changed files with 10 additions and 60 deletions

View File

@ -184,16 +184,13 @@ SM_STATE(CP, AUTHENTICATED)
SM_STATE(CP, SECURED)
{
struct ieee802_1x_cp_conf conf;
SM_ENTRY(CP, SECURED);
sm->chgd_server = FALSE;
ieee802_1x_kay_cp_conf(sm->kay, &conf);
sm->protect_frames = conf.protect;
sm->replay_protect = conf.replay_protect;
sm->validate_frames = conf.validate;
sm->protect_frames = sm->kay->macsec_protect;
sm->replay_protect = sm->kay->macsec_replay_protect;
sm->validate_frames = sm->kay->macsec_validate;
/* NOTE: now no other than default cipher suite (AES-GCM-128) */
sm->current_cipher_suite = sm->cipher_suite;
@ -426,9 +423,7 @@ SM_STEP(CP)
/**
* ieee802_1x_cp_sm_init -
*/
struct ieee802_1x_cp_sm * ieee802_1x_cp_sm_init(
struct ieee802_1x_kay *kay,
struct ieee802_1x_cp_conf *pcp_conf)
struct ieee802_1x_cp_sm * ieee802_1x_cp_sm_init(struct ieee802_1x_kay *kay)
{
struct ieee802_1x_cp_sm *sm;
@ -444,10 +439,10 @@ struct ieee802_1x_cp_sm * ieee802_1x_cp_sm_init(
sm->chgd_server = FALSE;
sm->protect_frames = pcp_conf->protect;
sm->validate_frames = pcp_conf->validate;
sm->replay_protect = pcp_conf->replay_protect;
sm->replay_window = pcp_conf->replay_window;
sm->protect_frames = kay->macsec_protect;
sm->validate_frames = kay->macsec_validate;
sm->replay_protect = kay->macsec_replay_protect;
sm->replay_window = kay->macsec_replay_window;
sm->controlled_port_enabled = FALSE;

View File

@ -16,17 +16,7 @@ struct ieee802_1x_cp_sm;
struct ieee802_1x_kay;
struct ieee802_1x_mka_ki;
struct ieee802_1x_cp_conf {
Boolean protect;
Boolean replay_protect;
enum validate_frames validate;
u32 replay_window;
};
struct ieee802_1x_cp_sm *
ieee802_1x_cp_sm_init(struct ieee802_1x_kay *kay,
struct ieee802_1x_cp_conf *pcp_conf);
struct ieee802_1x_cp_sm * ieee802_1x_cp_sm_init(struct ieee802_1x_kay *kay);
void ieee802_1x_cp_sm_deinit(struct ieee802_1x_cp_sm *sm);
void ieee802_1x_cp_sm_step(void *cp_ctx);
void ieee802_1x_cp_connect_pending(void *cp_ctx);

View File

@ -2827,38 +2827,6 @@ int ieee802_1x_kay_enable_new_info(struct ieee802_1x_kay *kay)
}
/**
* ieee802_1x_kay_cp_conf -
*/
int ieee802_1x_kay_cp_conf(struct ieee802_1x_kay *kay,
struct ieee802_1x_cp_conf *pconf)
{
pconf->protect = kay->macsec_protect;
pconf->replay_protect = kay->macsec_replay_protect;
pconf->validate = kay->macsec_validate;
return 0;
}
/**
* ieee802_1x_kay_alloc_cp_sm -
*/
static struct ieee802_1x_cp_sm *
ieee802_1x_kay_alloc_cp_sm(struct ieee802_1x_kay *kay)
{
struct ieee802_1x_cp_conf conf;
os_memset(&conf, 0, sizeof(conf));
conf.protect = kay->macsec_protect;
conf.replay_protect = kay->macsec_replay_protect;
conf.validate = kay->macsec_validate;
conf.replay_window = kay->macsec_replay_window;
return ieee802_1x_cp_sm_init(kay, &conf);
}
/**
* ieee802_1x_kay_mkpdu_sanity_check -
* sanity check specified in clause 11.11.2 of IEEE802.1X-2010
@ -3178,7 +3146,7 @@ ieee802_1x_kay_init(struct ieee802_1x_kay_ctx *ctx, enum macsec_policy policy,
wpa_printf(MSG_DEBUG, "KaY: secy init macsec done");
/* init CP */
kay->cp = ieee802_1x_kay_alloc_cp_sm(kay);
kay->cp = ieee802_1x_cp_sm_init(kay);
if (kay->cp == NULL) {
ieee802_1x_kay_deinit(kay);
return NULL;

View File

@ -14,7 +14,6 @@
#include "common/ieee802_1x_defs.h"
struct macsec_init_params;
struct ieee802_1x_cp_conf;
#define MI_LEN 12
#define MAX_KEY_LEN 32 /* 32 bytes, 256 bits */
@ -186,7 +185,5 @@ int ieee802_1x_kay_enable_tx_sas(struct ieee802_1x_kay *kay,
int ieee802_1x_kay_enable_rx_sas(struct ieee802_1x_kay *kay,
struct ieee802_1x_mka_ki *lki);
int ieee802_1x_kay_enable_new_info(struct ieee802_1x_kay *kay);
int ieee802_1x_kay_cp_conf(struct ieee802_1x_kay *kay,
struct ieee802_1x_cp_conf *pconf);
#endif /* IEEE802_1X_KAY_H */