From: Jouni Malinen Date: Mon, 1 Apr 2013 16:30:34 +0000 (+0300) Subject: WPS: Fix use of pre-configured DH keys with multiple operations X-Git-Tag: aosp-kk-from-upstream~364 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49e160a58dbb043a539c212b54146a9775555289;p=thirdparty%2Fhostap.git WPS: Fix use of pre-configured DH keys with multiple operations wps_build_public_key() takes the dh_ctx into use and another attempt to use the same DH keys fails with wps->dh_ctx being set to NULL. Avoid this by using the DH parameters only if dh_ctx is valid. This fixes cases where a use of local pre-configured DH keys followed by an operating using peer DH keys would faild due to unexpected attempt to use local keys again. Signed-hostap: Jouni Malinen --- diff --git a/src/wps/wps_attr_build.c b/src/wps/wps_attr_build.c index a7e9ad7e8..edcc18cb6 100644 --- a/src/wps/wps_attr_build.c +++ b/src/wps/wps_attr_build.c @@ -25,12 +25,9 @@ int wps_build_public_key(struct wps_data *wps, struct wpabuf *msg) wpa_printf(MSG_DEBUG, "WPS: * Public Key"); wpabuf_free(wps->dh_privkey); wps->dh_privkey = NULL; - if (wps->dev_pw_id != DEV_PW_DEFAULT && wps->wps->dh_privkey) { + if (wps->dev_pw_id != DEV_PW_DEFAULT && wps->wps->dh_privkey && + wps->wps->dh_ctx) { wpa_printf(MSG_DEBUG, "WPS: Using pre-configured DH keys"); - if (wps->wps->dh_ctx == NULL) { - wpa_printf(MSG_DEBUG, "WPS: wps->wps->dh_ctx == NULL"); - return -1; - } if (wps->wps->dh_pubkey == NULL) { wpa_printf(MSG_DEBUG, "WPS: wps->wps->dh_pubkey == NULL");