/** * eap_pax_initial_key_derivation - EAP-PAX initial key derivation * @mac_id: MAC ID (EAP_PAX_MAC_*) / currently, only HMAC_SHA1_128 is supported * @ak: Authentication Key * @e: Entropy * @mk: Buffer for the derived Master Key * @ck: Buffer for the derived Confirmation Key * @ick: Buffer for the derived Integrity Check Key * Returns: 0 on success, -1 on failure */ int eap_pax_initial_key_derivation(u8 mac_id, const u8 *ak, const u8 *e, u8 *mk, u8 *ck, u8 *ick) { wpa_printf(MSG_DEBUG, "EAP-PAX: initial key derivation"); if (eap_pax_kdf(mac_id, ak, EAP_PAX_AK_LEN, "Master Key", e, 2 * EAP_PAX_RAND_LEN, EAP_PAX_MK_LEN, mk) || eap_pax_kdf(mac_id, mk, EAP_PAX_MK_LEN, "Confirmation Key", e, 2 * EAP_PAX_RAND_LEN, EAP_PAX_CK_LEN, ck) || eap_pax_kdf(mac_id, mk, EAP_PAX_MK_LEN, "Integrity Check Key", e, 2 * EAP_PAX_RAND_LEN, EAP_PAX_ICK_LEN, ick)) return -1; wpa_hexdump_key(MSG_MSGDUMP, "EAP-PAX: AK", ak, EAP_PAX_AK_LEN); wpa_hexdump_key(MSG_MSGDUMP, "EAP-PAX: MK", mk, EAP_PAX_MK_LEN); wpa_hexdump_key(MSG_MSGDUMP, "EAP-PAX: CK", ck, EAP_PAX_CK_LEN); wpa_hexdump_key(MSG_MSGDUMP, "EAP-PAX: ICK", ick, EAP_PAX_ICK_LEN); return 0; }
static u8 * eap_pax_getKey(struct eap_sm *sm, void *priv, size_t *len) { struct eap_pax_data *data = priv; u8 *key; if (data->state != SUCCESS) return NULL; key = os_malloc(EAP_MSK_LEN); if (key == NULL) return NULL; *len = EAP_MSK_LEN; eap_pax_kdf(data->mac_id, data->mk, EAP_PAX_MK_LEN, "Master Session Key", data->rand.e, 2 * EAP_PAX_RAND_LEN, EAP_MSK_LEN, key); return key; }
static u8 *eap_pax_get_emsk(struct eap_sm *sm, void *priv, size_t *len) { struct eap_pax_data *data = priv; u8 *key; if (data->state != PAX_DONE) { return NULL; } key = os_malloc(EAP_EMSK_LEN); if (key == NULL) { return NULL; } *len = EAP_EMSK_LEN; eap_pax_kdf(data->mac_id, data->mk, EAP_PAX_MK_LEN, "Extended Master Session Key", data->rand.e, 2 * EAP_PAX_RAND_LEN, EAP_EMSK_LEN, key); return key; }