aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2015-09-07 19:56:40 (GMT)
committerJouni Malinen <j@w1.fi>2015-09-07 20:02:19 (GMT)
commit4b9a395e29878a739d8d21b4383268d83fc7710d (patch)
treefeb4d7d666380b7b064f83f7c2f8bcd77f6d4d96 /src
parentb664ef1c0d97dbf8b127408b4b63eb35e36aa5bb (diff)
downloadhostap-4b9a395e29878a739d8d21b4383268d83fc7710d.zip
hostap-4b9a395e29878a739d8d21b4383268d83fc7710d.tar.gz
hostap-4b9a395e29878a739d8d21b4383268d83fc7710d.tar.bz2
WPS: Reduce struct wps_parse_attr size
Use shorter variables for storing the attribute lengths and group these variables together to allow compiler to pack them more efficiently. This reduces the struct size from 960 bytes to 760 bytes in 64-bit builds. This reduces stack use in number of functions. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src')
-rw-r--r--src/wps/wps_attr_parse.h41
-rw-r--r--src/wps/wps_enrollee.c2
-rw-r--r--src/wps/wps_registrar.c5
3 files changed, 26 insertions, 22 deletions
diff --git a/src/wps/wps_attr_parse.h b/src/wps/wps_attr_parse.h
index 82c4739..8188fe9 100644
--- a/src/wps/wps_attr_parse.h
+++ b/src/wps/wps_attr_parse.h
@@ -59,43 +59,44 @@ struct wps_parse_attr {
/* variable length fields */
const u8 *manufacturer;
- size_t manufacturer_len;
const u8 *model_name;
- size_t model_name_len;
const u8 *model_number;
- size_t model_number_len;
const u8 *serial_number;
- size_t serial_number_len;
const u8 *dev_name;
- size_t dev_name_len;
const u8 *public_key;
- size_t public_key_len;
const u8 *encr_settings;
- size_t encr_settings_len;
const u8 *ssid; /* <= 32 octets */
- size_t ssid_len;
const u8 *network_key; /* <= 64 octets */
- size_t network_key_len;
const u8 *authorized_macs; /* <= 30 octets */
- size_t authorized_macs_len;
const u8 *sec_dev_type_list; /* <= 128 octets */
- size_t sec_dev_type_list_len;
const u8 *oob_dev_password; /* 38..54 octets */
- size_t oob_dev_password_len;
+ u16 manufacturer_len;
+ u16 model_name_len;
+ u16 model_number_len;
+ u16 serial_number_len;
+ u16 dev_name_len;
+ u16 public_key_len;
+ u16 encr_settings_len;
+ u16 ssid_len;
+ u16 network_key_len;
+ u16 authorized_macs_len;
+ u16 sec_dev_type_list_len;
+ u16 oob_dev_password_len;
/* attributes that can occur multiple times */
#define MAX_CRED_COUNT 10
- const u8 *cred[MAX_CRED_COUNT];
- size_t cred_len[MAX_CRED_COUNT];
- size_t num_cred;
-
#define MAX_REQ_DEV_TYPE_COUNT 10
- const u8 *req_dev_type[MAX_REQ_DEV_TYPE_COUNT];
- size_t num_req_dev_type;
+ unsigned int num_cred;
+ unsigned int num_req_dev_type;
+ unsigned int num_vendor_ext;
+
+ u16 cred_len[MAX_CRED_COUNT];
+ u16 vendor_ext_len[MAX_WPS_PARSE_VENDOR_EXT];
+
+ const u8 *cred[MAX_CRED_COUNT];
+ const u8 *req_dev_type[MAX_REQ_DEV_TYPE_COUNT];
const u8 *vendor_ext[MAX_WPS_PARSE_VENDOR_EXT];
- size_t vendor_ext_len[MAX_WPS_PARSE_VENDOR_EXT];
- size_t num_vendor_ext;
};
int wps_parse_msg(const struct wpabuf *msg, struct wps_parse_attr *attr);
diff --git a/src/wps/wps_enrollee.c b/src/wps/wps_enrollee.c
index 53b79e3..9321b72 100644
--- a/src/wps/wps_enrollee.c
+++ b/src/wps/wps_enrollee.c
@@ -759,7 +759,7 @@ static int wps_process_cred_e(struct wps_data *wps, const u8 *cred,
static int wps_process_creds(struct wps_data *wps, const u8 *cred[],
- size_t cred_len[], size_t num_cred, int wps2)
+ u16 cred_len[], unsigned int num_cred, int wps2)
{
size_t i;
int ok = 0;
diff --git a/src/wps/wps_registrar.c b/src/wps/wps_registrar.c
index 8bcf2b3..4ca3a42 100644
--- a/src/wps/wps_registrar.c
+++ b/src/wps/wps_registrar.c
@@ -2605,13 +2605,16 @@ static enum wps_process_res wps_process_m1(struct wps_data *wps,
token = wps_get_nfc_pw_token(
&wps->wps->registrar->nfc_pw_tokens, wps->dev_pw_id);
if (token && token->peer_pk_hash_known) {
+ size_t len;
+
wpa_printf(MSG_DEBUG, "WPS: Found matching NFC "
"Password Token");
dl_list_del(&token->list);
wps->nfc_pw_token = token;
addr[0] = attr->public_key;
- sha256_vector(1, addr, &attr->public_key_len, hash);
+ len = attr->public_key_len;
+ sha256_vector(1, addr, &len, hash);
if (os_memcmp_const(hash,
wps->nfc_pw_token->pubkey_hash,
WPS_OOB_PUBKEY_HASH_LEN) != 0) {