aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSabrina Dubroca <sd@queasysnail.net>2016-08-12 13:07:33 (GMT)
committerJouni Malinen <j@w1.fi>2016-08-28 17:29:20 (GMT)
commitd4f668fded5f6800a6fa8aec485d7580fb46b04f (patch)
treeb9e3d4aac431b0123000edec657938424ee38987 /src
parent1de7a9f88213bac17ce5b33be00fb69304d38766 (diff)
downloadhostap-d4f668fded5f6800a6fa8aec485d7580fb46b04f.zip
hostap-d4f668fded5f6800a6fa8aec485d7580fb46b04f.tar.gz
hostap-d4f668fded5f6800a6fa8aec485d7580fb46b04f.tar.bz2
mka: Add MKA_ALIGN_LENGTH macro
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Diffstat (limited to 'src')
-rw-r--r--src/pae/ieee802_1x_kay.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c
index 122c3be..36b7105 100644
--- a/src/pae/ieee802_1x_kay.c
+++ b/src/pae/ieee802_1x_kay.c
@@ -29,6 +29,8 @@
#define PENDING_PN_EXHAUSTION 0xC0000000
+#define MKA_ALIGN_LENGTH(len) (((len) + 0x3) & ~0x3)
+
/* IEEE Std 802.1X-2010, Table 9-1 - MKA Algorithm Agility */
#define MKA_ALGO_AGILITY_2009 { 0x00, 0x80, 0xC2, 0x01 }
static u8 mka_algo_agility[4] = MKA_ALGO_AGILITY_2009;
@@ -673,7 +675,7 @@ ieee802_1x_mka_basic_body_length(struct ieee802_1x_mka_participant *participant)
length = sizeof(struct ieee802_1x_mka_basic_body);
length += participant->ckn.len;
- return (length + 0x3) & ~0x3;
+ return MKA_ALIGN_LENGTH(length);
}
@@ -829,7 +831,7 @@ ieee802_1x_mka_get_live_peer_length(
struct ieee802_1x_kay_peer, list)
len += sizeof(struct ieee802_1x_mka_peer_id);
- return (len + 0x3) & ~0x3;
+ return MKA_ALIGN_LENGTH(len);
}
@@ -890,7 +892,7 @@ ieee802_1x_mka_get_potential_peer_length(
struct ieee802_1x_kay_peer, list)
len += sizeof(struct ieee802_1x_mka_peer_id);
- return (len + 0x3) & ~0x3;
+ return MKA_ALIGN_LENGTH(len);
}
@@ -1134,12 +1136,8 @@ ieee802_1x_mka_get_sak_use_length(
if (participant->kay->macsec_desired && participant->advised_desired)
length = sizeof(struct ieee802_1x_mka_sak_use_body);
- else
- length = MKA_HDR_LEN;
-
- length = (length + 0x3) & ~0x3;
- return length;
+ return MKA_ALIGN_LENGTH(length);
}
@@ -1443,7 +1441,7 @@ static int
ieee802_1x_mka_get_dist_sak_length(
struct ieee802_1x_mka_participant *participant)
{
- int length;
+ int length = MKA_HDR_LEN;
int cs_index = participant->kay->macsec_csindex;
if (participant->advised_desired) {
@@ -1452,12 +1450,9 @@ ieee802_1x_mka_get_dist_sak_length(
length += CS_ID_LEN;
length += cipher_suite_tbl[cs_index].sak_len + 8;
- } else {
- length = MKA_HDR_LEN;
}
- length = (length + 0x3) & ~0x3;
- return length;
+ return MKA_ALIGN_LENGTH(length);
}
@@ -1743,7 +1738,7 @@ ieee802_1x_mka_get_icv_length(struct ieee802_1x_mka_participant *participant)
length = sizeof(struct ieee802_1x_mka_icv_body);
length += mka_alg_tbl[participant->kay->mka_algindex].icv_len;
- return (length + 0x3) & ~0x3;
+ return MKA_ALIGN_LENGTH(length);
}