diff options
author | Jouni Malinen <j@w1.fi> | 2018-12-26 14:18:00 (GMT) |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2018-12-26 14:44:58 (GMT) |
commit | b452a76e540b0ef6ecf053941851c079c036bb20 (patch) | |
tree | 3e9d03bf12edc38b1226f74fc7e51c1f7352254f | |
parent | 7c3d1cc040d60cab56fb7558b359454ab6cb8744 (diff) | |
download | hostap-b452a76e540b0ef6ecf053941851c079c036bb20.zip hostap-b452a76e540b0ef6ecf053941851c079c036bb20.tar.gz hostap-b452a76e540b0ef6ecf053941851c079c036bb20.tar.bz2 |
mka: ICV calculation using 256-bit ICK
Add support for using AES-CMAC with 256-bit key (ICK) to calculate ICV.
Signed-off-by: Jouni Malinen <j@w1.fi>
-rw-r--r-- | src/pae/ieee802_1x_kay.c | 11 | ||||
-rw-r--r-- | src/pae/ieee802_1x_kay_i.h | 3 | ||||
-rw-r--r-- | src/pae/ieee802_1x_key.c | 19 | ||||
-rw-r--r-- | src/pae/ieee802_1x_key.h | 4 |
4 files changed, 24 insertions, 13 deletions
diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c index 7f38e0d..8176c9d 100644 --- a/src/pae/ieee802_1x_kay.c +++ b/src/pae/ieee802_1x_kay.c @@ -74,7 +74,7 @@ static struct mka_alg mka_alg_tbl[] = { .ckn_trfm = ieee802_1x_ckn_128bits_aes_cmac, .kek_trfm = ieee802_1x_kek_aes_cmac, .ick_trfm = ieee802_1x_ick_aes_cmac, - .icv_hash = ieee802_1x_icv_128bits_aes_cmac, + .icv_hash = ieee802_1x_icv_aes_cmac, .index = 1, }, @@ -1782,8 +1782,9 @@ ieee802_1x_mka_encode_icv_body(struct ieee802_1x_mka_participant *participant, } if (mka_alg_tbl[participant->kay->mka_algindex].icv_hash( - participant->ick.key, wpabuf_head(buf), buf->used, cmac)) { - wpa_printf(MSG_ERROR, "KaY, omac1_aes_128 failed"); + participant->ick.key, participant->ick.len, + wpabuf_head(buf), wpabuf_len(buf), cmac)) { + wpa_printf(MSG_ERROR, "KaY: failed to calculate ICV"); return -1; } @@ -3029,9 +3030,9 @@ static int ieee802_1x_kay_mkpdu_sanity_check(struct ieee802_1x_kay *kay, * packet body length. */ if (mka_alg_tbl[kay->mka_algindex].icv_hash( - participant->ick.key, + participant->ick.key, participant->ick.len, buf, len - mka_alg_tbl[kay->mka_algindex].icv_len, icv)) { - wpa_printf(MSG_ERROR, "KaY: omac1_aes_128 failed"); + wpa_printf(MSG_ERROR, "KaY: failed to calculate ICV"); return -1; } diff --git a/src/pae/ieee802_1x_kay_i.h b/src/pae/ieee802_1x_kay_i.h index b4eb9d2..7ae4355 100644 --- a/src/pae/ieee802_1x_kay_i.h +++ b/src/pae/ieee802_1x_kay_i.h @@ -80,7 +80,8 @@ struct mka_alg { int (*ick_trfm)(const u8 *cak, size_t cak_bytes, const u8 *ckn, size_t ckn_len, u8 *ick, size_t ick_bytes); - int (*icv_hash)(const u8 *ick, const u8 *msg, size_t msg_len, u8 *icv); + int (*icv_hash)(const u8 *ick, size_t ick_bytes, + const u8 *msg, size_t msg_len, u8 *icv); int index; /* index for configuring */ }; diff --git a/src/pae/ieee802_1x_key.c b/src/pae/ieee802_1x_key.c index fe27e2c..4fafba8 100644 --- a/src/pae/ieee802_1x_key.c +++ b/src/pae/ieee802_1x_key.c @@ -172,16 +172,25 @@ int ieee802_1x_ick_aes_cmac(const u8 *cak, size_t cak_bytes, const u8 *ckn, /** - * ieee802_1x_icv_128bits_aes_cmac + * ieee802_1x_icv_aes_cmac * * IEEE Std 802.1X-2010, 9.4.1 * ICV = AES-CMAC(ICK, M, 128) */ -int ieee802_1x_icv_128bits_aes_cmac(const u8 *ick, const u8 *msg, - size_t msg_bytes, u8 *icv) +int ieee802_1x_icv_aes_cmac(const u8 *ick, size_t ick_bytes, const u8 *msg, + size_t msg_bytes, u8 *icv) { - if (omac1_aes_128(ick, msg, msg_bytes, icv)) { - wpa_printf(MSG_ERROR, "MKA: omac1_aes_128 failed"); + int res; + + if (ick_bytes == 16) + res = omac1_aes_128(ick, msg, msg_bytes, icv); + else if (ick_bytes == 32) + res = omac1_aes_256(ick, msg, msg_bytes, icv); + else + return -1; + if (res) { + wpa_printf(MSG_ERROR, + "MKA: AES-CMAC failed for ICV calculation"); return -1; } return 0; diff --git a/src/pae/ieee802_1x_key.h b/src/pae/ieee802_1x_key.h index 70f912c..dc6603a 100644 --- a/src/pae/ieee802_1x_key.h +++ b/src/pae/ieee802_1x_key.h @@ -18,8 +18,8 @@ int ieee802_1x_kek_aes_cmac(const u8 *cak, size_t cak_bytes, const u8 *ckn, size_t ckn_bytes, u8 *kek, size_t kek_bytes); int ieee802_1x_ick_aes_cmac(const u8 *cak, size_t cak_bytes, const u8 *ckn, size_t ckn_bytes, u8 *ick, size_t ick_bytes); -int ieee802_1x_icv_128bits_aes_cmac(const u8 *ick, const u8 *msg, - size_t msg_bytes, u8 *icv); +int ieee802_1x_icv_aes_cmac(const u8 *ick, size_t ick_bytes, const u8 *msg, + size_t msg_bytes, u8 *icv); int ieee802_1x_sak_aes_cmac(const u8 *cak, size_t cak_bytes, const u8 *ctx, size_t ctx_bytes, u8 *sak, size_t sak_bytes); |