sae.c:wpa_key_mgmt_sae_ext_key:
  131|    552|{
  132|    552|	return !!(akm & (WPA_KEY_MGMT_SAE_EXT_KEY |
  ------------------
  |  |   52|    552|#define WPA_KEY_MGMT_SAE_EXT_KEY BIT(26)
  |  |  ------------------
  |  |  |  |  458|    552|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  133|    552|			 WPA_KEY_MGMT_FT_SAE_EXT_KEY));
  ------------------
  |  |   53|    552|#define WPA_KEY_MGMT_FT_SAE_EXT_KEY BIT(27)
  |  |  ------------------
  |  |  |  |  458|    552|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  134|    552|}

dragonfly_suitable_group:
   19|  1.16k|{
   20|       |	/* Enforce REVmd rules on which SAE groups are suitable for production
   21|       |	 * purposes: FFC groups whose prime is >= 3072 bits and ECC groups
   22|       |	 * defined over a prime field whose prime is >= 256 bits. Furthermore,
   23|       |	 * ECC groups defined over a characteristic 2 finite field and ECC
   24|       |	 * groups with a co-factor greater than 1 are not suitable. Disable
   25|       |	 * groups that use Brainpool curves as well for now since they leak more
   26|       |	 * timing information due to the prime not being close to a power of
   27|       |	 * two. */
   28|  1.16k|	return group == 19 || group == 20 || group == 21 ||
  ------------------
  |  Branch (28:9): [True: 1.16k, False: 0]
  |  Branch (28:24): [True: 0, False: 0]
  |  Branch (28:39): [True: 0, False: 0]
  ------------------
   29|      0|		(!ecc_only &&
  ------------------
  |  Branch (29:4): [True: 0, False: 0]
  ------------------
   30|      0|		 (group == 15 || group == 16 || group == 17 || group == 18));
  ------------------
  |  Branch (30:5): [True: 0, False: 0]
  |  Branch (30:20): [True: 0, False: 0]
  |  Branch (30:35): [True: 0, False: 0]
  |  Branch (30:50): [True: 0, False: 0]
  ------------------
   31|  1.16k|}

sae_set_group:
   27|  1.16k|{
   28|  1.16k|	struct sae_temporary_data *tmp;
   29|       |
   30|       |#ifdef CONFIG_TESTING_OPTIONS
   31|       |	/* Allow all groups for testing purposes in non-production builds. */
   32|       |#else /* CONFIG_TESTING_OPTIONS */
   33|  1.16k|	if (!dragonfly_suitable_group(group, 0)) {
  ------------------
  |  Branch (33:6): [True: 0, False: 1.16k]
  ------------------
   34|      0|		wpa_printf(MSG_DEBUG, "SAE: Reject unsuitable group %d", group);
   35|      0|		return -1;
   36|      0|	}
   37|  1.16k|#endif /* CONFIG_TESTING_OPTIONS */
   38|       |
   39|  1.16k|	sae_clear_data(sae);
   40|  1.16k|	tmp = sae->tmp = os_zalloc(sizeof(*tmp));
   41|  1.16k|	if (tmp == NULL)
  ------------------
  |  Branch (41:6): [True: 0, False: 1.16k]
  ------------------
   42|      0|		return -1;
   43|       |
   44|       |	/* First, check if this is an ECC group */
   45|  1.16k|	tmp->ec = crypto_ec_init(group);
   46|  1.16k|	if (tmp->ec) {
  ------------------
  |  Branch (46:6): [True: 1.16k, False: 0]
  ------------------
   47|  1.16k|		wpa_printf(MSG_DEBUG, "SAE: Selecting supported ECC group %d",
   48|  1.16k|			   group);
   49|  1.16k|		sae->group = group;
   50|  1.16k|		tmp->prime_len = crypto_ec_prime_len(tmp->ec);
   51|  1.16k|		tmp->prime = crypto_ec_get_prime(tmp->ec);
   52|  1.16k|		tmp->order_len = crypto_ec_order_len(tmp->ec);
   53|  1.16k|		tmp->order = crypto_ec_get_order(tmp->ec);
   54|  1.16k|		return 0;
   55|  1.16k|	}
   56|       |
   57|       |	/* Not an ECC group, check FFC */
   58|      0|	tmp->dh = dh_groups_get(group);
   59|      0|	if (tmp->dh) {
  ------------------
  |  Branch (59:6): [True: 0, False: 0]
  ------------------
   60|      0|		wpa_printf(MSG_DEBUG, "SAE: Selecting supported FFC group %d",
   61|      0|			   group);
   62|      0|		sae->group = group;
   63|      0|		tmp->prime_len = tmp->dh->prime_len;
   64|      0|		if (tmp->prime_len > SAE_MAX_PRIME_LEN) {
  ------------------
  |  |   16|      0|#define SAE_MAX_PRIME_LEN 512
  ------------------
  |  Branch (64:7): [True: 0, False: 0]
  ------------------
   65|      0|			sae_clear_data(sae);
   66|      0|			return -1;
   67|      0|		}
   68|       |
   69|      0|		tmp->prime_buf = crypto_bignum_init_set(tmp->dh->prime,
   70|      0|							tmp->prime_len);
   71|      0|		if (tmp->prime_buf == NULL) {
  ------------------
  |  Branch (71:7): [True: 0, False: 0]
  ------------------
   72|      0|			sae_clear_data(sae);
   73|      0|			return -1;
   74|      0|		}
   75|      0|		tmp->prime = tmp->prime_buf;
   76|       |
   77|      0|		tmp->order_len = tmp->dh->order_len;
   78|      0|		tmp->order_buf = crypto_bignum_init_set(tmp->dh->order,
   79|      0|							tmp->dh->order_len);
   80|      0|		if (tmp->order_buf == NULL) {
  ------------------
  |  Branch (80:7): [True: 0, False: 0]
  ------------------
   81|      0|			sae_clear_data(sae);
   82|      0|			return -1;
   83|      0|		}
   84|      0|		tmp->order = tmp->order_buf;
   85|       |
   86|      0|		return 0;
   87|      0|	}
   88|       |
   89|       |	/* Unsupported group */
   90|      0|	wpa_printf(MSG_DEBUG,
   91|      0|		   "SAE: Group %d not supported by the crypto library", group);
   92|      0|	return -1;
   93|      0|}
sae_clear_temp_data:
   97|  2.37k|{
   98|  2.37k|	struct sae_temporary_data *tmp;
   99|  2.37k|	if (sae == NULL || sae->tmp == NULL)
  ------------------
  |  Branch (99:6): [True: 0, False: 2.37k]
  |  Branch (99:21): [True: 1.21k, False: 1.16k]
  ------------------
  100|  1.21k|		return;
  101|  1.16k|	tmp = sae->tmp;
  102|  1.16k|	crypto_ec_deinit(tmp->ec);
  103|  1.16k|	crypto_bignum_deinit(tmp->prime_buf, 0);
  104|  1.16k|	crypto_bignum_deinit(tmp->order_buf, 0);
  105|  1.16k|	crypto_bignum_deinit(tmp->sae_rand, 1);
  106|  1.16k|	crypto_bignum_deinit(tmp->pwe_ffc, 1);
  107|  1.16k|	crypto_bignum_deinit(tmp->own_commit_scalar, 0);
  108|  1.16k|	crypto_bignum_deinit(tmp->own_commit_element_ffc, 0);
  109|  1.16k|	crypto_bignum_deinit(tmp->peer_commit_element_ffc, 0);
  110|  1.16k|	crypto_ec_point_deinit(tmp->pwe_ecc, 1);
  111|  1.16k|	crypto_ec_point_deinit(tmp->own_commit_element_ecc, 0);
  112|  1.16k|	crypto_ec_point_deinit(tmp->peer_commit_element_ecc, 0);
  113|  1.16k|	wpabuf_free(tmp->anti_clogging_token);
  114|  1.16k|	wpabuf_free(tmp->own_rejected_groups);
  115|  1.16k|	wpabuf_free(tmp->peer_rejected_groups);
  116|  1.16k|	os_free(tmp->pw_id);
  ------------------
  |  |  513|  1.16k|#define os_free(p) free((p))
  ------------------
  117|  1.16k|	os_free(tmp->parsed_pw_id);
  ------------------
  |  |  513|  1.16k|#define os_free(p) free((p))
  ------------------
  118|  1.16k|	os_free(tmp->dec_pw_id);
  ------------------
  |  |  513|  1.16k|#define os_free(p) free((p))
  ------------------
  119|  1.16k|	bin_clear_free(tmp, sizeof(*tmp));
  120|       |	sae->tmp = NULL;
  121|  1.16k|}
sae_clear_data:
  125|  2.37k|{
  126|  2.37k|	unsigned int no_pw_id;
  127|       |
  128|  2.37k|	if (sae == NULL)
  ------------------
  |  Branch (128:6): [True: 0, False: 2.37k]
  ------------------
  129|      0|		return;
  130|  2.37k|	sae_clear_temp_data(sae);
  131|  2.37k|	crypto_bignum_deinit(sae->peer_commit_scalar, 0);
  132|  2.37k|	crypto_bignum_deinit(sae->peer_commit_scalar_accepted, 0);
  133|  2.37k|	no_pw_id = sae->no_pw_id;
  134|  2.37k|	os_memset(sae, 0, sizeof(*sae));
  ------------------
  |  |  531|  2.37k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  135|  2.37k|	sae->no_pw_id = no_pw_id;
  136|  2.37k|}
sae_group_allowed:
 1741|  1.21k|{
 1742|  1.21k|	if (allowed_groups) {
  ------------------
  |  Branch (1742:6): [True: 1.21k, False: 0]
  ------------------
 1743|  1.21k|		int i;
 1744|  1.26k|		for (i = 0; allowed_groups[i] > 0; i++) {
  ------------------
  |  Branch (1744:15): [True: 1.21k, False: 50]
  ------------------
 1745|  1.21k|			if (allowed_groups[i] == group)
  ------------------
  |  Branch (1745:8): [True: 1.16k, False: 50]
  ------------------
 1746|  1.16k|				break;
 1747|  1.21k|		}
 1748|  1.21k|		if (allowed_groups[i] != group) {
  ------------------
  |  Branch (1748:7): [True: 46, False: 1.16k]
  ------------------
 1749|     46|			wpa_printf(MSG_DEBUG, "SAE: Proposed group %u not "
 1750|     46|				   "enabled in the current configuration",
 1751|     46|				   group);
 1752|     46|			return WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED;
  ------------------
  |  |  200|     46|#define WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED 77
  ------------------
 1753|     46|		}
 1754|  1.21k|	}
 1755|       |
 1756|  1.16k|	if (sae->state == SAE_COMMITTED && group != sae->group) {
  ------------------
  |  Branch (1756:6): [True: 0, False: 1.16k]
  |  Branch (1756:37): [True: 0, False: 0]
  ------------------
 1757|      0|		wpa_printf(MSG_DEBUG, "SAE: Do not allow group to be changed");
 1758|      0|		return WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED;
  ------------------
  |  |  200|      0|#define WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED 77
  ------------------
 1759|      0|	}
 1760|       |
 1761|  1.16k|	if (group != sae->group && sae_set_group(sae, group) < 0) {
  ------------------
  |  Branch (1761:6): [True: 1.16k, False: 4]
  |  Branch (1761:29): [True: 0, False: 1.16k]
  ------------------
 1762|      0|		wpa_printf(MSG_DEBUG, "SAE: Unsupported Finite Cyclic Group %u",
 1763|      0|			   group);
 1764|      0|		return WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED;
  ------------------
  |  |  200|      0|#define WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED 77
  ------------------
 1765|      0|	}
 1766|       |
 1767|  1.16k|	if (sae->tmp == NULL) {
  ------------------
  |  Branch (1767:6): [True: 4, False: 1.16k]
  ------------------
 1768|      4|		wpa_printf(MSG_DEBUG, "SAE: Group information not yet initialized");
 1769|      4|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      4|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1770|      4|	}
 1771|       |
 1772|  1.16k|	if (sae->tmp->dh && !allowed_groups) {
  ------------------
  |  Branch (1772:6): [True: 0, False: 1.16k]
  |  Branch (1772:22): [True: 0, False: 0]
  ------------------
 1773|      0|		wpa_printf(MSG_DEBUG, "SAE: Do not allow FFC group %u without "
 1774|      0|			   "explicit configuration enabling it", group);
 1775|      0|		return WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED;
  ------------------
  |  |  200|      0|#define WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED 77
  ------------------
 1776|      0|	}
 1777|       |
 1778|  1.16k|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|  1.16k|#define WLAN_STATUS_SUCCESS 0
  ------------------
 1779|  1.16k|}
sae_parse_commit:
 2162|  1.21k|{
 2163|  1.21k|	const u8 *pos = data, *end = data + len;
 2164|  1.21k|	u16 res;
 2165|       |
 2166|       |	/* Check Finite Cyclic Group */
 2167|  1.21k|	if (end - pos < 2)
  ------------------
  |  Branch (2167:6): [True: 4, False: 1.21k]
  ------------------
 2168|      4|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      4|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2169|  1.21k|	res = sae_group_allowed(sae, allowed_groups, WPA_GET_LE16(pos));
 2170|  1.21k|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|  1.21k|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2170:6): [True: 50, False: 1.16k]
  ------------------
 2171|     50|		return res;
 2172|  1.16k|	pos += 2;
 2173|       |
 2174|       |	/* Optional Anti-Clogging Token */
 2175|  1.16k|	sae_parse_commit_token(sae, &pos, end, token, token_len, h2e);
 2176|       |
 2177|       |	/* commit-scalar */
 2178|  1.16k|	res = sae_parse_commit_scalar(sae, &pos, end);
 2179|  1.16k|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|  1.16k|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2179:6): [True: 55, False: 1.10k]
  ------------------
 2180|     55|		return res;
 2181|       |
 2182|       |	/* commit-element */
 2183|  1.10k|	res = sae_parse_commit_element(sae, &pos, end);
 2184|  1.10k|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|  1.10k|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2184:6): [True: 501, False: 606]
  ------------------
 2185|    501|		return res;
 2186|       |
 2187|    606|	if (ie_offset)
  ------------------
  |  Branch (2187:6): [True: 0, False: 606]
  ------------------
 2188|      0|		*ie_offset = pos - data;
 2189|       |
 2190|    606|	if (end > pos)
  ------------------
  |  Branch (2190:6): [True: 603, False: 3]
  ------------------
 2191|    603|		wpa_hexdump(MSG_DEBUG,
 2192|    603|			    "SAE: Possible elements at the end of the frame",
 2193|    603|			    pos, end - pos);
 2194|       |
 2195|       |	/* Optional Password Identifier element */
 2196|    606|	res = sae_parse_password_identifier(sae, h2e, &pos, end);
 2197|    606|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|    606|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2197:6): [True: 17, False: 589]
  ------------------
 2198|     17|		return res;
 2199|       |
 2200|       |	/* Conditional Rejected Groups element */
 2201|    589|	if (h2e) {
  ------------------
  |  Branch (2201:6): [True: 407, False: 182]
  ------------------
 2202|    407|		res = sae_parse_rejected_groups(sae, &pos, end);
 2203|    407|		if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|    407|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2203:7): [True: 37, False: 370]
  ------------------
 2204|     37|			return res;
 2205|    407|	} else {
 2206|    182|		wpabuf_free(sae->tmp->peer_rejected_groups);
 2207|    182|		sae->tmp->peer_rejected_groups = NULL;
 2208|    182|	}
 2209|       |
 2210|       |	/* Optional Anti-Clogging Token Container element */
 2211|    552|	if (h2e)
  ------------------
  |  Branch (2211:6): [True: 370, False: 182]
  ------------------
 2212|    370|		sae_parse_token_container(sae, pos, end, token, token_len);
 2213|       |
 2214|       |	/* Conditional AKM Suite Selector element */
 2215|    552|	res = sae_parse_akm_suite_selector(sae, &pos, end);
 2216|    552|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|    552|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2216:6): [True: 0, False: 552]
  ------------------
 2217|      0|		return res;
 2218|       |
 2219|    552|	if (sae->own_akm_suite_selector &&
  ------------------
  |  Branch (2219:6): [True: 0, False: 552]
  ------------------
 2220|      0|	    sae->own_akm_suite_selector != sae->peer_akm_suite_selector) {
  ------------------
  |  Branch (2220:6): [True: 0, False: 0]
  ------------------
 2221|      0|		wpa_printf(MSG_DEBUG,
 2222|      0|			   "SAE: AKM suite selector mismatch: own=%08x peer=%08x",
 2223|      0|			   sae->own_akm_suite_selector,
 2224|      0|			   sae->peer_akm_suite_selector);
 2225|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2226|      0|	}
 2227|       |
 2228|    552|	if (!sae->akmp) {
  ------------------
  |  Branch (2228:6): [True: 552, False: 0]
  ------------------
 2229|    552|		if (sae->peer_akm_suite_selector ==
  ------------------
  |  Branch (2229:7): [True: 14, False: 538]
  ------------------
 2230|    552|		    RSN_AUTH_KEY_MGMT_SAE_EXT_KEY)
  ------------------
  |  |  106|    552|#define RSN_AUTH_KEY_MGMT_SAE_EXT_KEY RSN_SELECTOR(0x00, 0x0f, 0xac, 24)
  |  |  ------------------
  |  |  |  |   71|    552|	((((u32) (a)) << 24) | (((u32) (b)) << 16) | (((u32) (c)) << 8) | \
  |  |  |  |   72|    552|	 (u32) (d))
  |  |  ------------------
  ------------------
 2231|     14|			sae->akmp = WPA_KEY_MGMT_SAE_EXT_KEY;
  ------------------
  |  |   52|     14|#define WPA_KEY_MGMT_SAE_EXT_KEY BIT(26)
  |  |  ------------------
  |  |  |  |  458|     14|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 2232|    538|		else if (sae->peer_akm_suite_selector ==
  ------------------
  |  Branch (2232:12): [True: 10, False: 528]
  ------------------
 2233|    538|		    RSN_AUTH_KEY_MGMT_FT_SAE_EXT_KEY)
  ------------------
  |  |  107|    538|#define RSN_AUTH_KEY_MGMT_FT_SAE_EXT_KEY RSN_SELECTOR(0x00, 0x0f, 0xac, 25)
  |  |  ------------------
  |  |  |  |   71|    538|	((((u32) (a)) << 24) | (((u32) (b)) << 16) | (((u32) (c)) << 8) | \
  |  |  |  |   72|    538|	 (u32) (d))
  |  |  ------------------
  ------------------
 2234|     10|			sae->akmp = WPA_KEY_MGMT_FT_SAE_EXT_KEY;
  ------------------
  |  |   53|     10|#define WPA_KEY_MGMT_FT_SAE_EXT_KEY BIT(27)
  |  |  ------------------
  |  |  |  |  458|     10|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 2235|    552|	}
 2236|       |
 2237|    552|	if (wpa_key_mgmt_sae_ext_key(sae->akmp) && !h2e) {
  ------------------
  |  Branch (2237:6): [True: 24, False: 528]
  |  Branch (2237:45): [True: 4, False: 20]
  ------------------
 2238|      4|		wpa_printf(MSG_DEBUG,
 2239|      4|			   "SAE: Tried to use EXT-KEY AKM without H2E");
 2240|      4|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      4|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2241|      4|	}
 2242|       |
 2243|       |	/*
 2244|       |	 * Check whether peer-commit-scalar and PEER-COMMIT-ELEMENT are same as
 2245|       |	 * the values we sent which would be evidence of a reflection attack.
 2246|       |	 */
 2247|    548|	if (!sae->tmp->own_commit_scalar ||
  ------------------
  |  Branch (2247:6): [True: 548, False: 0]
  ------------------
 2248|      0|	    crypto_bignum_cmp(sae->tmp->own_commit_scalar,
  ------------------
  |  Branch (2248:6): [True: 0, False: 0]
  ------------------
 2249|      0|			      sae->peer_commit_scalar) != 0 ||
 2250|      0|	    (sae->tmp->dh &&
  ------------------
  |  Branch (2250:7): [True: 0, False: 0]
  ------------------
 2251|      0|	     (!sae->tmp->own_commit_element_ffc ||
  ------------------
  |  Branch (2251:8): [True: 0, False: 0]
  ------------------
 2252|      0|	      crypto_bignum_cmp(sae->tmp->own_commit_element_ffc,
  ------------------
  |  Branch (2252:8): [True: 0, False: 0]
  ------------------
 2253|      0|				sae->tmp->peer_commit_element_ffc) != 0)) ||
 2254|      0|	    (sae->tmp->ec &&
  ------------------
  |  Branch (2254:7): [True: 0, False: 0]
  ------------------
 2255|      0|	     (!sae->tmp->own_commit_element_ecc ||
  ------------------
  |  Branch (2255:8): [True: 0, False: 0]
  ------------------
 2256|      0|	      crypto_ec_point_cmp(sae->tmp->ec,
  ------------------
  |  Branch (2256:8): [True: 0, False: 0]
  ------------------
 2257|      0|				  sae->tmp->own_commit_element_ecc,
 2258|      0|				  sae->tmp->peer_commit_element_ecc) != 0)))
 2259|    548|		return WLAN_STATUS_SUCCESS; /* scalars/elements are different */
  ------------------
  |  |  134|    548|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2260|       |
 2261|       |	/*
 2262|       |	 * This is a reflection attack - return special value to trigger caller
 2263|       |	 * to silently discard the frame instead of replying with a specific
 2264|       |	 * status code.
 2265|       |	 */
 2266|      0|	return SAE_SILENTLY_DISCARD;
  ------------------
  |  |   28|      0|#define SAE_SILENTLY_DISCARD 65535
  ------------------
 2267|    548|}
sae.c:sae_parse_commit_token:
 1825|  1.16k|{
 1826|  1.16k|	size_t scalar_elem_len, tlen;
 1827|       |
 1828|  1.16k|	if (token)
  ------------------
  |  Branch (1828:6): [True: 1.16k, False: 0]
  ------------------
 1829|  1.16k|		*token = NULL;
 1830|  1.16k|	if (token_len)
  ------------------
  |  Branch (1830:6): [True: 1.16k, False: 0]
  ------------------
 1831|  1.16k|		*token_len = 0;
 1832|       |
 1833|  1.16k|	if (h2e)
  ------------------
  |  Branch (1833:6): [True: 581, False: 581]
  ------------------
 1834|    581|		return; /* No Anti-Clogging Token field outside container IE */
 1835|       |
 1836|    581|	scalar_elem_len = (sae->tmp->ec ? 3 : 2) * sae->tmp->prime_len;
  ------------------
  |  Branch (1836:21): [True: 581, False: 0]
  ------------------
 1837|    581|	if (scalar_elem_len >= (size_t) (end - *pos))
  ------------------
  |  Branch (1837:6): [True: 142, False: 439]
  ------------------
 1838|    142|		return; /* No extra data beyond peer scalar and element */
 1839|       |
 1840|    439|	tlen = end - (*pos + scalar_elem_len);
 1841|       |
 1842|    439|	if (tlen < SHA256_MAC_LEN) {
  ------------------
  |  |   12|    439|#define SHA256_MAC_LEN 32
  ------------------
  |  Branch (1842:6): [True: 202, False: 237]
  ------------------
 1843|    202|		wpa_printf(MSG_DEBUG,
 1844|    202|			   "SAE: Too short optional data (%u octets) to include our Anti-Clogging Token",
 1845|    202|			   (unsigned int) tlen);
 1846|    202|		return;
 1847|    202|	}
 1848|       |
 1849|    237|	wpa_hexdump(MSG_DEBUG, "SAE: Anti-Clogging Token", *pos, tlen);
 1850|    237|	if (token)
  ------------------
  |  Branch (1850:6): [True: 237, False: 0]
  ------------------
 1851|    237|		*token = *pos;
 1852|    237|	if (token_len)
  ------------------
  |  Branch (1852:6): [True: 237, False: 0]
  ------------------
 1853|    237|		*token_len = tlen;
 1854|    237|	*pos += tlen;
 1855|    237|}
sae.c:sae_parse_commit_scalar:
 1875|  1.16k|{
 1876|  1.16k|	struct crypto_bignum *peer_scalar;
 1877|       |
 1878|  1.16k|	if (sae->tmp->prime_len > end - *pos) {
  ------------------
  |  Branch (1878:6): [True: 12, False: 1.15k]
  ------------------
 1879|     12|		wpa_printf(MSG_DEBUG, "SAE: Not enough data for scalar");
 1880|     12|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|     12|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1881|     12|	}
 1882|       |
 1883|  1.15k|	peer_scalar = crypto_bignum_init_set(*pos, sae->tmp->prime_len);
 1884|  1.15k|	if (peer_scalar == NULL)
  ------------------
  |  Branch (1884:6): [True: 0, False: 1.15k]
  ------------------
 1885|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1886|       |
 1887|       |	/*
 1888|       |	 * IEEE Std 802.11-2012, 11.3.8.6.1: If there is a protocol instance for
 1889|       |	 * the peer and it is in Authenticated state, the new Commit Message
 1890|       |	 * shall be dropped if the peer-scalar is identical to the one used in
 1891|       |	 * the existing protocol instance.
 1892|       |	 */
 1893|  1.15k|	if (sae->state == SAE_ACCEPTED && sae->peer_commit_scalar_accepted &&
  ------------------
  |  Branch (1893:6): [True: 0, False: 1.15k]
  |  Branch (1893:36): [True: 0, False: 0]
  ------------------
 1894|      0|	    crypto_bignum_cmp(sae->peer_commit_scalar_accepted,
  ------------------
  |  Branch (1894:6): [True: 0, False: 0]
  ------------------
 1895|      0|			      peer_scalar) == 0) {
 1896|      0|		wpa_printf(MSG_DEBUG, "SAE: Do not accept re-use of previous "
 1897|      0|			   "peer-commit-scalar");
 1898|      0|		crypto_bignum_deinit(peer_scalar, 0);
 1899|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1900|      0|	}
 1901|       |
 1902|       |	/* 1 < scalar < r */
 1903|  1.15k|	if (crypto_bignum_is_zero(peer_scalar) ||
  ------------------
  |  Branch (1903:6): [True: 22, False: 1.12k]
  ------------------
 1904|  1.12k|	    crypto_bignum_is_one(peer_scalar) ||
  ------------------
  |  Branch (1904:6): [True: 7, False: 1.12k]
  ------------------
 1905|  1.12k|	    crypto_bignum_cmp(peer_scalar, sae->tmp->order) >= 0) {
  ------------------
  |  Branch (1905:6): [True: 14, False: 1.10k]
  ------------------
 1906|     43|		wpa_printf(MSG_DEBUG, "SAE: Invalid peer scalar");
 1907|     43|		crypto_bignum_deinit(peer_scalar, 0);
 1908|     43|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|     43|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1909|     43|	}
 1910|       |
 1911|       |
 1912|  1.10k|	crypto_bignum_deinit(sae->peer_commit_scalar, 0);
 1913|  1.10k|	sae->peer_commit_scalar = peer_scalar;
 1914|  1.10k|	wpa_hexdump(MSG_DEBUG, "SAE: Peer commit-scalar",
 1915|  1.10k|		    *pos, sae->tmp->prime_len);
 1916|  1.10k|	*pos += sae->tmp->prime_len;
 1917|       |
 1918|  1.10k|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|  1.10k|#define WLAN_STATUS_SUCCESS 0
  ------------------
 1919|  1.15k|}
sae.c:sae_parse_commit_element:
 2023|  1.10k|{
 2024|  1.10k|	if (sae->tmp->dh)
  ------------------
  |  Branch (2024:6): [True: 0, False: 1.10k]
  ------------------
 2025|      0|		return sae_parse_commit_element_ffc(sae, pos, end);
 2026|  1.10k|	return sae_parse_commit_element_ecc(sae, pos, end);
 2027|  1.10k|}
sae.c:sae_parse_commit_element_ecc:
 1924|  1.10k|{
 1925|  1.10k|	u8 prime[SAE_MAX_ECC_PRIME_LEN];
 1926|       |
 1927|  1.10k|	if (2 * sae->tmp->prime_len > end - *pos) {
  ------------------
  |  Branch (1927:6): [True: 24, False: 1.08k]
  ------------------
 1928|     24|		wpa_printf(MSG_DEBUG, "SAE: Not enough data for "
 1929|     24|			   "commit-element");
 1930|     24|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|     24|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1931|     24|	}
 1932|       |
 1933|  1.08k|	if (crypto_bignum_to_bin(sae->tmp->prime, prime, sizeof(prime),
  ------------------
  |  Branch (1933:6): [True: 0, False: 1.08k]
  ------------------
 1934|  1.08k|				 sae->tmp->prime_len) < 0)
 1935|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1936|       |
 1937|       |	/* element x and y coordinates < p */
 1938|  1.08k|	if (os_memcmp(*pos, prime, sae->tmp->prime_len) >= 0 ||
  ------------------
  |  |  534|  1.08k|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (1938:6): [True: 102, False: 981]
  ------------------
 1939|    981|	    os_memcmp(*pos + sae->tmp->prime_len, prime,
  ------------------
  |  |  534|    981|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (1939:6): [True: 115, False: 866]
  ------------------
 1940|    981|		      sae->tmp->prime_len) >= 0) {
 1941|    217|		wpa_printf(MSG_DEBUG, "SAE: Invalid coordinates in peer "
 1942|    217|			   "element");
 1943|    217|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|    217|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1944|    217|	}
 1945|       |
 1946|    866|	wpa_hexdump(MSG_DEBUG, "SAE: Peer commit-element(x)",
 1947|    866|		    *pos, sae->tmp->prime_len);
 1948|    866|	wpa_hexdump(MSG_DEBUG, "SAE: Peer commit-element(y)",
 1949|    866|		    *pos + sae->tmp->prime_len, sae->tmp->prime_len);
 1950|       |
 1951|    866|	crypto_ec_point_deinit(sae->tmp->peer_commit_element_ecc, 0);
 1952|    866|	sae->tmp->peer_commit_element_ecc =
 1953|    866|		crypto_ec_point_from_bin(sae->tmp->ec, *pos);
 1954|    866|	if (!sae->tmp->peer_commit_element_ecc) {
  ------------------
  |  Branch (1954:6): [True: 260, False: 606]
  ------------------
 1955|    260|		wpa_printf(MSG_DEBUG, "SAE: Peer element is not a valid point");
 1956|    260|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|    260|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1957|    260|	}
 1958|       |
 1959|    606|	if (!crypto_ec_point_is_on_curve(sae->tmp->ec,
  ------------------
  |  Branch (1959:6): [True: 0, False: 606]
  ------------------
 1960|    606|					 sae->tmp->peer_commit_element_ecc)) {
 1961|      0|		wpa_printf(MSG_DEBUG, "SAE: Peer element is not on curve");
 1962|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1963|      0|	}
 1964|       |
 1965|    606|	*pos += 2 * sae->tmp->prime_len;
 1966|       |
 1967|    606|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|    606|#define WLAN_STATUS_SUCCESS 0
  ------------------
 1968|    606|}
sae.c:sae_parse_password_identifier:
 2032|    606|{
 2033|    606|	const u8 *epos;
 2034|    606|	u8 len;
 2035|       |
 2036|    606|	if (!sae_is_password_id_elem(*pos, end)) {
  ------------------
  |  Branch (2036:6): [True: 511, False: 95]
  ------------------
 2037|    511|		if (sae->tmp->pw_id) {
  ------------------
  |  Branch (2037:7): [True: 0, False: 511]
  ------------------
 2038|      0|			wpa_printf(MSG_DEBUG,
 2039|      0|				   "SAE: No Password Identifier included, but expected one (%s)",
 2040|      0|				   sae->tmp->pw_id);
 2041|      0|			return WLAN_STATUS_UNKNOWN_PASSWORD_IDENTIFIER;
  ------------------
  |  |  231|      0|#define WLAN_STATUS_UNKNOWN_PASSWORD_IDENTIFIER 123
  ------------------
 2042|      0|		}
 2043|    511|		os_free(sae->tmp->parsed_pw_id);
  ------------------
  |  |  513|    511|#define os_free(p) free((p))
  ------------------
 2044|    511|		sae->tmp->parsed_pw_id = NULL;
 2045|    511|		sae->tmp->parsed_pw_id_len = 0;
 2046|    511|		return WLAN_STATUS_SUCCESS; /* No Password Identifier */
  ------------------
  |  |  134|    511|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2047|    511|	}
 2048|       |
 2049|     95|	epos = *pos;
 2050|     95|	epos++; /* skip IE type */
 2051|     95|	len = *epos++; /* IE length */
 2052|     95|	if (len > end - epos || len < 1)
  ------------------
  |  Branch (2052:6): [True: 0, False: 95]
  |  Branch (2052:26): [True: 0, False: 95]
  ------------------
 2053|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2054|     95|	epos++; /* skip ext ID */
 2055|     95|	len--;
 2056|       |
 2057|     95|	if (!h2e) {
  ------------------
  |  Branch (2057:6): [True: 17, False: 78]
  ------------------
 2058|     17|		wpa_printf(MSG_DEBUG,
 2059|     17|			   "SAE: Password Identifier included, but H2E is not used");
 2060|     17|		return WLAN_STATUS_UNKNOWN_PASSWORD_IDENTIFIER;
  ------------------
  |  |  231|     17|#define WLAN_STATUS_UNKNOWN_PASSWORD_IDENTIFIER 123
  ------------------
 2061|     17|	}
 2062|       |
 2063|     78|	if (sae->no_pw_id) {
  ------------------
  |  Branch (2063:6): [True: 0, False: 78]
  ------------------
 2064|      0|		wpa_printf(MSG_DEBUG,
 2065|      0|			   "SAE: Password Identifier included, but none has been enabled");
 2066|      0|		return WLAN_STATUS_UNKNOWN_PASSWORD_IDENTIFIER;
  ------------------
  |  |  231|      0|#define WLAN_STATUS_UNKNOWN_PASSWORD_IDENTIFIER 123
  ------------------
 2067|      0|	}
 2068|       |
 2069|     78|	if (sae->tmp->pw_id &&
  ------------------
  |  Branch (2069:6): [True: 0, False: 78]
  ------------------
 2070|      0|	    (len != sae->tmp->pw_id_len ||
  ------------------
  |  Branch (2070:7): [True: 0, False: 0]
  ------------------
 2071|      0|	     os_memcmp(sae->tmp->pw_id, epos, len) != 0)) {
  ------------------
  |  |  534|      0|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (2071:7): [True: 0, False: 0]
  ------------------
 2072|      0|		wpa_printf(MSG_DEBUG,
 2073|      0|			   "SAE: The included Password Identifier does not match the expected one (%s)",
 2074|      0|			   sae->tmp->pw_id);
 2075|      0|		return WLAN_STATUS_UNKNOWN_PASSWORD_IDENTIFIER;
  ------------------
  |  |  231|      0|#define WLAN_STATUS_UNKNOWN_PASSWORD_IDENTIFIER 123
  ------------------
 2076|      0|	}
 2077|       |
 2078|     78|	os_free(sae->tmp->parsed_pw_id);
  ------------------
  |  |  513|     78|#define os_free(p) free((p))
  ------------------
 2079|     78|	sae->tmp->parsed_pw_id = os_malloc(len + 1);
  ------------------
  |  |  507|     78|#define os_malloc(s) malloc((s))
  ------------------
 2080|     78|	if (!sae->tmp->parsed_pw_id) {
  ------------------
  |  Branch (2080:6): [True: 0, False: 78]
  ------------------
 2081|      0|		sae->tmp->parsed_pw_id_len = 0;
 2082|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2083|      0|	}
 2084|     78|	os_memcpy(sae->tmp->parsed_pw_id, epos, len);
  ------------------
  |  |  525|     78|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 2085|     78|	sae->tmp->parsed_pw_id_len = len;
 2086|     78|	sae->tmp->parsed_pw_id[len] = '\0';
 2087|     78|	wpa_hexdump_ascii(MSG_DEBUG, "SAE: Received Password Identifier",
 2088|     78|			  sae->tmp->parsed_pw_id, len);
 2089|     78|	*pos = epos + len;
 2090|     78|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|     78|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2091|     78|}
sae.c:sae_is_password_id_elem:
 1783|    606|{
 1784|    606|	return end - pos >= 3 &&
  ------------------
  |  Branch (1784:9): [True: 599, False: 7]
  ------------------
 1785|    599|		pos[0] == WLAN_EID_EXTENSION &&
  ------------------
  |  |  505|  1.20k|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (1785:3): [True: 549, False: 50]
  ------------------
 1786|    549|		pos[1] >= 1 &&
  ------------------
  |  Branch (1786:3): [True: 544, False: 5]
  ------------------
 1787|    544|		end - pos - 2 >= pos[1] &&
  ------------------
  |  Branch (1787:3): [True: 507, False: 37]
  ------------------
 1788|    507|		pos[2] == WLAN_EID_EXT_PASSWORD_IDENTIFIER;
  ------------------
  |  |  523|    507|#define WLAN_EID_EXT_PASSWORD_IDENTIFIER 33
  ------------------
  |  Branch (1788:3): [True: 95, False: 412]
  ------------------
 1789|    606|}
sae.c:sae_parse_rejected_groups:
 2096|    407|{
 2097|    407|	const u8 *epos;
 2098|    407|	u8 len;
 2099|       |
 2100|    407|	if (!sae_is_rejected_groups_elem(*pos, end)) {
  ------------------
  |  Branch (2100:6): [True: 339, False: 68]
  ------------------
 2101|    339|		wpabuf_free(sae->tmp->peer_rejected_groups);
 2102|    339|		sae->tmp->peer_rejected_groups = NULL;
 2103|    339|		return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|    339|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2104|    339|	}
 2105|       |
 2106|     68|	epos = *pos;
 2107|     68|	epos++; /* skip IE type */
 2108|     68|	len = *epos++; /* IE length */
 2109|     68|	if (len > end - epos || len < 1)
  ------------------
  |  Branch (2109:6): [True: 0, False: 68]
  |  Branch (2109:26): [True: 0, False: 68]
  ------------------
 2110|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2111|     68|	epos++; /* skip ext ID */
 2112|     68|	len--;
 2113|     68|	if (len & 1) {
  ------------------
  |  Branch (2113:6): [True: 37, False: 31]
  ------------------
 2114|     37|		wpa_printf(MSG_DEBUG,
 2115|     37|			   "SAE: Invalid length of the Rejected Groups element payload: %u",
 2116|     37|			   len);
 2117|     37|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|     37|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2118|     37|	}
 2119|       |
 2120|     31|	wpabuf_free(sae->tmp->peer_rejected_groups);
 2121|     31|	sae->tmp->peer_rejected_groups = wpabuf_alloc(len);
 2122|     31|	if (!sae->tmp->peer_rejected_groups)
  ------------------
  |  Branch (2122:6): [True: 0, False: 31]
  ------------------
 2123|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2124|     31|	wpabuf_put_data(sae->tmp->peer_rejected_groups, epos, len);
 2125|     31|	wpa_hexdump_buf(MSG_DEBUG, "SAE: Received Rejected Groups list",
 2126|     31|			sae->tmp->peer_rejected_groups);
 2127|     31|	*pos = epos + len;
 2128|     31|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|     31|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2129|     31|}
sae.c:sae_is_rejected_groups_elem:
 1793|    407|{
 1794|    407|	return end - pos >= 3 &&
  ------------------
  |  Branch (1794:9): [True: 386, False: 21]
  ------------------
 1795|    386|		pos[0] == WLAN_EID_EXTENSION &&
  ------------------
  |  |  505|    793|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (1795:3): [True: 344, False: 42]
  ------------------
 1796|    344|		pos[1] >= 2 &&
  ------------------
  |  Branch (1796:3): [True: 293, False: 51]
  ------------------
 1797|    293|		end - pos - 2 >= pos[1] &&
  ------------------
  |  Branch (1797:3): [True: 270, False: 23]
  ------------------
 1798|    270|		pos[2] == WLAN_EID_EXT_REJECTED_GROUPS;
  ------------------
  |  |  540|    270|#define WLAN_EID_EXT_REJECTED_GROUPS 92
  ------------------
  |  Branch (1798:3): [True: 68, False: 202]
  ------------------
 1799|    407|}
sae.c:sae_parse_token_container:
 1861|    370|{
 1862|    370|	if (!sae_is_token_container_elem(pos, end))
  ------------------
  |  Branch (1862:6): [True: 367, False: 3]
  ------------------
 1863|    367|		return;
 1864|      3|	if (token)
  ------------------
  |  Branch (1864:6): [True: 3, False: 0]
  ------------------
 1865|      3|		*token = pos + 3;
 1866|      3|	if (token_len)
  ------------------
  |  Branch (1866:6): [True: 3, False: 0]
  ------------------
 1867|      3|		*token_len = pos[1] - 1;
 1868|      3|	wpa_hexdump(MSG_DEBUG, "SAE: Anti-Clogging Token (in container)",
 1869|      3|		    pos + 3, pos[1] - 1);
 1870|      3|}
sae.c:sae_is_token_container_elem:
 1803|    370|{
 1804|    370|	return end - pos >= 3 &&
  ------------------
  |  Branch (1804:9): [True: 333, False: 37]
  ------------------
 1805|    333|		pos[0] == WLAN_EID_EXTENSION &&
  ------------------
  |  |  505|    703|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (1805:3): [True: 278, False: 55]
  ------------------
 1806|    278|		pos[1] >= 1 &&
  ------------------
  |  Branch (1806:3): [True: 275, False: 3]
  ------------------
 1807|    275|		end - pos - 2 >= pos[1] &&
  ------------------
  |  Branch (1807:3): [True: 252, False: 23]
  ------------------
 1808|    252|		pos[2] == WLAN_EID_EXT_ANTI_CLOGGING_TOKEN;
  ------------------
  |  |  541|    252|#define WLAN_EID_EXT_ANTI_CLOGGING_TOKEN 93
  ------------------
  |  Branch (1808:3): [True: 3, False: 249]
  ------------------
 1809|    370|}
sae.c:sae_parse_akm_suite_selector:
 2134|    552|{
 2135|    552|	const u8 *epos;
 2136|    552|	u8 len;
 2137|       |
 2138|    552|	if (!sae_is_akm_suite_selector_elem(*pos, end))
  ------------------
  |  Branch (2138:6): [True: 327, False: 225]
  ------------------
 2139|    327|		return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|    327|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2140|       |
 2141|    225|	epos = *pos;
 2142|    225|	epos++; /* skip IE type */
 2143|    225|	len = *epos++; /* IE length */
 2144|    225|	if (len > end - epos || len < 1)
  ------------------
  |  Branch (2144:6): [True: 0, False: 225]
  |  Branch (2144:26): [True: 0, False: 225]
  ------------------
 2145|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2146|    225|	epos++; /* skip ext ID */
 2147|    225|	len--;
 2148|       |
 2149|    225|	if (len < RSN_SELECTOR_LEN)
  ------------------
  |  |   67|    225|#define RSN_SELECTOR_LEN 4
  ------------------
  |  Branch (2149:6): [True: 0, False: 225]
  ------------------
 2150|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2151|    225|	sae->peer_akm_suite_selector = RSN_SELECTOR_GET(epos);
  ------------------
  |  |  171|    225|#define RSN_SELECTOR_GET(a) WPA_GET_BE32((const u8 *) (a))
  ------------------
 2152|    225|	wpa_printf(MSG_DEBUG, "SAE: Received AKM Suite Selector: %08x",
 2153|    225|		   sae->peer_akm_suite_selector);
 2154|    225|	*pos = epos + len;
 2155|    225|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|    225|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2156|    225|}
sae.c:sae_is_akm_suite_selector_elem:
 1813|    552|{
 1814|    552|	return end - pos >= 2 + 1 + RSN_SELECTOR_LEN &&
  ------------------
  |  |   67|  1.10k|#define RSN_SELECTOR_LEN 4
  ------------------
  |  Branch (1814:9): [True: 397, False: 155]
  ------------------
 1815|    397|		pos[0] == WLAN_EID_EXTENSION &&
  ------------------
  |  |  505|    949|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (1815:3): [True: 343, False: 54]
  ------------------
 1816|    343|		pos[1] >= 1 + RSN_SELECTOR_LEN &&
  ------------------
  |  |   67|    895|#define RSN_SELECTOR_LEN 4
  ------------------
  |  Branch (1816:3): [True: 296, False: 47]
  ------------------
 1817|    296|		end - pos - 2 >= pos[1] &&
  ------------------
  |  Branch (1817:3): [True: 274, False: 22]
  ------------------
 1818|    274|		pos[2] == WLAN_EID_EXT_AKM_SUITE_SELECTOR;
  ------------------
  |  |  549|    274|#define WLAN_EID_EXT_AKM_SUITE_SELECTOR 114
  ------------------
  |  Branch (1818:3): [True: 225, False: 49]
  ------------------
 1819|    552|}

crypto_bignum_init_set:
 2091|  1.15k|{
 2092|  1.15k|	BIGNUM *bn;
 2093|       |
 2094|  1.15k|	if (TEST_FAIL())
  ------------------
  |  |  729|  1.15k|#define TEST_FAIL() testing_test_fail(NULL, false)
  |  |  ------------------
  |  |  |  Branch (729:21): [True: 0, False: 1.15k]
  |  |  ------------------
  ------------------
 2095|      0|		return NULL;
 2096|       |
 2097|  1.15k|	bn = BN_bin2bn(buf, len, NULL);
 2098|  1.15k|	return (struct crypto_bignum *) bn;
 2099|  1.15k|}
crypto_bignum_deinit:
 2121|  14.0k|{
 2122|  14.0k|	if (clear)
  ------------------
  |  Branch (2122:6): [True: 2.32k, False: 11.7k]
  ------------------
 2123|  2.32k|		BN_clear_free((BIGNUM *) n);
 2124|  11.7k|	else
 2125|  11.7k|		BN_free((BIGNUM *) n);
 2126|  14.0k|}
crypto_bignum_to_bin:
 2131|  1.08k|{
 2132|  1.08k|	int num_bytes, offset;
 2133|       |
 2134|  1.08k|	if (TEST_FAIL())
  ------------------
  |  |  729|  1.08k|#define TEST_FAIL() testing_test_fail(NULL, false)
  |  |  ------------------
  |  |  |  Branch (729:21): [True: 0, False: 1.08k]
  |  |  ------------------
  ------------------
 2135|      0|		return -1;
 2136|       |
 2137|  1.08k|	if (padlen > buflen)
  ------------------
  |  Branch (2137:6): [True: 0, False: 1.08k]
  ------------------
 2138|      0|		return -1;
 2139|       |
 2140|  1.08k|	if (padlen) {
  ------------------
  |  Branch (2140:6): [True: 1.08k, False: 0]
  ------------------
 2141|       |#ifdef OPENSSL_IS_BORINGSSL
 2142|       |		if (BN_bn2bin_padded(buf, padlen, (const BIGNUM *) a) == 0)
 2143|       |			return -1;
 2144|       |		return padlen;
 2145|       |#else /* OPENSSL_IS_BORINGSSL */
 2146|  1.08k|#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
 2147|  1.08k|		return BN_bn2binpad((const BIGNUM *) a, buf, padlen);
 2148|  1.08k|#endif
 2149|  1.08k|#endif
 2150|  1.08k|	}
 2151|       |
 2152|      0|	num_bytes = BN_num_bytes((const BIGNUM *) a);
 2153|      0|	if ((size_t) num_bytes > buflen)
  ------------------
  |  Branch (2153:6): [True: 0, False: 0]
  ------------------
 2154|      0|		return -1;
 2155|      0|	if (padlen > (size_t) num_bytes)
  ------------------
  |  Branch (2155:6): [True: 0, False: 0]
  ------------------
 2156|      0|		offset = padlen - num_bytes;
 2157|      0|	else
 2158|      0|		offset = 0;
 2159|       |
 2160|      0|	os_memset(buf, 0, offset);
  ------------------
  |  |  531|      0|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 2161|      0|	BN_bn2bin((const BIGNUM *) a, buf + offset);
 2162|       |
 2163|      0|	return num_bytes + offset;
 2164|      0|}
crypto_bignum_cmp:
 2361|  1.12k|{
 2362|  1.12k|	return BN_cmp((const BIGNUM *) a, (const BIGNUM *) b);
 2363|  1.12k|}
crypto_bignum_is_zero:
 2367|  1.15k|{
 2368|  1.15k|	return BN_is_zero((const BIGNUM *) a);
 2369|  1.15k|}
crypto_bignum_is_one:
 2373|  1.12k|{
 2374|  1.12k|	return BN_is_one((const BIGNUM *) a);
 2375|  1.12k|}
crypto_ec_init:
 2514|  1.16k|{
 2515|  1.16k|	struct crypto_ec *e;
 2516|  1.16k|	int nid;
 2517|       |
 2518|  1.16k|	nid = crypto_ec_group_2_nid(group);
 2519|  1.16k|	if (nid < 0)
  ------------------
  |  Branch (2519:6): [True: 0, False: 1.16k]
  ------------------
 2520|      0|		return NULL;
 2521|       |
 2522|  1.16k|	e = os_zalloc(sizeof(*e));
 2523|  1.16k|	if (e == NULL)
  ------------------
  |  Branch (2523:6): [True: 0, False: 1.16k]
  ------------------
 2524|      0|		return NULL;
 2525|       |
 2526|  1.16k|	e->nid = nid;
 2527|  1.16k|	e->iana_group = group;
 2528|  1.16k|	e->bnctx = BN_CTX_new();
 2529|  1.16k|	e->group = EC_GROUP_new_by_curve_name(nid);
 2530|  1.16k|	e->prime = BN_new();
 2531|  1.16k|	e->order = BN_new();
 2532|  1.16k|	e->a = BN_new();
 2533|  1.16k|	e->b = BN_new();
 2534|  1.16k|	if (e->group == NULL || e->bnctx == NULL || e->prime == NULL ||
  ------------------
  |  Branch (2534:6): [True: 0, False: 1.16k]
  |  Branch (2534:26): [True: 0, False: 1.16k]
  |  Branch (2534:46): [True: 0, False: 1.16k]
  ------------------
 2535|  1.16k|	    e->order == NULL || e->a == NULL || e->b == NULL ||
  ------------------
  |  Branch (2535:6): [True: 0, False: 1.16k]
  |  Branch (2535:26): [True: 0, False: 1.16k]
  |  Branch (2535:42): [True: 0, False: 1.16k]
  ------------------
 2536|  1.16k|	    !EC_GROUP_get_curve(e->group, e->prime, e->a, e->b, e->bnctx) ||
  ------------------
  |  Branch (2536:6): [True: 0, False: 1.16k]
  ------------------
 2537|  1.16k|	    !EC_GROUP_get_order(e->group, e->order, e->bnctx)) {
  ------------------
  |  Branch (2537:6): [True: 0, False: 1.16k]
  ------------------
 2538|      0|		crypto_ec_deinit(e);
 2539|      0|		e = NULL;
 2540|      0|	}
 2541|       |
 2542|  1.16k|	return e;
 2543|  1.16k|}
crypto_ec_deinit:
 2547|  1.16k|{
 2548|  1.16k|	if (e == NULL)
  ------------------
  |  Branch (2548:6): [True: 0, False: 1.16k]
  ------------------
 2549|      0|		return;
 2550|  1.16k|	BN_clear_free(e->b);
 2551|  1.16k|	BN_clear_free(e->a);
 2552|  1.16k|	BN_clear_free(e->order);
 2553|  1.16k|	BN_clear_free(e->prime);
 2554|  1.16k|	EC_GROUP_free(e->group);
 2555|  1.16k|	BN_CTX_free(e->bnctx);
 2556|  1.16k|	os_free(e);
  ------------------
  |  |  513|  1.16k|#define os_free(p) free((p))
  ------------------
 2557|  1.16k|}
crypto_ec_prime_len:
 2571|  1.16k|{
 2572|       |	return BN_num_bytes(e->prime);
 2573|  1.16k|}
crypto_ec_order_len:
 2583|  1.16k|{
 2584|       |	return BN_num_bytes(e->order);
 2585|  1.16k|}
crypto_ec_get_prime:
 2589|  1.16k|{
 2590|  1.16k|	return (const struct crypto_bignum *) e->prime;
 2591|  1.16k|}
crypto_ec_get_order:
 2595|  1.16k|{
 2596|  1.16k|	return (const struct crypto_bignum *) e->order;
 2597|  1.16k|}
crypto_ec_point_deinit:
 2620|  4.35k|{
 2621|  4.35k|	if (clear)
  ------------------
  |  Branch (2621:6): [True: 1.16k, False: 3.19k]
  ------------------
 2622|  1.16k|		EC_POINT_clear_free((EC_POINT *) p);
 2623|  3.19k|	else
 2624|  3.19k|		EC_POINT_free((EC_POINT *) p);
 2625|  4.35k|}
crypto_ec_point_from_bin:
 2675|    866|{
 2676|    866|	BIGNUM *x, *y;
 2677|    866|	EC_POINT *elem;
 2678|    866|	int len = BN_num_bytes(e->prime);
 2679|       |
 2680|    866|	if (TEST_FAIL())
  ------------------
  |  |  729|    866|#define TEST_FAIL() testing_test_fail(NULL, false)
  |  |  ------------------
  |  |  |  Branch (729:21): [True: 0, False: 866]
  |  |  ------------------
  ------------------
 2681|      0|		return NULL;
 2682|       |
 2683|    866|	x = BN_bin2bn(val, len, NULL);
 2684|    866|	y = BN_bin2bn(val + len, len, NULL);
 2685|    866|	elem = EC_POINT_new(e->group);
 2686|    866|	if (x == NULL || y == NULL || elem == NULL) {
  ------------------
  |  Branch (2686:6): [True: 0, False: 866]
  |  Branch (2686:19): [True: 0, False: 866]
  |  Branch (2686:32): [True: 0, False: 866]
  ------------------
 2687|      0|		BN_clear_free(x);
 2688|      0|		BN_clear_free(y);
 2689|      0|		EC_POINT_clear_free(elem);
 2690|      0|		return NULL;
 2691|      0|	}
 2692|       |
 2693|    866|	if (!EC_POINT_set_affine_coordinates(e->group, elem, x, y, e->bnctx)) {
  ------------------
  |  Branch (2693:6): [True: 260, False: 606]
  ------------------
 2694|    260|		EC_POINT_clear_free(elem);
 2695|    260|		elem = NULL;
 2696|    260|	}
 2697|       |
 2698|    866|	BN_clear_free(x);
 2699|    866|	BN_clear_free(y);
 2700|       |
 2701|    866|	return (struct crypto_ec_point *) elem;
 2702|    866|}
crypto_ec_point_is_on_curve:
 2769|    606|{
 2770|    606|	return EC_POINT_is_on_curve(e->group, (const EC_POINT *) p,
 2771|    606|				    e->bnctx) == 1;
 2772|    606|}
crypto_openssl.c:crypto_ec_group_2_nid:
 2440|  1.16k|{
 2441|       |	/* Map from IANA registry for IKE D-H groups to OpenSSL NID */
 2442|  1.16k|	switch (group) {
 2443|  1.16k|	case 19:
  ------------------
  |  Branch (2443:2): [True: 1.16k, False: 0]
  ------------------
 2444|  1.16k|		return NID_X9_62_prime256v1;
 2445|      0|	case 20:
  ------------------
  |  Branch (2445:2): [True: 0, False: 1.16k]
  ------------------
 2446|      0|		return NID_secp384r1;
 2447|      0|	case 21:
  ------------------
  |  Branch (2447:2): [True: 0, False: 1.16k]
  ------------------
 2448|      0|		return NID_secp521r1;
 2449|      0|	case 25:
  ------------------
  |  Branch (2449:2): [True: 0, False: 1.16k]
  ------------------
 2450|      0|		return NID_X9_62_prime192v1;
 2451|      0|	case 26:
  ------------------
  |  Branch (2451:2): [True: 0, False: 1.16k]
  ------------------
 2452|      0|		return NID_secp224r1;
 2453|      0|#ifdef NID_brainpoolP224r1
 2454|      0|	case 27:
  ------------------
  |  Branch (2454:2): [True: 0, False: 1.16k]
  ------------------
 2455|      0|		return NID_brainpoolP224r1;
 2456|      0|#endif /* NID_brainpoolP224r1 */
 2457|      0|#ifdef NID_brainpoolP256r1
 2458|      0|	case 28:
  ------------------
  |  Branch (2458:2): [True: 0, False: 1.16k]
  ------------------
 2459|      0|		return NID_brainpoolP256r1;
 2460|      0|#endif /* NID_brainpoolP256r1 */
 2461|      0|#ifdef NID_brainpoolP384r1
 2462|      0|	case 29:
  ------------------
  |  Branch (2462:2): [True: 0, False: 1.16k]
  ------------------
 2463|      0|		return NID_brainpoolP384r1;
 2464|      0|#endif /* NID_brainpoolP384r1 */
 2465|      0|#ifdef NID_brainpoolP512r1
 2466|      0|	case 30:
  ------------------
  |  Branch (2466:2): [True: 0, False: 1.16k]
  ------------------
 2467|      0|		return NID_brainpoolP512r1;
 2468|      0|#endif /* NID_brainpoolP512r1 */
 2469|      0|	default:
  ------------------
  |  Branch (2469:2): [True: 0, False: 1.16k]
  ------------------
 2470|      0|		return -1;
 2471|  1.16k|	}
 2472|  1.16k|}

bin_clear_free:
 1047|  1.16k|{
 1048|  1.16k|	if (bin) {
  ------------------
  |  Branch (1048:6): [True: 1.16k, False: 0]
  ------------------
 1049|  1.16k|		forced_memzero(bin, len);
 1050|  1.16k|		os_free(bin);
  ------------------
  |  |  513|  1.16k|#define os_free(p) free((p))
  ------------------
 1051|  1.16k|	}
 1052|  1.16k|}
forced_memzero:
 1343|  1.16k|{
 1344|  1.16k|	memset_func(ptr, 0, len);
 1345|  1.16k|	if (len)
  ------------------
  |  Branch (1345:6): [True: 1.16k, False: 0]
  ------------------
 1346|  1.16k|		forced_memzero_val = ((u8 *) ptr)[0];
 1347|  1.16k|}

sae.c:WPA_GET_LE16:
  225|  1.21k|{
  226|  1.21k|	return (a[1] << 8) | a[0];
  227|  1.21k|}
sae.c:WPA_GET_BE32:
  260|    225|{
  261|    225|	return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3];
  262|    225|}

crypto_openssl.c:testing_test_fail:
  738|  3.09k|{
  739|  3.09k|	return 0;
  740|  3.09k|}

os_get_random:
  280|    608|{
  281|    608|#ifdef TEST_FUZZ
  282|    608|	size_t i;
  283|       |
  284|  3.04k|	for (i = 0; i < len; i++)
  ------------------
  |  Branch (284:14): [True: 2.43k, False: 608]
  ------------------
  285|  2.43k|		buf[i] = i & 0xff;
  286|    608|	return 0;
  287|       |#else /* TEST_FUZZ */
  288|       |	FILE *f;
  289|       |	size_t rc;
  290|       |
  291|       |	if (TEST_FAIL())
  292|       |		return -1;
  293|       |
  294|       |	f = fopen("/dev/urandom", "rb");
  295|       |	if (f == NULL) {
  296|       |		printf("Could not open /dev/urandom.\n");
  297|       |		return -1;
  298|       |	}
  299|       |
  300|       |	rc = fread(buf, 1, len, f);
  301|       |	fclose(f);
  302|       |
  303|       |	return rc != len ? -1 : 0;
  304|       |#endif /* TEST_FUZZ */
  305|    608|}
os_program_init:
  361|    608|{
  362|    608|	unsigned int seed;
  363|       |
  364|       |#ifdef ANDROID
  365|       |	/*
  366|       |	 * We ignore errors here since errors are normal if we
  367|       |	 * are already running as non-root.
  368|       |	 */
  369|       |#ifdef ANDROID_SETGROUPS_OVERRIDE
  370|       |	gid_t groups[] = { ANDROID_SETGROUPS_OVERRIDE };
  371|       |#else /* ANDROID_SETGROUPS_OVERRIDE */
  372|       |	gid_t groups[] = { AID_INET, AID_WIFI, AID_KEYSTORE };
  373|       |#endif /* ANDROID_SETGROUPS_OVERRIDE */
  374|       |	struct __user_cap_header_struct header;
  375|       |	struct __user_cap_data_struct cap;
  376|       |
  377|       |	setgroups(ARRAY_SIZE(groups), groups);
  378|       |
  379|       |	prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
  380|       |
  381|       |	setgid(AID_WIFI);
  382|       |	setuid(AID_WIFI);
  383|       |
  384|       |	header.version = _LINUX_CAPABILITY_VERSION;
  385|       |	header.pid = 0;
  386|       |	cap.effective = cap.permitted =
  387|       |		(1 << CAP_NET_ADMIN) | (1 << CAP_NET_RAW);
  388|       |	cap.inheritable = 0;
  389|       |	capset(&header, &cap);
  390|       |#endif /* ANDROID */
  391|       |
  392|    608|	if (os_get_random((unsigned char *) &seed, sizeof(seed)) == 0)
  ------------------
  |  Branch (392:6): [True: 608, False: 0]
  ------------------
  393|    608|		srandom(seed);
  394|       |
  395|    608|	return 0;
  396|    608|}
os_program_deinit:
  400|    608|{
  401|       |#ifdef WPA_TRACE
  402|       |	struct os_alloc_trace *a;
  403|       |	unsigned long total = 0;
  404|       |	dl_list_for_each(a, &alloc_list, struct os_alloc_trace, list) {
  405|       |		total += a->len;
  406|       |		if (a->magic != ALLOC_MAGIC) {
  407|       |			wpa_printf(MSG_INFO, "MEMLEAK[%p]: invalid magic 0x%x "
  408|       |				   "len %lu",
  409|       |				   a, a->magic, (unsigned long) a->len);
  410|       |			continue;
  411|       |		}
  412|       |		wpa_printf(MSG_INFO, "MEMLEAK[%p]: len %lu",
  413|       |			   a, (unsigned long) a->len);
  414|       |		wpa_trace_dump("memleak", a);
  415|       |	}
  416|       |	if (total)
  417|       |		wpa_printf(MSG_INFO, "MEMLEAK: total %lu bytes",
  418|       |			   (unsigned long) total);
  419|       |	wpa_trace_deinit();
  420|       |#endif /* WPA_TRACE */
  421|    608|}
os_zalloc:
  507|  2.35k|{
  508|  2.35k|	return calloc(1, size);
  509|  2.35k|}

wpa_printf:
  224|  3.46k|{
  225|  3.46k|	va_list ap;
  226|       |
  227|  3.46k|	if (level >= wpa_debug_level) {
  ------------------
  |  Branch (227:6): [True: 0, False: 3.46k]
  ------------------
  228|       |#ifdef CONFIG_ANDROID_LOG
  229|       |		va_start(ap, fmt);
  230|       |		__android_log_vprint(wpa_to_android_level(level),
  231|       |				     ANDROID_LOG_NAME, fmt, ap);
  232|       |		va_end(ap);
  233|       |#else /* CONFIG_ANDROID_LOG */
  234|       |#ifdef CONFIG_DEBUG_SYSLOG
  235|       |		if (wpa_debug_syslog) {
  236|       |			va_start(ap, fmt);
  237|       |			vsyslog(syslog_priority(level), fmt, ap);
  238|       |			va_end(ap);
  239|       |		}
  240|       |#endif /* CONFIG_DEBUG_SYSLOG */
  241|      0|		wpa_debug_print_timestamp();
  242|      0|#ifdef CONFIG_DEBUG_FILE
  243|      0|		if (out_file) {
  ------------------
  |  Branch (243:7): [True: 0, False: 0]
  ------------------
  244|      0|			va_start(ap, fmt);
  245|      0|			vfprintf(out_file, fmt, ap);
  246|      0|			fprintf(out_file, "\n");
  247|      0|			va_end(ap);
  248|      0|		}
  249|      0|#endif /* CONFIG_DEBUG_FILE */
  250|      0|		if (!wpa_debug_syslog && !out_file) {
  ------------------
  |  Branch (250:7): [True: 0, False: 0]
  |  Branch (250:28): [True: 0, False: 0]
  ------------------
  251|      0|			va_start(ap, fmt);
  252|      0|			vprintf(fmt, ap);
  253|      0|			printf("\n");
  254|      0|			va_end(ap);
  255|      0|		}
  256|      0|#endif /* CONFIG_ANDROID_LOG */
  257|      0|	}
  258|       |
  259|       |#ifdef CONFIG_DEBUG_LINUX_TRACING
  260|       |	if (wpa_debug_tracing_file != NULL) {
  261|       |		va_start(ap, fmt);
  262|       |		fprintf(wpa_debug_tracing_file, WPAS_TRACE_PFX, level);
  263|       |		vfprintf(wpa_debug_tracing_file, fmt, ap);
  264|       |		fprintf(wpa_debug_tracing_file, "\n");
  265|       |		fflush(wpa_debug_tracing_file);
  266|       |		va_end(ap);
  267|       |	}
  268|       |#endif /* CONFIG_DEBUG_LINUX_TRACING */
  269|  3.46k|}
wpa_hexdump:
  400|  3.71k|{
  401|  3.71k|	_wpa_hexdump(level, title, buf, len, 1, 0);
  402|  3.71k|}
wpa_hexdump_ascii:
  526|     78|{
  527|     78|	_wpa_hexdump_ascii(level, title, buf, len, 1);
  528|     78|}
wpa_debug.c:_wpa_hexdump:
  274|  3.71k|{
  275|  3.71k|	size_t i;
  276|       |
  277|       |#ifdef CONFIG_DEBUG_LINUX_TRACING
  278|       |	if (wpa_debug_tracing_file != NULL) {
  279|       |		fprintf(wpa_debug_tracing_file,
  280|       |			WPAS_TRACE_PFX "%s - hexdump(len=%lu):",
  281|       |			level, title, (unsigned long) len);
  282|       |		if (buf == NULL) {
  283|       |			fprintf(wpa_debug_tracing_file, " [NULL]\n");
  284|       |		} else if (!show) {
  285|       |			fprintf(wpa_debug_tracing_file, " [REMOVED]\n");
  286|       |		} else {
  287|       |			for (i = 0; i < len; i++)
  288|       |				fprintf(wpa_debug_tracing_file,
  289|       |					" %02x", buf[i]);
  290|       |		}
  291|       |		fflush(wpa_debug_tracing_file);
  292|       |	}
  293|       |#endif /* CONFIG_DEBUG_LINUX_TRACING */
  294|       |
  295|  3.71k|	if (level < wpa_debug_level)
  ------------------
  |  Branch (295:6): [True: 3.71k, False: 0]
  ------------------
  296|  3.71k|		return;
  297|       |#ifdef CONFIG_ANDROID_LOG
  298|       |	{
  299|       |		const char *display;
  300|       |		char *strbuf = NULL;
  301|       |		size_t slen = len;
  302|       |		if (buf == NULL) {
  303|       |			display = " [NULL]";
  304|       |		} else if (len == 0) {
  305|       |			display = "";
  306|       |		} else if (show && len) {
  307|       |			/* Limit debug message length for Android log */
  308|       |			if (slen > 32)
  309|       |				slen = 32;
  310|       |			strbuf = os_malloc(1 + 3 * slen);
  311|       |			if (strbuf == NULL) {
  312|       |				wpa_printf(MSG_ERROR, "wpa_hexdump: Failed to "
  313|       |					   "allocate message buffer");
  314|       |				return;
  315|       |			}
  316|       |
  317|       |			for (i = 0; i < slen; i++)
  318|       |				os_snprintf(&strbuf[i * 3], 4, " %02x",
  319|       |					    buf[i]);
  320|       |
  321|       |			display = strbuf;
  322|       |		} else {
  323|       |			display = " [REMOVED]";
  324|       |		}
  325|       |
  326|       |		__android_log_print(wpa_to_android_level(level),
  327|       |				    ANDROID_LOG_NAME,
  328|       |				    "%s - hexdump(len=%lu):%s%s",
  329|       |				    title, (long unsigned int) len, display,
  330|       |				    len > slen ? " ..." : "");
  331|       |		bin_clear_free(strbuf, 1 + 3 * slen);
  332|       |		return;
  333|       |	}
  334|       |#else /* CONFIG_ANDROID_LOG */
  335|       |#ifdef CONFIG_DEBUG_SYSLOG
  336|       |	if (wpa_debug_syslog) {
  337|       |		const char *display;
  338|       |		char *strbuf = NULL;
  339|       |
  340|       |		if (buf == NULL) {
  341|       |			display = " [NULL]";
  342|       |		} else if (len == 0) {
  343|       |			display = "";
  344|       |		} else if (show && len) {
  345|       |			strbuf = os_malloc(1 + 3 * len);
  346|       |			if (strbuf == NULL) {
  347|       |				wpa_printf(MSG_ERROR, "wpa_hexdump: Failed to "
  348|       |					   "allocate message buffer");
  349|       |				return;
  350|       |			}
  351|       |
  352|       |			for (i = 0; i < len; i++)
  353|       |				os_snprintf(&strbuf[i * 3], 4, " %02x",
  354|       |					    buf[i]);
  355|       |
  356|       |			display = strbuf;
  357|       |		} else {
  358|       |			display = " [REMOVED]";
  359|       |		}
  360|       |
  361|       |		syslog(syslog_priority(level), "%s - hexdump(len=%lu):%s",
  362|       |		       title, (unsigned long) len, display);
  363|       |		bin_clear_free(strbuf, 1 + 3 * len);
  364|       |		if (only_syslog)
  365|       |			return;
  366|       |	}
  367|       |#endif /* CONFIG_DEBUG_SYSLOG */
  368|      0|	wpa_debug_print_timestamp();
  369|      0|#ifdef CONFIG_DEBUG_FILE
  370|      0|	if (out_file) {
  ------------------
  |  Branch (370:6): [True: 0, False: 0]
  ------------------
  371|      0|		fprintf(out_file, "%s - hexdump(len=%lu):",
  372|      0|			title, (unsigned long) len);
  373|      0|		if (buf == NULL) {
  ------------------
  |  Branch (373:7): [True: 0, False: 0]
  ------------------
  374|      0|			fprintf(out_file, " [NULL]");
  375|      0|		} else if (show) {
  ------------------
  |  Branch (375:14): [True: 0, False: 0]
  ------------------
  376|      0|			for (i = 0; i < len; i++)
  ------------------
  |  Branch (376:16): [True: 0, False: 0]
  ------------------
  377|      0|				fprintf(out_file, " %02x", buf[i]);
  378|      0|		} else {
  379|      0|			fprintf(out_file, " [REMOVED]");
  380|      0|		}
  381|      0|		fprintf(out_file, "\n");
  382|      0|	}
  383|      0|#endif /* CONFIG_DEBUG_FILE */
  384|      0|	if (!wpa_debug_syslog && !out_file) {
  ------------------
  |  Branch (384:6): [True: 0, False: 0]
  |  Branch (384:27): [True: 0, False: 0]
  ------------------
  385|      0|		printf("%s - hexdump(len=%lu):", title, (unsigned long) len);
  386|      0|		if (buf == NULL) {
  ------------------
  |  Branch (386:7): [True: 0, False: 0]
  ------------------
  387|      0|			printf(" [NULL]");
  388|      0|		} else if (show) {
  ------------------
  |  Branch (388:14): [True: 0, False: 0]
  ------------------
  389|      0|			for (i = 0; i < len; i++)
  ------------------
  |  Branch (389:16): [True: 0, False: 0]
  ------------------
  390|      0|				printf(" %02x", buf[i]);
  391|      0|		} else {
  392|      0|			printf(" [REMOVED]");
  393|      0|		}
  394|      0|		printf("\n");
  395|      0|	}
  396|      0|#endif /* CONFIG_ANDROID_LOG */
  397|      0|}
wpa_debug.c:_wpa_hexdump_ascii:
  413|     78|{
  414|     78|	size_t i, llen;
  415|     78|	const u8 *pos = buf;
  416|     78|	const size_t line_len = 16;
  417|       |
  418|       |#ifdef CONFIG_DEBUG_LINUX_TRACING
  419|       |	if (wpa_debug_tracing_file != NULL) {
  420|       |		fprintf(wpa_debug_tracing_file,
  421|       |			WPAS_TRACE_PFX "%s - hexdump_ascii(len=%lu):",
  422|       |			level, title, (unsigned long) len);
  423|       |		if (buf == NULL) {
  424|       |			fprintf(wpa_debug_tracing_file, " [NULL]\n");
  425|       |		} else if (!show) {
  426|       |			fprintf(wpa_debug_tracing_file, " [REMOVED]\n");
  427|       |		} else {
  428|       |			/* can do ascii processing in userspace */
  429|       |			for (i = 0; i < len; i++)
  430|       |				fprintf(wpa_debug_tracing_file,
  431|       |					" %02x", pos[i]);
  432|       |		}
  433|       |		fflush(wpa_debug_tracing_file);
  434|       |	}
  435|       |#endif /* CONFIG_DEBUG_LINUX_TRACING */
  436|       |
  437|     78|	if (level < wpa_debug_level)
  ------------------
  |  Branch (437:6): [True: 78, False: 0]
  ------------------
  438|     78|		return;
  439|       |#ifdef CONFIG_ANDROID_LOG
  440|       |	_wpa_hexdump(level, title, buf, len, show, 0);
  441|       |#else /* CONFIG_ANDROID_LOG */
  442|       |#ifdef CONFIG_DEBUG_SYSLOG
  443|       |	if (wpa_debug_syslog)
  444|       |		_wpa_hexdump(level, title, buf, len, show, 1);
  445|       |#endif /* CONFIG_DEBUG_SYSLOG */
  446|      0|	wpa_debug_print_timestamp();
  447|      0|#ifdef CONFIG_DEBUG_FILE
  448|      0|	if (out_file) {
  ------------------
  |  Branch (448:6): [True: 0, False: 0]
  ------------------
  449|      0|		if (!show) {
  ------------------
  |  Branch (449:7): [True: 0, False: 0]
  ------------------
  450|      0|			fprintf(out_file,
  451|      0|				"%s - hexdump_ascii(len=%lu): [REMOVED]\n",
  452|      0|				title, (unsigned long) len);
  453|      0|			goto file_done;
  454|      0|		}
  455|      0|		if (buf == NULL) {
  ------------------
  |  Branch (455:7): [True: 0, False: 0]
  ------------------
  456|      0|			fprintf(out_file,
  457|      0|				"%s - hexdump_ascii(len=%lu): [NULL]\n",
  458|      0|				title, (unsigned long) len);
  459|      0|			goto file_done;
  460|      0|		}
  461|      0|		fprintf(out_file, "%s - hexdump_ascii(len=%lu):\n",
  462|      0|			title, (unsigned long) len);
  463|      0|		while (len) {
  ------------------
  |  Branch (463:10): [True: 0, False: 0]
  ------------------
  464|      0|			llen = len > line_len ? line_len : len;
  ------------------
  |  Branch (464:11): [True: 0, False: 0]
  ------------------
  465|      0|			fprintf(out_file, "    ");
  466|      0|			for (i = 0; i < llen; i++)
  ------------------
  |  Branch (466:16): [True: 0, False: 0]
  ------------------
  467|      0|				fprintf(out_file, " %02x", pos[i]);
  468|      0|			for (i = llen; i < line_len; i++)
  ------------------
  |  Branch (468:19): [True: 0, False: 0]
  ------------------
  469|      0|				fprintf(out_file, "   ");
  470|      0|			fprintf(out_file, "   ");
  471|      0|			for (i = 0; i < llen; i++) {
  ------------------
  |  Branch (471:16): [True: 0, False: 0]
  ------------------
  472|      0|				if (isprint(pos[i]))
  ------------------
  |  Branch (472:9): [True: 0, False: 0]
  ------------------
  473|      0|					fprintf(out_file, "%c", pos[i]);
  474|      0|				else
  475|      0|					fprintf(out_file, "_");
  476|      0|			}
  477|      0|			for (i = llen; i < line_len; i++)
  ------------------
  |  Branch (477:19): [True: 0, False: 0]
  ------------------
  478|      0|				fprintf(out_file, " ");
  479|      0|			fprintf(out_file, "\n");
  480|      0|			pos += llen;
  481|      0|			len -= llen;
  482|      0|		}
  483|      0|	}
  484|      0|file_done:
  485|      0|#endif /* CONFIG_DEBUG_FILE */
  486|      0|	if (!wpa_debug_syslog && !out_file) {
  ------------------
  |  Branch (486:6): [True: 0, False: 0]
  |  Branch (486:27): [True: 0, False: 0]
  ------------------
  487|      0|		if (!show) {
  ------------------
  |  Branch (487:7): [True: 0, False: 0]
  ------------------
  488|      0|			printf("%s - hexdump_ascii(len=%lu): [REMOVED]\n",
  489|      0|			       title, (unsigned long) len);
  490|      0|			return;
  491|      0|		}
  492|      0|		if (buf == NULL) {
  ------------------
  |  Branch (492:7): [True: 0, False: 0]
  ------------------
  493|      0|			printf("%s - hexdump_ascii(len=%lu): [NULL]\n",
  494|      0|			       title, (unsigned long) len);
  495|      0|			return;
  496|      0|		}
  497|      0|		printf("%s - hexdump_ascii(len=%lu):\n", title,
  498|      0|		       (unsigned long) len);
  499|      0|		while (len) {
  ------------------
  |  Branch (499:10): [True: 0, False: 0]
  ------------------
  500|      0|			llen = len > line_len ? line_len : len;
  ------------------
  |  Branch (500:11): [True: 0, False: 0]
  ------------------
  501|      0|			printf("    ");
  502|      0|			for (i = 0; i < llen; i++)
  ------------------
  |  Branch (502:16): [True: 0, False: 0]
  ------------------
  503|      0|				printf(" %02x", pos[i]);
  504|      0|			for (i = llen; i < line_len; i++)
  ------------------
  |  Branch (504:19): [True: 0, False: 0]
  ------------------
  505|      0|				printf("   ");
  506|      0|			printf("   ");
  507|      0|			for (i = 0; i < llen; i++) {
  ------------------
  |  Branch (507:16): [True: 0, False: 0]
  ------------------
  508|      0|				if (isprint(pos[i]))
  ------------------
  |  Branch (508:9): [True: 0, False: 0]
  ------------------
  509|      0|					printf("%c", pos[i]);
  510|      0|				else
  511|      0|					printf("_");
  512|      0|			}
  513|      0|			for (i = llen; i < line_len; i++)
  ------------------
  |  Branch (513:19): [True: 0, False: 0]
  ------------------
  514|      0|				printf(" ");
  515|      0|			printf("\n");
  516|      0|			pos += llen;
  517|      0|			len -= llen;
  518|      0|		}
  519|      0|	}
  520|      0|#endif /* CONFIG_ANDROID_LOG */
  521|      0|}

sae.c:wpa_hexdump_buf:
  122|     31|{
  123|     31|	wpa_hexdump(level, title, buf ? wpabuf_head(buf) : NULL,
  ------------------
  |  Branch (123:28): [True: 31, False: 0]
  ------------------
  124|     31|		    buf ? wpabuf_len(buf) : 0);
  ------------------
  |  Branch (124:7): [True: 31, False: 0]
  ------------------
  125|     31|}

wpabuf_alloc:
  114|     31|{
  115|       |#ifdef WPA_TRACE
  116|       |	struct wpabuf_trace *trace = os_zalloc(sizeof(struct wpabuf_trace) +
  117|       |					       sizeof(struct wpabuf) + len);
  118|       |	struct wpabuf *buf;
  119|       |	if (trace == NULL)
  120|       |		return NULL;
  121|       |	trace->magic = WPABUF_MAGIC;
  122|       |	buf = (struct wpabuf *) (trace + 1);
  123|       |#else /* WPA_TRACE */
  124|     31|	struct wpabuf *buf = os_zalloc(sizeof(struct wpabuf) + len);
  125|     31|	if (buf == NULL)
  ------------------
  |  Branch (125:6): [True: 0, False: 31]
  ------------------
  126|      0|		return NULL;
  127|     31|#endif /* WPA_TRACE */
  128|       |
  129|     31|	buf->size = len;
  130|     31|	buf->buf = (u8 *) (buf + 1);
  131|     31|	return buf;
  132|     31|}
wpabuf_free:
  187|  4.03k|{
  188|       |#ifdef WPA_TRACE
  189|       |	struct wpabuf_trace *trace;
  190|       |	if (buf == NULL)
  191|       |		return;
  192|       |	trace = wpabuf_get_trace(buf);
  193|       |	if (trace->magic != WPABUF_MAGIC) {
  194|       |		wpa_printf(MSG_ERROR, "wpabuf_free: invalid magic %x",
  195|       |			   trace->magic);
  196|       |		wpa_trace_show("wpabuf_free magic mismatch");
  197|       |		abort();
  198|       |	}
  199|       |	if (buf->flags & WPABUF_FLAG_EXT_DATA)
  200|       |		os_free(buf->buf);
  201|       |	os_free(trace);
  202|       |#else /* WPA_TRACE */
  203|  4.03k|	if (buf == NULL)
  ------------------
  |  Branch (203:6): [True: 4.00k, False: 31]
  ------------------
  204|  4.00k|		return;
  205|     31|	if (buf->flags & WPABUF_FLAG_EXT_DATA)
  ------------------
  |  |   13|     31|#define WPABUF_FLAG_EXT_DATA BIT(0)
  |  |  ------------------
  |  |  |  |  458|     31|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (205:6): [True: 0, False: 31]
  ------------------
  206|      0|		os_free(buf->buf);
  ------------------
  |  |  513|      0|#define os_free(p) free((p))
  ------------------
  207|     31|	os_free(buf);
  ------------------
  |  |  513|     31|#define os_free(p) free((p))
  ------------------
  208|     31|#endif /* WPA_TRACE */
  209|     31|}
wpabuf_put:
  222|     31|{
  223|     31|	void *tmp = wpabuf_mhead_u8(buf) + wpabuf_len(buf);
  224|     31|	buf->used += len;
  225|     31|	if (buf->used > buf->size) {
  ------------------
  |  Branch (225:6): [True: 0, False: 31]
  ------------------
  226|      0|		wpabuf_overflow(buf, len);
  227|      0|	}
  228|     31|	return tmp;
  229|     31|}

sae.c:wpabuf_len:
   59|     31|{
   60|     31|	return buf->used;
   61|     31|}
sae.c:wpabuf_head:
   94|     31|{
   95|     31|	return buf->buf;
   96|     31|}
sae.c:wpabuf_put_data:
  174|     31|{
  175|     31|	if (data)
  ------------------
  |  Branch (175:6): [True: 31, False: 0]
  ------------------
  176|     31|		os_memcpy(wpabuf_put(buf, len), data, len);
  ------------------
  |  |  525|     31|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
  177|     31|}
wpabuf.c:wpabuf_len:
   59|     31|{
   60|     31|	return buf->used;
   61|     31|}
wpabuf.c:wpabuf_mhead:
  109|     31|{
  110|     31|	return buf->buf;
  111|     31|}
wpabuf.c:wpabuf_mhead_u8:
  114|     31|{
  115|     31|	return (u8 *) wpabuf_mhead(buf);
  116|     31|}

wpa_fuzzer_set_debug_level:
   15|    608|{
   16|    608|	static int first = 1;
   17|       |
   18|    608|	if (first) {
  ------------------
  |  Branch (18:6): [True: 1, False: 607]
  ------------------
   19|      1|		char *env;
   20|       |
   21|      1|		first = 0;
   22|      1|		env = getenv("WPADEBUG");
   23|      1|		if (env)
  ------------------
  |  Branch (23:7): [True: 0, False: 1]
  ------------------
   24|      0|			wpa_debug_level = atoi(env);
   25|      1|		else
   26|      1|			wpa_debug_level = MSG_ERROR + 1;
   27|       |
   28|      1|		wpa_debug_show_keys = 1;
   29|      1|	}
   30|    608|}

LLVMFuzzerTestOneInput:
   17|    608|{
   18|    608|	struct sae_data sae;
   19|    608|	u16 res;
   20|    608|	const u8 *token = NULL;
   21|    608|	size_t token_len = 0;
   22|    608|	int groups[] = { 19, 0 };
   23|       |
   24|    608|	wpa_fuzzer_set_debug_level();
   25|       |
   26|    608|	if (os_program_init())
  ------------------
  |  Branch (26:6): [True: 0, False: 608]
  ------------------
   27|      0|		return 0;
   28|       |
   29|    608|	os_memset(&sae, 0, sizeof(sae));
  ------------------
  |  |  531|    608|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
   30|    608|	res = sae_parse_commit(&sae, data, size, &token, &token_len, groups, 0,
   31|    608|			       NULL);
   32|    608|	wpa_printf(MSG_DEBUG, "sae_parse_commit(0): %u", res);
   33|    608|	sae_clear_data(&sae);
   34|    608|	res = sae_parse_commit(&sae, data, size, &token, &token_len, groups, 1,
   35|    608|			       NULL);
   36|    608|	wpa_printf(MSG_DEBUG, "sae_parse_commit(1): %u", res);
   37|    608|	sae_clear_data(&sae);
   38|    608|	os_program_deinit();
   39|       |
   40|    608|	return 0;
   41|    608|}

