From b1977a652dffa4e4f6f01e93dac59f8f29f17b14 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 15 Feb 2020 17:27:03 +0200 Subject: [PATCH] WPS: Use PMK_LEN instead of hardcoded 32 Signed-off-by: Jouni Malinen --- src/wps/wps_registrar.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/wps/wps_registrar.c b/src/wps/wps_registrar.c index da81d1adc..c07d42bdd 100644 --- a/src/wps/wps_registrar.c +++ b/src/wps/wps_registrar.c @@ -17,6 +17,7 @@ #include "crypto/sha256.h" #include "crypto/random.h" #include "common/ieee802_11_defs.h" +#include "common/wpa_common.h" #include "wps_i.h" #include "wps_dev_attr.h" #include "wps_upnp.h" @@ -1763,9 +1764,9 @@ int wps_build_cred(struct wps_data *wps, struct wpabuf *msg) wps->use_psk_key && wps->wps->psk_set) { char hex[65]; wpa_printf(MSG_DEBUG, "WPS: Use PSK format for Network Key"); - wpa_snprintf_hex(hex, sizeof(hex), wps->wps->psk, 32); - os_memcpy(wps->cred.key, hex, 32 * 2); - wps->cred.key_len = 32 * 2; + wpa_snprintf_hex(hex, sizeof(hex), wps->wps->psk, PMK_LEN); + os_memcpy(wps->cred.key, hex, PMK_LEN * 2); + wps->cred.key_len = PMK_LEN * 2; } else if (!wps->wps->registrar->force_per_enrollee_psk && wps->wps->network_key) { os_memcpy(wps->cred.key, wps->wps->network_key, @@ -1775,7 +1776,7 @@ int wps_build_cred(struct wps_data *wps, struct wpabuf *msg) char hex[65]; /* Generate a random per-device PSK */ os_free(wps->new_psk); - wps->new_psk_len = 32; + wps->new_psk_len = PMK_LEN; wps->new_psk = os_malloc(wps->new_psk_len); if (wps->new_psk == NULL) return -1;