static void * eap_sake_init(struct eap_sm *sm) { struct wpa_ssid *config = eap_get_config(sm); struct eap_sake_data *data; if (config == NULL) { wpa_printf(MSG_INFO, "EAP-SAKE: No configuration found"); return NULL; } if (!config->eappsk || config->eappsk_len != 2 * EAP_SAKE_ROOT_SECRET_LEN) { wpa_printf(MSG_INFO, "EAP-SAKE: No key (eappsk) of correct " "length configured"); return NULL; } data = os_zalloc(sizeof(*data)); if (data == NULL) return NULL; data->state = IDENTITY; if (config->nai) { data->peerid = os_malloc(config->nai_len); if (data->peerid == NULL) { eap_sake_deinit(sm, data); return NULL; } os_memcpy(data->peerid, config->nai, config->nai_len); data->peerid_len = config->nai_len; } os_memcpy(data->root_secret_a, config->eappsk, EAP_SAKE_ROOT_SECRET_LEN); os_memcpy(data->root_secret_b, config->eappsk + EAP_SAKE_ROOT_SECRET_LEN, EAP_SAKE_ROOT_SECRET_LEN); return data; }
static void * eap_sake_init(struct eap_sm *sm) { struct eap_sake_data *data; const u8 *identity, *password; size_t identity_len, password_len; password = eap_get_config_password(sm, &password_len); if (!password || password_len != 2 * EAP_SAKE_ROOT_SECRET_LEN) { wpa_printf(MSG_INFO, "EAP-SAKE: No key of correct length " "configured"); return NULL; } data = os_zalloc(sizeof(*data)); if (data == NULL) return NULL; data->state = IDENTITY; identity = eap_get_config_identity(sm, &identity_len); if (identity) { data->peerid = os_malloc(identity_len); if (data->peerid == NULL) { eap_sake_deinit(sm, data); return NULL; } os_memcpy(data->peerid, identity, identity_len); data->peerid_len = identity_len; } os_memcpy(data->root_secret_a, password, EAP_SAKE_ROOT_SECRET_LEN); os_memcpy(data->root_secret_b, password + EAP_SAKE_ROOT_SECRET_LEN, EAP_SAKE_ROOT_SECRET_LEN); return data; }