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

dragonfly_suitable_group:
   19|  1.19k|{
   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.19k|	return group == 19 || group == 20 || group == 21 ||
  ------------------
  |  Branch (28:9): [True: 1.19k, 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.19k|}

sae_set_group:
   27|  1.19k|{
   28|  1.19k|	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.19k|	if (!dragonfly_suitable_group(group, 0)) {
  ------------------
  |  Branch (33:6): [True: 0, False: 1.19k]
  ------------------
   34|      0|		wpa_printf(MSG_DEBUG, "SAE: Reject unsuitable group %d", group);
   35|      0|		return -1;
   36|      0|	}
   37|  1.19k|#endif /* CONFIG_TESTING_OPTIONS */
   38|       |
   39|  1.19k|	sae_clear_data(sae);
   40|  1.19k|	tmp = sae->tmp = os_zalloc(sizeof(*tmp));
   41|  1.19k|	if (tmp == NULL)
  ------------------
  |  Branch (41:6): [True: 0, False: 1.19k]
  ------------------
   42|      0|		return -1;
   43|       |
   44|       |	/* First, check if this is an ECC group */
   45|  1.19k|	tmp->ec = crypto_ec_init(group);
   46|  1.19k|	if (tmp->ec) {
  ------------------
  |  Branch (46:6): [True: 1.19k, False: 0]
  ------------------
   47|  1.19k|		wpa_printf(MSG_DEBUG, "SAE: Selecting supported ECC group %d",
   48|  1.19k|			   group);
   49|  1.19k|		sae->group = group;
   50|  1.19k|		tmp->prime_len = crypto_ec_prime_len(tmp->ec);
   51|  1.19k|		tmp->prime = crypto_ec_get_prime(tmp->ec);
   52|  1.19k|		tmp->order_len = crypto_ec_order_len(tmp->ec);
   53|  1.19k|		tmp->order = crypto_ec_get_order(tmp->ec);
   54|  1.19k|		return 0;
   55|  1.19k|	}
   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.44k|{
   98|  2.44k|	struct sae_temporary_data *tmp;
   99|  2.44k|	if (sae == NULL || sae->tmp == NULL)
  ------------------
  |  Branch (99:6): [True: 0, False: 2.44k]
  |  Branch (99:21): [True: 1.24k, False: 1.19k]
  ------------------
  100|  1.24k|		return;
  101|  1.19k|	tmp = sae->tmp;
  102|  1.19k|	crypto_ec_deinit(tmp->ec);
  103|  1.19k|	crypto_bignum_deinit(tmp->prime_buf, 0);
  104|  1.19k|	crypto_bignum_deinit(tmp->order_buf, 0);
  105|  1.19k|	crypto_bignum_deinit(tmp->sae_rand, 1);
  106|  1.19k|	crypto_bignum_deinit(tmp->pwe_ffc, 1);
  107|  1.19k|	crypto_bignum_deinit(tmp->own_commit_scalar, 0);
  108|  1.19k|	crypto_bignum_deinit(tmp->own_commit_element_ffc, 0);
  109|  1.19k|	crypto_bignum_deinit(tmp->peer_commit_element_ffc, 0);
  110|  1.19k|	crypto_ec_point_deinit(tmp->pwe_ecc, 1);
  111|  1.19k|	crypto_ec_point_deinit(tmp->own_commit_element_ecc, 0);
  112|  1.19k|	crypto_ec_point_deinit(tmp->peer_commit_element_ecc, 0);
  113|  1.19k|	wpabuf_free(tmp->anti_clogging_token);
  114|  1.19k|	wpabuf_free(tmp->own_rejected_groups);
  115|  1.19k|	wpabuf_free(tmp->peer_rejected_groups);
  116|  1.19k|	os_free(tmp->pw_id);
  ------------------
  |  |  513|  1.19k|#define os_free(p) free((p))
  ------------------
  117|  1.19k|	os_free(tmp->parsed_pw_id);
  ------------------
  |  |  513|  1.19k|#define os_free(p) free((p))
  ------------------
  118|  1.19k|	os_free(tmp->dec_pw_id);
  ------------------
  |  |  513|  1.19k|#define os_free(p) free((p))
  ------------------
  119|  1.19k|	bin_clear_free(tmp, sizeof(*tmp));
  120|       |	sae->tmp = NULL;
  121|  1.19k|}
sae_clear_data:
  125|  2.44k|{
  126|  2.44k|	unsigned int no_pw_id;
  127|       |
  128|  2.44k|	if (sae == NULL)
  ------------------
  |  Branch (128:6): [True: 0, False: 2.44k]
  ------------------
  129|      0|		return;
  130|  2.44k|	sae_clear_temp_data(sae);
  131|  2.44k|	crypto_bignum_deinit(sae->peer_commit_scalar, 0);
  132|  2.44k|	crypto_bignum_deinit(sae->peer_commit_scalar_accepted, 0);
  133|  2.44k|	no_pw_id = sae->no_pw_id;
  134|  2.44k|	os_memset(sae, 0, sizeof(*sae));
  ------------------
  |  |  531|  2.44k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  135|  2.44k|	sae->no_pw_id = no_pw_id;
  136|  2.44k|}
sae_group_allowed:
 1741|  1.24k|{
 1742|  1.24k|	if (allowed_groups) {
  ------------------
  |  Branch (1742:6): [True: 1.24k, False: 0]
  ------------------
 1743|  1.24k|		int i;
 1744|  1.29k|		for (i = 0; allowed_groups[i] > 0; i++) {
  ------------------
  |  Branch (1744:15): [True: 1.24k, False: 50]
  ------------------
 1745|  1.24k|			if (allowed_groups[i] == group)
  ------------------
  |  Branch (1745:8): [True: 1.19k, False: 50]
  ------------------
 1746|  1.19k|				break;
 1747|  1.24k|		}
 1748|  1.24k|		if (allowed_groups[i] != group) {
  ------------------
  |  Branch (1748:7): [True: 46, False: 1.19k]
  ------------------
 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.24k|	}
 1755|       |
 1756|  1.19k|	if (sae->state == SAE_COMMITTED && group != sae->group) {
  ------------------
  |  Branch (1756:6): [True: 0, False: 1.19k]
  |  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.19k|	if (group != sae->group && sae_set_group(sae, group) < 0) {
  ------------------
  |  Branch (1761:6): [True: 1.19k, False: 4]
  |  Branch (1761:29): [True: 0, False: 1.19k]
  ------------------
 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.19k|	if (sae->tmp == NULL) {
  ------------------
  |  Branch (1767:6): [True: 4, False: 1.19k]
  ------------------
 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.19k|	if (sae->tmp->dh && !allowed_groups) {
  ------------------
  |  Branch (1772:6): [True: 0, False: 1.19k]
  |  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.19k|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|  1.19k|#define WLAN_STATUS_SUCCESS 0
  ------------------
 1779|  1.19k|}
sae_parse_commit:
 2162|  1.24k|{
 2163|  1.24k|	const u8 *pos = data, *end = data + len;
 2164|  1.24k|	u16 res;
 2165|       |
 2166|       |	/* Check Finite Cyclic Group */
 2167|  1.24k|	if (end - pos < 2)
  ------------------
  |  Branch (2167:6): [True: 4, False: 1.24k]
  ------------------
 2168|      4|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      4|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2169|  1.24k|	res = sae_group_allowed(sae, allowed_groups, WPA_GET_LE16(pos));
 2170|  1.24k|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|  1.24k|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2170:6): [True: 50, False: 1.19k]
  ------------------
 2171|     50|		return res;
 2172|  1.19k|	pos += 2;
 2173|       |
 2174|       |	/* Optional Anti-Clogging Token */
 2175|  1.19k|	sae_parse_commit_token(sae, &pos, end, token, token_len, h2e);
 2176|       |
 2177|       |	/* commit-scalar */
 2178|  1.19k|	res = sae_parse_commit_scalar(sae, &pos, end);
 2179|  1.19k|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|  1.19k|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2179:6): [True: 41, False: 1.15k]
  ------------------
 2180|     41|		return res;
 2181|       |
 2182|       |	/* commit-element */
 2183|  1.15k|	res = sae_parse_commit_element(sae, &pos, end);
 2184|  1.15k|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|  1.15k|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2184:6): [True: 528, False: 625]
  ------------------
 2185|    528|		return res;
 2186|       |
 2187|    625|	if (ie_offset)
  ------------------
  |  Branch (2187:6): [True: 0, False: 625]
  ------------------
 2188|      0|		*ie_offset = pos - data;
 2189|       |
 2190|    625|	if (end > pos)
  ------------------
  |  Branch (2190:6): [True: 622, False: 3]
  ------------------
 2191|    622|		wpa_hexdump(MSG_DEBUG,
 2192|    622|			    "SAE: Possible elements at the end of the frame",
 2193|    622|			    pos, end - pos);
 2194|       |
 2195|       |	/* Optional Password Identifier element */
 2196|    625|	res = sae_parse_password_identifier(sae, h2e, &pos, end);
 2197|    625|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|    625|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2197:6): [True: 17, False: 608]
  ------------------
 2198|     17|		return res;
 2199|       |
 2200|       |	/* Conditional Rejected Groups element */
 2201|    608|	if (h2e) {
  ------------------
  |  Branch (2201:6): [True: 420, False: 188]
  ------------------
 2202|    420|		res = sae_parse_rejected_groups(sae, &pos, end);
 2203|    420|		if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|    420|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2203:7): [True: 38, False: 382]
  ------------------
 2204|     38|			return res;
 2205|    420|	} else {
 2206|    188|		wpabuf_free(sae->tmp->peer_rejected_groups);
 2207|    188|		sae->tmp->peer_rejected_groups = NULL;
 2208|    188|	}
 2209|       |
 2210|       |	/* Optional Anti-Clogging Token Container element */
 2211|    570|	if (h2e)
  ------------------
  |  Branch (2211:6): [True: 382, False: 188]
  ------------------
 2212|    382|		sae_parse_token_container(sae, pos, end, token, token_len);
 2213|       |
 2214|       |	/* Conditional AKM Suite Selector element */
 2215|    570|	res = sae_parse_akm_suite_selector(sae, &pos, end);
 2216|    570|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|    570|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2216:6): [True: 0, False: 570]
  ------------------
 2217|      0|		return res;
 2218|       |
 2219|    570|	if (sae->own_akm_suite_selector &&
  ------------------
  |  Branch (2219:6): [True: 0, False: 570]
  ------------------
 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|    570|	if (!sae->akmp) {
  ------------------
  |  Branch (2228:6): [True: 570, False: 0]
  ------------------
 2229|    570|		if (sae->peer_akm_suite_selector ==
  ------------------
  |  Branch (2229:7): [True: 15, False: 555]
  ------------------
 2230|    570|		    RSN_AUTH_KEY_MGMT_SAE_EXT_KEY)
  ------------------
  |  |  106|    570|#define RSN_AUTH_KEY_MGMT_SAE_EXT_KEY RSN_SELECTOR(0x00, 0x0f, 0xac, 24)
  |  |  ------------------
  |  |  |  |   71|    570|	((((u32) (a)) << 24) | (((u32) (b)) << 16) | (((u32) (c)) << 8) | \
  |  |  |  |   72|    570|	 (u32) (d))
  |  |  ------------------
  ------------------
 2231|     15|			sae->akmp = WPA_KEY_MGMT_SAE_EXT_KEY;
  ------------------
  |  |   52|     15|#define WPA_KEY_MGMT_SAE_EXT_KEY BIT(26)
  |  |  ------------------
  |  |  |  |  458|     15|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 2232|    555|		else if (sae->peer_akm_suite_selector ==
  ------------------
  |  Branch (2232:12): [True: 8, False: 547]
  ------------------
 2233|    555|		    RSN_AUTH_KEY_MGMT_FT_SAE_EXT_KEY)
  ------------------
  |  |  107|    555|#define RSN_AUTH_KEY_MGMT_FT_SAE_EXT_KEY RSN_SELECTOR(0x00, 0x0f, 0xac, 25)
  |  |  ------------------
  |  |  |  |   71|    555|	((((u32) (a)) << 24) | (((u32) (b)) << 16) | (((u32) (c)) << 8) | \
  |  |  |  |   72|    555|	 (u32) (d))
  |  |  ------------------
  ------------------
 2234|      8|			sae->akmp = WPA_KEY_MGMT_FT_SAE_EXT_KEY;
  ------------------
  |  |   53|      8|#define WPA_KEY_MGMT_FT_SAE_EXT_KEY BIT(27)
  |  |  ------------------
  |  |  |  |  458|      8|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 2235|    570|	}
 2236|       |
 2237|    570|	if (wpa_key_mgmt_sae_ext_key(sae->akmp) && !h2e) {
  ------------------
  |  Branch (2237:6): [True: 23, False: 547]
  |  Branch (2237:45): [True: 2, False: 21]
  ------------------
 2238|      2|		wpa_printf(MSG_DEBUG,
 2239|      2|			   "SAE: Tried to use EXT-KEY AKM without H2E");
 2240|      2|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      2|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2241|      2|	}
 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|    568|	if (!sae->tmp->own_commit_scalar ||
  ------------------
  |  Branch (2247:6): [True: 568, 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|    568|		return WLAN_STATUS_SUCCESS; /* scalars/elements are different */
  ------------------
  |  |  134|    568|#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|    568|}
sae.c:sae_parse_commit_token:
 1825|  1.19k|{
 1826|  1.19k|	size_t scalar_elem_len, tlen;
 1827|       |
 1828|  1.19k|	if (token)
  ------------------
  |  Branch (1828:6): [True: 1.19k, False: 0]
  ------------------
 1829|  1.19k|		*token = NULL;
 1830|  1.19k|	if (token_len)
  ------------------
  |  Branch (1830:6): [True: 1.19k, False: 0]
  ------------------
 1831|  1.19k|		*token_len = 0;
 1832|       |
 1833|  1.19k|	if (h2e)
  ------------------
  |  Branch (1833:6): [True: 597, False: 597]
  ------------------
 1834|    597|		return; /* No Anti-Clogging Token field outside container IE */
 1835|       |
 1836|    597|	scalar_elem_len = (sae->tmp->ec ? 3 : 2) * sae->tmp->prime_len;
  ------------------
  |  Branch (1836:21): [True: 597, False: 0]
  ------------------
 1837|    597|	if (scalar_elem_len >= (size_t) (end - *pos))
  ------------------
  |  Branch (1837:6): [True: 148, False: 449]
  ------------------
 1838|    148|		return; /* No extra data beyond peer scalar and element */
 1839|       |
 1840|    449|	tlen = end - (*pos + scalar_elem_len);
 1841|       |
 1842|    449|	if (tlen < SHA256_MAC_LEN) {
  ------------------
  |  |   12|    449|#define SHA256_MAC_LEN 32
  ------------------
  |  Branch (1842:6): [True: 207, False: 242]
  ------------------
 1843|    207|		wpa_printf(MSG_DEBUG,
 1844|    207|			   "SAE: Too short optional data (%u octets) to include our Anti-Clogging Token",
 1845|    207|			   (unsigned int) tlen);
 1846|    207|		return;
 1847|    207|	}
 1848|       |
 1849|    242|	wpa_hexdump(MSG_DEBUG, "SAE: Anti-Clogging Token", *pos, tlen);
 1850|    242|	if (token)
  ------------------
  |  Branch (1850:6): [True: 242, False: 0]
  ------------------
 1851|    242|		*token = *pos;
 1852|    242|	if (token_len)
  ------------------
  |  Branch (1852:6): [True: 242, False: 0]
  ------------------
 1853|    242|		*token_len = tlen;
 1854|    242|	*pos += tlen;
 1855|    242|}
sae.c:sae_parse_commit_scalar:
 1875|  1.19k|{
 1876|  1.19k|	struct crypto_bignum *peer_scalar;
 1877|       |
 1878|  1.19k|	if (sae->tmp->prime_len > end - *pos) {
  ------------------
  |  Branch (1878:6): [True: 14, False: 1.18k]
  ------------------
 1879|     14|		wpa_printf(MSG_DEBUG, "SAE: Not enough data for scalar");
 1880|     14|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|     14|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1881|     14|	}
 1882|       |
 1883|  1.18k|	peer_scalar = crypto_bignum_init_set(*pos, sae->tmp->prime_len);
 1884|  1.18k|	if (peer_scalar == NULL)
  ------------------
  |  Branch (1884:6): [True: 0, False: 1.18k]
  ------------------
 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.18k|	if (sae->state == SAE_ACCEPTED && sae->peer_commit_scalar_accepted &&
  ------------------
  |  Branch (1893:6): [True: 0, False: 1.18k]
  |  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.18k|	if (crypto_bignum_is_zero(peer_scalar) ||
  ------------------
  |  Branch (1903:6): [True: 15, False: 1.16k]
  ------------------
 1904|  1.16k|	    crypto_bignum_is_one(peer_scalar) ||
  ------------------
  |  Branch (1904:6): [True: 3, False: 1.16k]
  ------------------
 1905|  1.16k|	    crypto_bignum_cmp(peer_scalar, sae->tmp->order) >= 0) {
  ------------------
  |  Branch (1905:6): [True: 9, False: 1.15k]
  ------------------
 1906|     27|		wpa_printf(MSG_DEBUG, "SAE: Invalid peer scalar");
 1907|     27|		crypto_bignum_deinit(peer_scalar, 0);
 1908|     27|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|     27|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1909|     27|	}
 1910|       |
 1911|       |
 1912|  1.15k|	crypto_bignum_deinit(sae->peer_commit_scalar, 0);
 1913|  1.15k|	sae->peer_commit_scalar = peer_scalar;
 1914|  1.15k|	wpa_hexdump(MSG_DEBUG, "SAE: Peer commit-scalar",
 1915|  1.15k|		    *pos, sae->tmp->prime_len);
 1916|  1.15k|	*pos += sae->tmp->prime_len;
 1917|       |
 1918|  1.15k|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|  1.15k|#define WLAN_STATUS_SUCCESS 0
  ------------------
 1919|  1.18k|}
sae.c:sae_parse_commit_element:
 2023|  1.15k|{
 2024|  1.15k|	if (sae->tmp->dh)
  ------------------
  |  Branch (2024:6): [True: 0, False: 1.15k]
  ------------------
 2025|      0|		return sae_parse_commit_element_ffc(sae, pos, end);
 2026|  1.15k|	return sae_parse_commit_element_ecc(sae, pos, end);
 2027|  1.15k|}
sae.c:sae_parse_commit_element_ecc:
 1924|  1.15k|{
 1925|  1.15k|	u8 prime[SAE_MAX_ECC_PRIME_LEN];
 1926|       |
 1927|  1.15k|	if (2 * sae->tmp->prime_len > end - *pos) {
  ------------------
  |  Branch (1927:6): [True: 26, False: 1.12k]
  ------------------
 1928|     26|		wpa_printf(MSG_DEBUG, "SAE: Not enough data for "
 1929|     26|			   "commit-element");
 1930|     26|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|     26|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1931|     26|	}
 1932|       |
 1933|  1.12k|	if (crypto_bignum_to_bin(sae->tmp->prime, prime, sizeof(prime),
  ------------------
  |  Branch (1933:6): [True: 0, False: 1.12k]
  ------------------
 1934|  1.12k|				 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.12k|	if (os_memcmp(*pos, prime, sae->tmp->prime_len) >= 0 ||
  ------------------
  |  |  534|  1.12k|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (1938:6): [True: 86, False: 1.04k]
  ------------------
 1939|  1.04k|	    os_memcmp(*pos + sae->tmp->prime_len, prime,
  ------------------
  |  |  534|  1.04k|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (1939:6): [True: 101, False: 940]
  ------------------
 1940|  1.04k|		      sae->tmp->prime_len) >= 0) {
 1941|    187|		wpa_printf(MSG_DEBUG, "SAE: Invalid coordinates in peer "
 1942|    187|			   "element");
 1943|    187|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|    187|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1944|    187|	}
 1945|       |
 1946|    940|	wpa_hexdump(MSG_DEBUG, "SAE: Peer commit-element(x)",
 1947|    940|		    *pos, sae->tmp->prime_len);
 1948|    940|	wpa_hexdump(MSG_DEBUG, "SAE: Peer commit-element(y)",
 1949|    940|		    *pos + sae->tmp->prime_len, sae->tmp->prime_len);
 1950|       |
 1951|    940|	crypto_ec_point_deinit(sae->tmp->peer_commit_element_ecc, 0);
 1952|    940|	sae->tmp->peer_commit_element_ecc =
 1953|    940|		crypto_ec_point_from_bin(sae->tmp->ec, *pos);
 1954|    940|	if (!sae->tmp->peer_commit_element_ecc) {
  ------------------
  |  Branch (1954:6): [True: 315, False: 625]
  ------------------
 1955|    315|		wpa_printf(MSG_DEBUG, "SAE: Peer element is not a valid point");
 1956|    315|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|    315|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1957|    315|	}
 1958|       |
 1959|    625|	if (!crypto_ec_point_is_on_curve(sae->tmp->ec,
  ------------------
  |  Branch (1959:6): [True: 0, False: 625]
  ------------------
 1960|    625|					 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|    625|	*pos += 2 * sae->tmp->prime_len;
 1966|       |
 1967|    625|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|    625|#define WLAN_STATUS_SUCCESS 0
  ------------------
 1968|    625|}
sae.c:sae_parse_password_identifier:
 2032|    625|{
 2033|    625|	const u8 *epos;
 2034|    625|	u8 len;
 2035|       |
 2036|    625|	if (!sae_is_password_id_elem(*pos, end)) {
  ------------------
  |  Branch (2036:6): [True: 532, False: 93]
  ------------------
 2037|    532|		if (sae->tmp->pw_id) {
  ------------------
  |  Branch (2037:7): [True: 0, False: 532]
  ------------------
 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|    532|		os_free(sae->tmp->parsed_pw_id);
  ------------------
  |  |  513|    532|#define os_free(p) free((p))
  ------------------
 2044|    532|		sae->tmp->parsed_pw_id = NULL;
 2045|    532|		sae->tmp->parsed_pw_id_len = 0;
 2046|    532|		return WLAN_STATUS_SUCCESS; /* No Password Identifier */
  ------------------
  |  |  134|    532|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2047|    532|	}
 2048|       |
 2049|     93|	epos = *pos;
 2050|     93|	epos++; /* skip IE type */
 2051|     93|	len = *epos++; /* IE length */
 2052|     93|	if (len > end - epos || len < 1)
  ------------------
  |  Branch (2052:6): [True: 0, False: 93]
  |  Branch (2052:26): [True: 0, False: 93]
  ------------------
 2053|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2054|     93|	epos++; /* skip ext ID */
 2055|     93|	len--;
 2056|       |
 2057|     93|	if (!h2e) {
  ------------------
  |  Branch (2057:6): [True: 17, False: 76]
  ------------------
 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|     76|	if (sae->no_pw_id) {
  ------------------
  |  Branch (2063:6): [True: 0, False: 76]
  ------------------
 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|     76|	if (sae->tmp->pw_id &&
  ------------------
  |  Branch (2069:6): [True: 0, False: 76]
  ------------------
 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|     76|	os_free(sae->tmp->parsed_pw_id);
  ------------------
  |  |  513|     76|#define os_free(p) free((p))
  ------------------
 2079|     76|	sae->tmp->parsed_pw_id = os_malloc(len + 1);
  ------------------
  |  |  507|     76|#define os_malloc(s) malloc((s))
  ------------------
 2080|     76|	if (!sae->tmp->parsed_pw_id) {
  ------------------
  |  Branch (2080:6): [True: 0, False: 76]
  ------------------
 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|     76|	os_memcpy(sae->tmp->parsed_pw_id, epos, len);
  ------------------
  |  |  525|     76|#define os_memcpy(d, s, n) memcpy((d), (s), (n))
  ------------------
 2085|     76|	sae->tmp->parsed_pw_id_len = len;
 2086|     76|	sae->tmp->parsed_pw_id[len] = '\0';
 2087|     76|	wpa_hexdump_ascii(MSG_DEBUG, "SAE: Received Password Identifier",
 2088|     76|			  sae->tmp->parsed_pw_id, len);
 2089|     76|	*pos = epos + len;
 2090|     76|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|     76|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2091|     76|}
sae.c:sae_is_password_id_elem:
 1783|    625|{
 1784|    625|	return end - pos >= 3 &&
  ------------------
  |  Branch (1784:9): [True: 618, False: 7]
  ------------------
 1785|    618|		pos[0] == WLAN_EID_EXTENSION &&
  ------------------
  |  |  505|  1.24k|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (1785:3): [True: 566, False: 52]
  ------------------
 1786|    566|		pos[1] >= 1 &&
  ------------------
  |  Branch (1786:3): [True: 561, False: 5]
  ------------------
 1787|    561|		end - pos - 2 >= pos[1] &&
  ------------------
  |  Branch (1787:3): [True: 518, False: 43]
  ------------------
 1788|    518|		pos[2] == WLAN_EID_EXT_PASSWORD_IDENTIFIER;
  ------------------
  |  |  523|    518|#define WLAN_EID_EXT_PASSWORD_IDENTIFIER 33
  ------------------
  |  Branch (1788:3): [True: 93, False: 425]
  ------------------
 1789|    625|}
sae.c:sae_parse_rejected_groups:
 2096|    420|{
 2097|    420|	const u8 *epos;
 2098|    420|	u8 len;
 2099|       |
 2100|    420|	if (!sae_is_rejected_groups_elem(*pos, end)) {
  ------------------
  |  Branch (2100:6): [True: 352, False: 68]
  ------------------
 2101|    352|		wpabuf_free(sae->tmp->peer_rejected_groups);
 2102|    352|		sae->tmp->peer_rejected_groups = NULL;
 2103|    352|		return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|    352|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2104|    352|	}
 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: 38, False: 30]
  ------------------
 2114|     38|		wpa_printf(MSG_DEBUG,
 2115|     38|			   "SAE: Invalid length of the Rejected Groups element payload: %u",
 2116|     38|			   len);
 2117|     38|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|     38|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2118|     38|	}
 2119|       |
 2120|     30|	wpabuf_free(sae->tmp->peer_rejected_groups);
 2121|     30|	sae->tmp->peer_rejected_groups = wpabuf_alloc(len);
 2122|     30|	if (!sae->tmp->peer_rejected_groups)
  ------------------
  |  Branch (2122:6): [True: 0, False: 30]
  ------------------
 2123|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2124|     30|	wpabuf_put_data(sae->tmp->peer_rejected_groups, epos, len);
 2125|     30|	wpa_hexdump_buf(MSG_DEBUG, "SAE: Received Rejected Groups list",
 2126|     30|			sae->tmp->peer_rejected_groups);
 2127|     30|	*pos = epos + len;
 2128|     30|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|     30|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2129|     30|}
sae.c:sae_is_rejected_groups_elem:
 1793|    420|{
 1794|    420|	return end - pos >= 3 &&
  ------------------
  |  Branch (1794:9): [True: 400, False: 20]
  ------------------
 1795|    400|		pos[0] == WLAN_EID_EXTENSION &&
  ------------------
  |  |  505|    820|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (1795:3): [True: 357, False: 43]
  ------------------
 1796|    357|		pos[1] >= 2 &&
  ------------------
  |  Branch (1796:3): [True: 311, False: 46]
  ------------------
 1797|    311|		end - pos - 2 >= pos[1] &&
  ------------------
  |  Branch (1797:3): [True: 285, False: 26]
  ------------------
 1798|    285|		pos[2] == WLAN_EID_EXT_REJECTED_GROUPS;
  ------------------
  |  |  540|    285|#define WLAN_EID_EXT_REJECTED_GROUPS 92
  ------------------
  |  Branch (1798:3): [True: 68, False: 217]
  ------------------
 1799|    420|}
sae.c:sae_parse_token_container:
 1861|    382|{
 1862|    382|	if (!sae_is_token_container_elem(pos, end))
  ------------------
  |  Branch (1862:6): [True: 380, False: 2]
  ------------------
 1863|    380|		return;
 1864|      2|	if (token)
  ------------------
  |  Branch (1864:6): [True: 2, False: 0]
  ------------------
 1865|      2|		*token = pos + 3;
 1866|      2|	if (token_len)
  ------------------
  |  Branch (1866:6): [True: 2, False: 0]
  ------------------
 1867|      2|		*token_len = pos[1] - 1;
 1868|      2|	wpa_hexdump(MSG_DEBUG, "SAE: Anti-Clogging Token (in container)",
 1869|      2|		    pos + 3, pos[1] - 1);
 1870|      2|}
sae.c:sae_is_token_container_elem:
 1803|    382|{
 1804|    382|	return end - pos >= 3 &&
  ------------------
  |  Branch (1804:9): [True: 345, False: 37]
  ------------------
 1805|    345|		pos[0] == WLAN_EID_EXTENSION &&
  ------------------
  |  |  505|    727|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (1805:3): [True: 293, False: 52]
  ------------------
 1806|    293|		pos[1] >= 1 &&
  ------------------
  |  Branch (1806:3): [True: 289, False: 4]
  ------------------
 1807|    289|		end - pos - 2 >= pos[1] &&
  ------------------
  |  Branch (1807:3): [True: 263, False: 26]
  ------------------
 1808|    263|		pos[2] == WLAN_EID_EXT_ANTI_CLOGGING_TOKEN;
  ------------------
  |  |  541|    263|#define WLAN_EID_EXT_ANTI_CLOGGING_TOKEN 93
  ------------------
  |  Branch (1808:3): [True: 2, False: 261]
  ------------------
 1809|    382|}
sae.c:sae_parse_akm_suite_selector:
 2134|    570|{
 2135|    570|	const u8 *epos;
 2136|    570|	u8 len;
 2137|       |
 2138|    570|	if (!sae_is_akm_suite_selector_elem(*pos, end))
  ------------------
  |  Branch (2138:6): [True: 331, False: 239]
  ------------------
 2139|    331|		return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|    331|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2140|       |
 2141|    239|	epos = *pos;
 2142|    239|	epos++; /* skip IE type */
 2143|    239|	len = *epos++; /* IE length */
 2144|    239|	if (len > end - epos || len < 1)
  ------------------
  |  Branch (2144:6): [True: 0, False: 239]
  |  Branch (2144:26): [True: 0, False: 239]
  ------------------
 2145|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2146|    239|	epos++; /* skip ext ID */
 2147|    239|	len--;
 2148|       |
 2149|    239|	if (len < RSN_SELECTOR_LEN)
  ------------------
  |  |   67|    239|#define RSN_SELECTOR_LEN 4
  ------------------
  |  Branch (2149:6): [True: 0, False: 239]
  ------------------
 2150|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2151|    239|	sae->peer_akm_suite_selector = RSN_SELECTOR_GET(epos);
  ------------------
  |  |  171|    239|#define RSN_SELECTOR_GET(a) WPA_GET_BE32((const u8 *) (a))
  ------------------
 2152|    239|	wpa_printf(MSG_DEBUG, "SAE: Received AKM Suite Selector: %08x",
 2153|    239|		   sae->peer_akm_suite_selector);
 2154|    239|	*pos = epos + len;
 2155|    239|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|    239|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2156|    239|}
sae.c:sae_is_akm_suite_selector_elem:
 1813|    570|{
 1814|    570|	return end - pos >= 2 + 1 + RSN_SELECTOR_LEN &&
  ------------------
  |  |   67|  1.14k|#define RSN_SELECTOR_LEN 4
  ------------------
  |  Branch (1814:9): [True: 409, False: 161]
  ------------------
 1815|    409|		pos[0] == WLAN_EID_EXTENSION &&
  ------------------
  |  |  505|    979|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (1815:3): [True: 356, False: 53]
  ------------------
 1816|    356|		pos[1] >= 1 + RSN_SELECTOR_LEN &&
  ------------------
  |  |   67|    926|#define RSN_SELECTOR_LEN 4
  ------------------
  |  Branch (1816:3): [True: 313, False: 43]
  ------------------
 1817|    313|		end - pos - 2 >= pos[1] &&
  ------------------
  |  Branch (1817:3): [True: 288, False: 25]
  ------------------
 1818|    288|		pos[2] == WLAN_EID_EXT_AKM_SUITE_SELECTOR;
  ------------------
  |  |  549|    288|#define WLAN_EID_EXT_AKM_SUITE_SELECTOR 114
  ------------------
  |  Branch (1818:3): [True: 239, False: 49]
  ------------------
 1819|    570|}

crypto_bignum_init_set:
 2088|  1.18k|{
 2089|  1.18k|	BIGNUM *bn;
 2090|       |
 2091|  1.18k|	if (TEST_FAIL())
  ------------------
  |  |  729|  1.18k|#define TEST_FAIL() testing_test_fail(NULL, false)
  |  |  ------------------
  |  |  |  Branch (729:21): [True: 0, False: 1.18k]
  |  |  ------------------
  ------------------
 2092|      0|		return NULL;
 2093|       |
 2094|  1.18k|	bn = BN_bin2bn(buf, len, NULL);
 2095|  1.18k|	return (struct crypto_bignum *) bn;
 2096|  1.18k|}
crypto_bignum_deinit:
 2118|  14.4k|{
 2119|  14.4k|	if (clear)
  ------------------
  |  Branch (2119:6): [True: 2.38k, False: 12.0k]
  ------------------
 2120|  2.38k|		BN_clear_free((BIGNUM *) n);
 2121|  12.0k|	else
 2122|  12.0k|		BN_free((BIGNUM *) n);
 2123|  14.4k|}
crypto_bignum_to_bin:
 2128|  1.12k|{
 2129|  1.12k|	int num_bytes, offset;
 2130|       |
 2131|  1.12k|	if (TEST_FAIL())
  ------------------
  |  |  729|  1.12k|#define TEST_FAIL() testing_test_fail(NULL, false)
  |  |  ------------------
  |  |  |  Branch (729:21): [True: 0, False: 1.12k]
  |  |  ------------------
  ------------------
 2132|      0|		return -1;
 2133|       |
 2134|  1.12k|	if (padlen > buflen)
  ------------------
  |  Branch (2134:6): [True: 0, False: 1.12k]
  ------------------
 2135|      0|		return -1;
 2136|       |
 2137|  1.12k|	if (padlen) {
  ------------------
  |  Branch (2137:6): [True: 1.12k, False: 0]
  ------------------
 2138|       |#ifdef OPENSSL_IS_BORINGSSL
 2139|       |		if (BN_bn2bin_padded(buf, padlen, (const BIGNUM *) a) == 0)
 2140|       |			return -1;
 2141|       |		return padlen;
 2142|       |#else /* OPENSSL_IS_BORINGSSL */
 2143|  1.12k|#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
 2144|  1.12k|		return BN_bn2binpad((const BIGNUM *) a, buf, padlen);
 2145|  1.12k|#endif
 2146|  1.12k|#endif
 2147|  1.12k|	}
 2148|       |
 2149|      0|	num_bytes = BN_num_bytes((const BIGNUM *) a);
 2150|      0|	if ((size_t) num_bytes > buflen)
  ------------------
  |  Branch (2150:6): [True: 0, False: 0]
  ------------------
 2151|      0|		return -1;
 2152|      0|	if (padlen > (size_t) num_bytes)
  ------------------
  |  Branch (2152:6): [True: 0, False: 0]
  ------------------
 2153|      0|		offset = padlen - num_bytes;
 2154|      0|	else
 2155|      0|		offset = 0;
 2156|       |
 2157|      0|	os_memset(buf, 0, offset);
  ------------------
  |  |  531|      0|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
 2158|      0|	BN_bn2bin((const BIGNUM *) a, buf + offset);
 2159|       |
 2160|      0|	return num_bytes + offset;
 2161|      0|}
crypto_bignum_cmp:
 2358|  1.16k|{
 2359|  1.16k|	return BN_cmp((const BIGNUM *) a, (const BIGNUM *) b);
 2360|  1.16k|}
crypto_bignum_is_zero:
 2364|  1.18k|{
 2365|  1.18k|	return BN_is_zero((const BIGNUM *) a);
 2366|  1.18k|}
crypto_bignum_is_one:
 2370|  1.16k|{
 2371|  1.16k|	return BN_is_one((const BIGNUM *) a);
 2372|  1.16k|}
crypto_ec_init:
 2511|  1.19k|{
 2512|  1.19k|	struct crypto_ec *e;
 2513|  1.19k|	int nid;
 2514|       |
 2515|  1.19k|	nid = crypto_ec_group_2_nid(group);
 2516|  1.19k|	if (nid < 0)
  ------------------
  |  Branch (2516:6): [True: 0, False: 1.19k]
  ------------------
 2517|      0|		return NULL;
 2518|       |
 2519|  1.19k|	e = os_zalloc(sizeof(*e));
 2520|  1.19k|	if (e == NULL)
  ------------------
  |  Branch (2520:6): [True: 0, False: 1.19k]
  ------------------
 2521|      0|		return NULL;
 2522|       |
 2523|  1.19k|	e->nid = nid;
 2524|  1.19k|	e->iana_group = group;
 2525|  1.19k|	e->bnctx = BN_CTX_new();
 2526|  1.19k|	e->group = EC_GROUP_new_by_curve_name(nid);
 2527|  1.19k|	e->prime = BN_new();
 2528|  1.19k|	e->order = BN_new();
 2529|  1.19k|	e->a = BN_new();
 2530|  1.19k|	e->b = BN_new();
 2531|  1.19k|	if (e->group == NULL || e->bnctx == NULL || e->prime == NULL ||
  ------------------
  |  Branch (2531:6): [True: 0, False: 1.19k]
  |  Branch (2531:26): [True: 0, False: 1.19k]
  |  Branch (2531:46): [True: 0, False: 1.19k]
  ------------------
 2532|  1.19k|	    e->order == NULL || e->a == NULL || e->b == NULL ||
  ------------------
  |  Branch (2532:6): [True: 0, False: 1.19k]
  |  Branch (2532:26): [True: 0, False: 1.19k]
  |  Branch (2532:42): [True: 0, False: 1.19k]
  ------------------
 2533|  1.19k|	    !EC_GROUP_get_curve(e->group, e->prime, e->a, e->b, e->bnctx) ||
  ------------------
  |  Branch (2533:6): [True: 0, False: 1.19k]
  ------------------
 2534|  1.19k|	    !EC_GROUP_get_order(e->group, e->order, e->bnctx)) {
  ------------------
  |  Branch (2534:6): [True: 0, False: 1.19k]
  ------------------
 2535|      0|		crypto_ec_deinit(e);
 2536|      0|		e = NULL;
 2537|      0|	}
 2538|       |
 2539|  1.19k|	return e;
 2540|  1.19k|}
crypto_ec_deinit:
 2544|  1.19k|{
 2545|  1.19k|	if (e == NULL)
  ------------------
  |  Branch (2545:6): [True: 0, False: 1.19k]
  ------------------
 2546|      0|		return;
 2547|  1.19k|	BN_clear_free(e->b);
 2548|  1.19k|	BN_clear_free(e->a);
 2549|  1.19k|	BN_clear_free(e->order);
 2550|  1.19k|	BN_clear_free(e->prime);
 2551|  1.19k|	EC_GROUP_free(e->group);
 2552|  1.19k|	BN_CTX_free(e->bnctx);
 2553|  1.19k|	os_free(e);
  ------------------
  |  |  513|  1.19k|#define os_free(p) free((p))
  ------------------
 2554|  1.19k|}
crypto_ec_prime_len:
 2568|  1.19k|{
 2569|       |	return BN_num_bytes(e->prime);
 2570|  1.19k|}
crypto_ec_order_len:
 2580|  1.19k|{
 2581|       |	return BN_num_bytes(e->order);
 2582|  1.19k|}
crypto_ec_get_prime:
 2586|  1.19k|{
 2587|  1.19k|	return (const struct crypto_bignum *) e->prime;
 2588|  1.19k|}
crypto_ec_get_order:
 2592|  1.19k|{
 2593|  1.19k|	return (const struct crypto_bignum *) e->order;
 2594|  1.19k|}
crypto_ec_point_deinit:
 2617|  4.52k|{
 2618|  4.52k|	if (clear)
  ------------------
  |  Branch (2618:6): [True: 1.19k, False: 3.32k]
  ------------------
 2619|  1.19k|		EC_POINT_clear_free((EC_POINT *) p);
 2620|  3.32k|	else
 2621|  3.32k|		EC_POINT_free((EC_POINT *) p);
 2622|  4.52k|}
crypto_ec_point_from_bin:
 2672|    940|{
 2673|    940|	BIGNUM *x, *y;
 2674|    940|	EC_POINT *elem;
 2675|    940|	int len = BN_num_bytes(e->prime);
 2676|       |
 2677|    940|	if (TEST_FAIL())
  ------------------
  |  |  729|    940|#define TEST_FAIL() testing_test_fail(NULL, false)
  |  |  ------------------
  |  |  |  Branch (729:21): [True: 0, False: 940]
  |  |  ------------------
  ------------------
 2678|      0|		return NULL;
 2679|       |
 2680|    940|	x = BN_bin2bn(val, len, NULL);
 2681|    940|	y = BN_bin2bn(val + len, len, NULL);
 2682|    940|	elem = EC_POINT_new(e->group);
 2683|    940|	if (x == NULL || y == NULL || elem == NULL) {
  ------------------
  |  Branch (2683:6): [True: 0, False: 940]
  |  Branch (2683:19): [True: 0, False: 940]
  |  Branch (2683:32): [True: 0, False: 940]
  ------------------
 2684|      0|		BN_clear_free(x);
 2685|      0|		BN_clear_free(y);
 2686|      0|		EC_POINT_clear_free(elem);
 2687|      0|		return NULL;
 2688|      0|	}
 2689|       |
 2690|    940|	if (!EC_POINT_set_affine_coordinates(e->group, elem, x, y, e->bnctx)) {
  ------------------
  |  Branch (2690:6): [True: 315, False: 625]
  ------------------
 2691|    315|		EC_POINT_clear_free(elem);
 2692|    315|		elem = NULL;
 2693|    315|	}
 2694|       |
 2695|    940|	BN_clear_free(x);
 2696|    940|	BN_clear_free(y);
 2697|       |
 2698|    940|	return (struct crypto_ec_point *) elem;
 2699|    940|}
crypto_ec_point_is_on_curve:
 2766|    625|{
 2767|    625|	return EC_POINT_is_on_curve(e->group, (const EC_POINT *) p,
 2768|    625|				    e->bnctx) == 1;
 2769|    625|}
crypto_openssl.c:crypto_ec_group_2_nid:
 2437|  1.19k|{
 2438|       |	/* Map from IANA registry for IKE D-H groups to OpenSSL NID */
 2439|  1.19k|	switch (group) {
 2440|  1.19k|	case 19:
  ------------------
  |  Branch (2440:2): [True: 1.19k, False: 0]
  ------------------
 2441|  1.19k|		return NID_X9_62_prime256v1;
 2442|      0|	case 20:
  ------------------
  |  Branch (2442:2): [True: 0, False: 1.19k]
  ------------------
 2443|      0|		return NID_secp384r1;
 2444|      0|	case 21:
  ------------------
  |  Branch (2444:2): [True: 0, False: 1.19k]
  ------------------
 2445|      0|		return NID_secp521r1;
 2446|      0|	case 25:
  ------------------
  |  Branch (2446:2): [True: 0, False: 1.19k]
  ------------------
 2447|      0|		return NID_X9_62_prime192v1;
 2448|      0|	case 26:
  ------------------
  |  Branch (2448:2): [True: 0, False: 1.19k]
  ------------------
 2449|      0|		return NID_secp224r1;
 2450|      0|#ifdef NID_brainpoolP224r1
 2451|      0|	case 27:
  ------------------
  |  Branch (2451:2): [True: 0, False: 1.19k]
  ------------------
 2452|      0|		return NID_brainpoolP224r1;
 2453|      0|#endif /* NID_brainpoolP224r1 */
 2454|      0|#ifdef NID_brainpoolP256r1
 2455|      0|	case 28:
  ------------------
  |  Branch (2455:2): [True: 0, False: 1.19k]
  ------------------
 2456|      0|		return NID_brainpoolP256r1;
 2457|      0|#endif /* NID_brainpoolP256r1 */
 2458|      0|#ifdef NID_brainpoolP384r1
 2459|      0|	case 29:
  ------------------
  |  Branch (2459:2): [True: 0, False: 1.19k]
  ------------------
 2460|      0|		return NID_brainpoolP384r1;
 2461|      0|#endif /* NID_brainpoolP384r1 */
 2462|      0|#ifdef NID_brainpoolP512r1
 2463|      0|	case 30:
  ------------------
  |  Branch (2463:2): [True: 0, False: 1.19k]
  ------------------
 2464|      0|		return NID_brainpoolP512r1;
 2465|      0|#endif /* NID_brainpoolP512r1 */
 2466|      0|	default:
  ------------------
  |  Branch (2466:2): [True: 0, False: 1.19k]
  ------------------
 2467|      0|		return -1;
 2468|  1.19k|	}
 2469|  1.19k|}

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

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

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

os_get_random:
  280|    624|{
  281|    624|#ifdef TEST_FUZZ
  282|    624|	size_t i;
  283|       |
  284|  3.12k|	for (i = 0; i < len; i++)
  ------------------
  |  Branch (284:14): [True: 2.49k, False: 624]
  ------------------
  285|  2.49k|		buf[i] = i & 0xff;
  286|    624|	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|    624|}
os_program_init:
  361|    624|{
  362|    624|	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|    624|	if (os_get_random((unsigned char *) &seed, sizeof(seed)) == 0)
  ------------------
  |  Branch (392:6): [True: 624, False: 0]
  ------------------
  393|    624|		srandom(seed);
  394|       |
  395|    624|	return 0;
  396|    624|}
os_program_deinit:
  400|    624|{
  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|    624|}
os_zalloc:
  507|  2.41k|{
  508|  2.41k|	return calloc(1, size);
  509|  2.41k|}

wpa_printf:
  224|  3.56k|{
  225|  3.56k|	va_list ap;
  226|       |
  227|  3.56k|	if (level >= wpa_debug_level) {
  ------------------
  |  Branch (227:6): [True: 0, False: 3.56k]
  ------------------
  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.56k|}
wpa_hexdump:
  400|  3.92k|{
  401|  3.92k|	_wpa_hexdump(level, title, buf, len, 1, 0);
  402|  3.92k|}
wpa_hexdump_ascii:
  526|     76|{
  527|     76|	_wpa_hexdump_ascii(level, title, buf, len, 1);
  528|     76|}
wpa_debug.c:_wpa_hexdump:
  274|  3.92k|{
  275|  3.92k|	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.92k|	if (level < wpa_debug_level)
  ------------------
  |  Branch (295:6): [True: 3.92k, False: 0]
  ------------------
  296|  3.92k|		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|     76|{
  414|     76|	size_t i, llen;
  415|     76|	const u8 *pos = buf;
  416|     76|	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|     76|	if (level < wpa_debug_level)
  ------------------
  |  Branch (437:6): [True: 76, False: 0]
  ------------------
  438|     76|		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|     30|{
  123|     30|	wpa_hexdump(level, title, buf ? wpabuf_head(buf) : NULL,
  ------------------
  |  Branch (123:28): [True: 30, False: 0]
  ------------------
  124|     30|		    buf ? wpabuf_len(buf) : 0);
  ------------------
  |  Branch (124:7): [True: 30, False: 0]
  ------------------
  125|     30|}

wpabuf_alloc:
  114|     30|{
  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|     30|	struct wpabuf *buf = os_zalloc(sizeof(struct wpabuf) + len);
  125|     30|	if (buf == NULL)
  ------------------
  |  Branch (125:6): [True: 0, False: 30]
  ------------------
  126|      0|		return NULL;
  127|     30|#endif /* WPA_TRACE */
  128|       |
  129|     30|	buf->size = len;
  130|     30|	buf->buf = (u8 *) (buf + 1);
  131|     30|	return buf;
  132|     30|}
wpabuf_free:
  187|  4.15k|{
  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.15k|	if (buf == NULL)
  ------------------
  |  Branch (203:6): [True: 4.12k, False: 30]
  ------------------
  204|  4.12k|		return;
  205|     30|	if (buf->flags & WPABUF_FLAG_EXT_DATA)
  ------------------
  |  |   13|     30|#define WPABUF_FLAG_EXT_DATA BIT(0)
  |  |  ------------------
  |  |  |  |  458|     30|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
  |  Branch (205:6): [True: 0, False: 30]
  ------------------
  206|      0|		os_free(buf->buf);
  ------------------
  |  |  513|      0|#define os_free(p) free((p))
  ------------------
  207|     30|	os_free(buf);
  ------------------
  |  |  513|     30|#define os_free(p) free((p))
  ------------------
  208|     30|#endif /* WPA_TRACE */
  209|     30|}
wpabuf_put:
  222|     30|{
  223|     30|	void *tmp = wpabuf_mhead_u8(buf) + wpabuf_len(buf);
  224|     30|	buf->used += len;
  225|     30|	if (buf->used > buf->size) {
  ------------------
  |  Branch (225:6): [True: 0, False: 30]
  ------------------
  226|      0|		wpabuf_overflow(buf, len);
  227|      0|	}
  228|     30|	return tmp;
  229|     30|}

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

wpa_fuzzer_set_debug_level:
   15|    624|{
   16|    624|	static int first = 1;
   17|       |
   18|    624|	if (first) {
  ------------------
  |  Branch (18:6): [True: 1, False: 623]
  ------------------
   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|    624|}

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

