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

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

sae_set_group:
   27|  1.15k|{
   28|  1.15k|	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.15k|	if (!dragonfly_suitable_group(group, 0)) {
  ------------------
  |  Branch (33:6): [True: 0, False: 1.15k]
  ------------------
   34|      0|		wpa_printf(MSG_DEBUG, "SAE: Reject unsuitable group %d", group);
   35|      0|		return -1;
   36|      0|	}
   37|  1.15k|#endif /* CONFIG_TESTING_OPTIONS */
   38|       |
   39|  1.15k|	sae_clear_data(sae);
   40|  1.15k|	tmp = sae->tmp = os_zalloc(sizeof(*tmp));
   41|  1.15k|	if (tmp == NULL)
  ------------------
  |  Branch (41:6): [True: 0, False: 1.15k]
  ------------------
   42|      0|		return -1;
   43|       |
   44|       |	/* First, check if this is an ECC group */
   45|  1.15k|	tmp->ec = crypto_ec_init(group);
   46|  1.15k|	if (tmp->ec) {
  ------------------
  |  Branch (46:6): [True: 1.15k, False: 0]
  ------------------
   47|  1.15k|		wpa_printf(MSG_DEBUG, "SAE: Selecting supported ECC group %d",
   48|  1.15k|			   group);
   49|  1.15k|		sae->group = group;
   50|  1.15k|		tmp->prime_len = crypto_ec_prime_len(tmp->ec);
   51|  1.15k|		tmp->prime = crypto_ec_get_prime(tmp->ec);
   52|  1.15k|		tmp->order_len = crypto_ec_order_len(tmp->ec);
   53|  1.15k|		tmp->order = crypto_ec_get_order(tmp->ec);
   54|  1.15k|		return 0;
   55|  1.15k|	}
   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.36k|{
   98|  2.36k|	struct sae_temporary_data *tmp;
   99|  2.36k|	if (sae == NULL || sae->tmp == NULL)
  ------------------
  |  Branch (99:6): [True: 0, False: 2.36k]
  |  Branch (99:21): [True: 1.20k, False: 1.15k]
  ------------------
  100|  1.20k|		return;
  101|  1.15k|	tmp = sae->tmp;
  102|  1.15k|	crypto_ec_deinit(tmp->ec);
  103|  1.15k|	crypto_bignum_deinit(tmp->prime_buf, 0);
  104|  1.15k|	crypto_bignum_deinit(tmp->order_buf, 0);
  105|  1.15k|	crypto_bignum_deinit(tmp->sae_rand, 1);
  106|  1.15k|	crypto_bignum_deinit(tmp->pwe_ffc, 1);
  107|  1.15k|	crypto_bignum_deinit(tmp->own_commit_scalar, 0);
  108|  1.15k|	crypto_bignum_deinit(tmp->own_commit_element_ffc, 0);
  109|  1.15k|	crypto_bignum_deinit(tmp->peer_commit_element_ffc, 0);
  110|  1.15k|	crypto_ec_point_deinit(tmp->pwe_ecc, 1);
  111|  1.15k|	crypto_ec_point_deinit(tmp->own_commit_element_ecc, 0);
  112|  1.15k|	crypto_ec_point_deinit(tmp->peer_commit_element_ecc, 0);
  113|  1.15k|	wpabuf_free(tmp->anti_clogging_token);
  114|  1.15k|	wpabuf_free(tmp->own_rejected_groups);
  115|  1.15k|	wpabuf_free(tmp->peer_rejected_groups);
  116|  1.15k|	os_free(tmp->pw_id);
  ------------------
  |  |  511|  1.15k|#define os_free(p) free((p))
  ------------------
  117|  1.15k|	os_free(tmp->parsed_pw_id);
  ------------------
  |  |  511|  1.15k|#define os_free(p) free((p))
  ------------------
  118|  1.15k|	os_free(tmp->dec_pw_id);
  ------------------
  |  |  511|  1.15k|#define os_free(p) free((p))
  ------------------
  119|  1.15k|	bin_clear_free(tmp, sizeof(*tmp));
  120|       |	sae->tmp = NULL;
  121|  1.15k|}
sae_clear_data:
  125|  2.36k|{
  126|  2.36k|	unsigned int no_pw_id;
  127|       |
  128|  2.36k|	if (sae == NULL)
  ------------------
  |  Branch (128:6): [True: 0, False: 2.36k]
  ------------------
  129|      0|		return;
  130|  2.36k|	sae_clear_temp_data(sae);
  131|  2.36k|	crypto_bignum_deinit(sae->peer_commit_scalar, 0);
  132|  2.36k|	crypto_bignum_deinit(sae->peer_commit_scalar_accepted, 0);
  133|  2.36k|	no_pw_id = sae->no_pw_id;
  134|  2.36k|	os_memset(sae, 0, sizeof(*sae));
  ------------------
  |  |  529|  2.36k|#define os_memset(s, c, n) memset(s, c, n)
  ------------------
  135|  2.36k|	sae->no_pw_id = no_pw_id;
  136|  2.36k|}
sae_group_allowed:
 1741|  1.20k|{
 1742|  1.20k|	if (allowed_groups) {
  ------------------
  |  Branch (1742:6): [True: 1.20k, False: 0]
  ------------------
 1743|  1.20k|		int i;
 1744|  1.25k|		for (i = 0; allowed_groups[i] > 0; i++) {
  ------------------
  |  Branch (1744:15): [True: 1.20k, False: 48]
  ------------------
 1745|  1.20k|			if (allowed_groups[i] == group)
  ------------------
  |  Branch (1745:8): [True: 1.15k, False: 48]
  ------------------
 1746|  1.15k|				break;
 1747|  1.20k|		}
 1748|  1.20k|		if (allowed_groups[i] != group) {
  ------------------
  |  Branch (1748:7): [True: 44, False: 1.16k]
  ------------------
 1749|     44|			wpa_printf(MSG_DEBUG, "SAE: Proposed group %u not "
 1750|     44|				   "enabled in the current configuration",
 1751|     44|				   group);
 1752|     44|			return WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED;
  ------------------
  |  |  200|     44|#define WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED 77
  ------------------
 1753|     44|		}
 1754|  1.20k|	}
 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.15k, False: 4]
  |  Branch (1761:29): [True: 0, False: 1.15k]
  ------------------
 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.15k]
  ------------------
 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.15k|	if (sae->tmp->dh && !allowed_groups) {
  ------------------
  |  Branch (1772:6): [True: 0, False: 1.15k]
  |  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.15k|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|  1.15k|#define WLAN_STATUS_SUCCESS 0
  ------------------
 1779|  1.15k|}
sae_parse_commit:
 2162|  1.20k|{
 2163|  1.20k|	const u8 *pos = data, *end = data + len;
 2164|  1.20k|	u16 res;
 2165|       |
 2166|       |	/* Check Finite Cyclic Group */
 2167|  1.20k|	if (end - pos < 2)
  ------------------
  |  Branch (2167:6): [True: 4, False: 1.20k]
  ------------------
 2168|      4|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      4|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2169|  1.20k|	res = sae_group_allowed(sae, allowed_groups, WPA_GET_LE16(pos));
 2170|  1.20k|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|  1.20k|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2170:6): [True: 48, False: 1.15k]
  ------------------
 2171|     48|		return res;
 2172|  1.15k|	pos += 2;
 2173|       |
 2174|       |	/* Optional Anti-Clogging Token */
 2175|  1.15k|	sae_parse_commit_token(sae, &pos, end, token, token_len, h2e);
 2176|       |
 2177|       |	/* commit-scalar */
 2178|  1.15k|	res = sae_parse_commit_scalar(sae, &pos, end);
 2179|  1.15k|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|  1.15k|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2179:6): [True: 58, False: 1.09k]
  ------------------
 2180|     58|		return res;
 2181|       |
 2182|       |	/* commit-element */
 2183|  1.09k|	res = sae_parse_commit_element(sae, &pos, end);
 2184|  1.09k|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|  1.09k|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2184:6): [True: 500, False: 598]
  ------------------
 2185|    500|		return res;
 2186|       |
 2187|    598|	if (ie_offset)
  ------------------
  |  Branch (2187:6): [True: 0, False: 598]
  ------------------
 2188|      0|		*ie_offset = pos - data;
 2189|       |
 2190|    598|	if (end > pos)
  ------------------
  |  Branch (2190:6): [True: 594, False: 4]
  ------------------
 2191|    594|		wpa_hexdump(MSG_DEBUG,
 2192|    594|			    "SAE: Possible elements at the end of the frame",
 2193|    594|			    pos, end - pos);
 2194|       |
 2195|       |	/* Optional Password Identifier element */
 2196|    598|	res = sae_parse_password_identifier(sae, h2e, &pos, end);
 2197|    598|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|    598|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2197:6): [True: 16, False: 582]
  ------------------
 2198|     16|		return res;
 2199|       |
 2200|       |	/* Conditional Rejected Groups element */
 2201|    582|	if (h2e) {
  ------------------
  |  Branch (2201:6): [True: 404, False: 178]
  ------------------
 2202|    404|		res = sae_parse_rejected_groups(sae, &pos, end);
 2203|    404|		if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|    404|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2203:7): [True: 37, False: 367]
  ------------------
 2204|     37|			return res;
 2205|    404|	} else {
 2206|    178|		wpabuf_free(sae->tmp->peer_rejected_groups);
 2207|    178|		sae->tmp->peer_rejected_groups = NULL;
 2208|    178|	}
 2209|       |
 2210|       |	/* Optional Anti-Clogging Token Container element */
 2211|    545|	if (h2e)
  ------------------
  |  Branch (2211:6): [True: 367, False: 178]
  ------------------
 2212|    367|		sae_parse_token_container(sae, pos, end, token, token_len);
 2213|       |
 2214|       |	/* Conditional AKM Suite Selector element */
 2215|    545|	res = sae_parse_akm_suite_selector(sae, &pos, end);
 2216|    545|	if (res != WLAN_STATUS_SUCCESS)
  ------------------
  |  |  134|    545|#define WLAN_STATUS_SUCCESS 0
  ------------------
  |  Branch (2216:6): [True: 0, False: 545]
  ------------------
 2217|      0|		return res;
 2218|       |
 2219|    545|	if (sae->own_akm_suite_selector &&
  ------------------
  |  Branch (2219:6): [True: 0, False: 545]
  ------------------
 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|    545|	if (!sae->akmp) {
  ------------------
  |  Branch (2228:6): [True: 545, False: 0]
  ------------------
 2229|    545|		if (sae->peer_akm_suite_selector ==
  ------------------
  |  Branch (2229:7): [True: 23, False: 522]
  ------------------
 2230|    545|		    RSN_AUTH_KEY_MGMT_SAE_EXT_KEY)
  ------------------
  |  |  106|    545|#define RSN_AUTH_KEY_MGMT_SAE_EXT_KEY RSN_SELECTOR(0x00, 0x0f, 0xac, 24)
  |  |  ------------------
  |  |  |  |   71|    545|	((((u32) (a)) << 24) | (((u32) (b)) << 16) | (((u32) (c)) << 8) | \
  |  |  |  |   72|    545|	 (u32) (d))
  |  |  ------------------
  ------------------
 2231|     23|			sae->akmp = WPA_KEY_MGMT_SAE_EXT_KEY;
  ------------------
  |  |   52|     23|#define WPA_KEY_MGMT_SAE_EXT_KEY BIT(26)
  |  |  ------------------
  |  |  |  |  458|     23|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 2232|    522|		else if (sae->peer_akm_suite_selector ==
  ------------------
  |  Branch (2232:12): [True: 17, False: 505]
  ------------------
 2233|    522|		    RSN_AUTH_KEY_MGMT_FT_SAE_EXT_KEY)
  ------------------
  |  |  107|    522|#define RSN_AUTH_KEY_MGMT_FT_SAE_EXT_KEY RSN_SELECTOR(0x00, 0x0f, 0xac, 25)
  |  |  ------------------
  |  |  |  |   71|    522|	((((u32) (a)) << 24) | (((u32) (b)) << 16) | (((u32) (c)) << 8) | \
  |  |  |  |   72|    522|	 (u32) (d))
  |  |  ------------------
  ------------------
 2234|     17|			sae->akmp = WPA_KEY_MGMT_FT_SAE_EXT_KEY;
  ------------------
  |  |   53|     17|#define WPA_KEY_MGMT_FT_SAE_EXT_KEY BIT(27)
  |  |  ------------------
  |  |  |  |  458|     17|#define BIT(x) (1U << (x))
  |  |  ------------------
  ------------------
 2235|    545|	}
 2236|       |
 2237|    545|	if (wpa_key_mgmt_sae_ext_key(sae->akmp) && !h2e) {
  ------------------
  |  Branch (2237:6): [True: 40, False: 505]
  |  Branch (2237:45): [True: 6, False: 34]
  ------------------
 2238|      6|		wpa_printf(MSG_DEBUG,
 2239|      6|			   "SAE: Tried to use EXT-KEY AKM without H2E");
 2240|      6|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      6|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2241|      6|	}
 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|    539|	if (!sae->tmp->own_commit_scalar ||
  ------------------
  |  Branch (2247:6): [True: 539, 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|    539|		return WLAN_STATUS_SUCCESS; /* scalars/elements are different */
  ------------------
  |  |  134|    539|#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|    539|}
sae.c:sae_parse_commit_token:
 1825|  1.15k|{
 1826|  1.15k|	size_t scalar_elem_len, tlen;
 1827|       |
 1828|  1.15k|	if (token)
  ------------------
  |  Branch (1828:6): [True: 1.15k, False: 0]
  ------------------
 1829|  1.15k|		*token = NULL;
 1830|  1.15k|	if (token_len)
  ------------------
  |  Branch (1830:6): [True: 1.15k, False: 0]
  ------------------
 1831|  1.15k|		*token_len = 0;
 1832|       |
 1833|  1.15k|	if (h2e)
  ------------------
  |  Branch (1833:6): [True: 578, False: 578]
  ------------------
 1834|    578|		return; /* No Anti-Clogging Token field outside container IE */
 1835|       |
 1836|    578|	scalar_elem_len = (sae->tmp->ec ? 3 : 2) * sae->tmp->prime_len;
  ------------------
  |  Branch (1836:21): [True: 578, False: 0]
  ------------------
 1837|    578|	if (scalar_elem_len >= (size_t) (end - *pos))
  ------------------
  |  Branch (1837:6): [True: 143, False: 435]
  ------------------
 1838|    143|		return; /* No extra data beyond peer scalar and element */
 1839|       |
 1840|    435|	tlen = end - (*pos + scalar_elem_len);
 1841|       |
 1842|    435|	if (tlen < SHA256_MAC_LEN) {
  ------------------
  |  |   12|    435|#define SHA256_MAC_LEN 32
  ------------------
  |  Branch (1842:6): [True: 196, False: 239]
  ------------------
 1843|    196|		wpa_printf(MSG_DEBUG,
 1844|    196|			   "SAE: Too short optional data (%u octets) to include our Anti-Clogging Token",
 1845|    196|			   (unsigned int) tlen);
 1846|    196|		return;
 1847|    196|	}
 1848|       |
 1849|    239|	wpa_hexdump(MSG_DEBUG, "SAE: Anti-Clogging Token", *pos, tlen);
 1850|    239|	if (token)
  ------------------
  |  Branch (1850:6): [True: 239, False: 0]
  ------------------
 1851|    239|		*token = *pos;
 1852|    239|	if (token_len)
  ------------------
  |  Branch (1852:6): [True: 239, False: 0]
  ------------------
 1853|    239|		*token_len = tlen;
 1854|    239|	*pos += tlen;
 1855|    239|}
sae.c:sae_parse_commit_scalar:
 1875|  1.15k|{
 1876|  1.15k|	struct crypto_bignum *peer_scalar;
 1877|       |
 1878|  1.15k|	if (sae->tmp->prime_len > end - *pos) {
  ------------------
  |  Branch (1878:6): [True: 14, False: 1.14k]
  ------------------
 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.14k|	peer_scalar = crypto_bignum_init_set(*pos, sae->tmp->prime_len);
 1884|  1.14k|	if (peer_scalar == NULL)
  ------------------
  |  Branch (1884:6): [True: 0, False: 1.14k]
  ------------------
 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.14k|	if (sae->state == SAE_ACCEPTED && sae->peer_commit_scalar_accepted &&
  ------------------
  |  Branch (1893:6): [True: 0, False: 1.14k]
  |  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.14k|	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: 3, False: 1.11k]
  ------------------
 1905|  1.11k|	    crypto_bignum_cmp(peer_scalar, sae->tmp->order) >= 0) {
  ------------------
  |  Branch (1905:6): [True: 19, False: 1.09k]
  ------------------
 1906|     44|		wpa_printf(MSG_DEBUG, "SAE: Invalid peer scalar");
 1907|     44|		crypto_bignum_deinit(peer_scalar, 0);
 1908|     44|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|     44|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1909|     44|	}
 1910|       |
 1911|       |
 1912|  1.09k|	crypto_bignum_deinit(sae->peer_commit_scalar, 0);
 1913|  1.09k|	sae->peer_commit_scalar = peer_scalar;
 1914|  1.09k|	wpa_hexdump(MSG_DEBUG, "SAE: Peer commit-scalar",
 1915|  1.09k|		    *pos, sae->tmp->prime_len);
 1916|  1.09k|	*pos += sae->tmp->prime_len;
 1917|       |
 1918|  1.09k|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|  1.09k|#define WLAN_STATUS_SUCCESS 0
  ------------------
 1919|  1.14k|}
sae.c:sae_parse_commit_element:
 2023|  1.09k|{
 2024|  1.09k|	if (sae->tmp->dh)
  ------------------
  |  Branch (2024:6): [True: 0, False: 1.09k]
  ------------------
 2025|      0|		return sae_parse_commit_element_ffc(sae, pos, end);
 2026|  1.09k|	return sae_parse_commit_element_ecc(sae, pos, end);
 2027|  1.09k|}
sae.c:sae_parse_commit_element_ecc:
 1924|  1.09k|{
 1925|  1.09k|	u8 prime[SAE_MAX_ECC_PRIME_LEN];
 1926|       |
 1927|  1.09k|	if (2 * sae->tmp->prime_len > end - *pos) {
  ------------------
  |  Branch (1927:6): [True: 18, False: 1.08k]
  ------------------
 1928|     18|		wpa_printf(MSG_DEBUG, "SAE: Not enough data for "
 1929|     18|			   "commit-element");
 1930|     18|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|     18|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1931|     18|	}
 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 ||
  ------------------
  |  |  532|  1.08k|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (1938:6): [True: 84, False: 996]
  ------------------
 1939|    996|	    os_memcmp(*pos + sae->tmp->prime_len, prime,
  ------------------
  |  |  532|    996|#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
  ------------------
  |  Branch (1939:6): [True: 106, False: 890]
  ------------------
 1940|    996|		      sae->tmp->prime_len) >= 0) {
 1941|    190|		wpa_printf(MSG_DEBUG, "SAE: Invalid coordinates in peer "
 1942|    190|			   "element");
 1943|    190|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|    190|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1944|    190|	}
 1945|       |
 1946|    890|	wpa_hexdump(MSG_DEBUG, "SAE: Peer commit-element(x)",
 1947|    890|		    *pos, sae->tmp->prime_len);
 1948|    890|	wpa_hexdump(MSG_DEBUG, "SAE: Peer commit-element(y)",
 1949|    890|		    *pos + sae->tmp->prime_len, sae->tmp->prime_len);
 1950|       |
 1951|    890|	crypto_ec_point_deinit(sae->tmp->peer_commit_element_ecc, 0);
 1952|    890|	sae->tmp->peer_commit_element_ecc =
 1953|    890|		crypto_ec_point_from_bin(sae->tmp->ec, *pos);
 1954|    890|	if (!sae->tmp->peer_commit_element_ecc) {
  ------------------
  |  Branch (1954:6): [True: 292, False: 598]
  ------------------
 1955|    292|		wpa_printf(MSG_DEBUG, "SAE: Peer element is not a valid point");
 1956|    292|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|    292|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 1957|    292|	}
 1958|       |
 1959|    598|	if (!crypto_ec_point_is_on_curve(sae->tmp->ec,
  ------------------
  |  Branch (1959:6): [True: 0, False: 598]
  ------------------
 1960|    598|					 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|    598|	*pos += 2 * sae->tmp->prime_len;
 1966|       |
 1967|    598|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|    598|#define WLAN_STATUS_SUCCESS 0
  ------------------
 1968|    598|}
sae.c:sae_parse_password_identifier:
 2032|    598|{
 2033|    598|	const u8 *epos;
 2034|    598|	u8 len;
 2035|       |
 2036|    598|	if (!sae_is_password_id_elem(*pos, end)) {
  ------------------
  |  Branch (2036:6): [True: 504, False: 94]
  ------------------
 2037|    504|		if (sae->tmp->pw_id) {
  ------------------
  |  Branch (2037:7): [True: 0, False: 504]
  ------------------
 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|    504|		os_free(sae->tmp->parsed_pw_id);
  ------------------
  |  |  511|    504|#define os_free(p) free((p))
  ------------------
 2044|    504|		sae->tmp->parsed_pw_id = NULL;
 2045|    504|		sae->tmp->parsed_pw_id_len = 0;
 2046|    504|		return WLAN_STATUS_SUCCESS; /* No Password Identifier */
  ------------------
  |  |  134|    504|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2047|    504|	}
 2048|       |
 2049|     94|	epos = *pos;
 2050|     94|	epos++; /* skip IE type */
 2051|     94|	len = *epos++; /* IE length */
 2052|     94|	if (len > end - epos || len < 1)
  ------------------
  |  Branch (2052:6): [True: 0, False: 94]
  |  Branch (2052:26): [True: 0, False: 94]
  ------------------
 2053|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2054|     94|	epos++; /* skip ext ID */
 2055|     94|	len--;
 2056|       |
 2057|     94|	if (!h2e) {
  ------------------
  |  Branch (2057:6): [True: 16, False: 78]
  ------------------
 2058|     16|		wpa_printf(MSG_DEBUG,
 2059|     16|			   "SAE: Password Identifier included, but H2E is not used");
 2060|     16|		return WLAN_STATUS_UNKNOWN_PASSWORD_IDENTIFIER;
  ------------------
  |  |  231|     16|#define WLAN_STATUS_UNKNOWN_PASSWORD_IDENTIFIER 123
  ------------------
 2061|     16|	}
 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)) {
  ------------------
  |  |  532|      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);
  ------------------
  |  |  511|     78|#define os_free(p) free((p))
  ------------------
 2079|     78|	sae->tmp->parsed_pw_id = os_malloc(len + 1);
  ------------------
  |  |  505|     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);
  ------------------
  |  |  523|     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|    598|{
 1784|    598|	return end - pos >= 3 &&
  ------------------
  |  Branch (1784:9): [True: 590, False: 8]
  ------------------
 1785|    590|		pos[0] == WLAN_EID_EXTENSION &&
  ------------------
  |  |  505|  1.18k|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (1785:3): [True: 537, False: 53]
  ------------------
 1786|    537|		pos[1] >= 1 &&
  ------------------
  |  Branch (1786:3): [True: 531, False: 6]
  ------------------
 1787|    531|		end - pos - 2 >= pos[1] &&
  ------------------
  |  Branch (1787:3): [True: 495, False: 36]
  ------------------
 1788|    495|		pos[2] == WLAN_EID_EXT_PASSWORD_IDENTIFIER;
  ------------------
  |  |  523|    495|#define WLAN_EID_EXT_PASSWORD_IDENTIFIER 33
  ------------------
  |  Branch (1788:3): [True: 94, False: 401]
  ------------------
 1789|    598|}
sae.c:sae_parse_rejected_groups:
 2096|    404|{
 2097|    404|	const u8 *epos;
 2098|    404|	u8 len;
 2099|       |
 2100|    404|	if (!sae_is_rejected_groups_elem(*pos, end)) {
  ------------------
  |  Branch (2100:6): [True: 336, False: 68]
  ------------------
 2101|    336|		wpabuf_free(sae->tmp->peer_rejected_groups);
 2102|    336|		sae->tmp->peer_rejected_groups = NULL;
 2103|    336|		return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|    336|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2104|    336|	}
 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|    404|{
 1794|    404|	return end - pos >= 3 &&
  ------------------
  |  Branch (1794:9): [True: 384, False: 20]
  ------------------
 1795|    384|		pos[0] == WLAN_EID_EXTENSION &&
  ------------------
  |  |  505|    788|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (1795:3): [True: 339, False: 45]
  ------------------
 1796|    339|		pos[1] >= 2 &&
  ------------------
  |  Branch (1796:3): [True: 294, False: 45]
  ------------------
 1797|    294|		end - pos - 2 >= pos[1] &&
  ------------------
  |  Branch (1797:3): [True: 270, False: 24]
  ------------------
 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|    404|}
sae.c:sae_parse_token_container:
 1861|    367|{
 1862|    367|	if (!sae_is_token_container_elem(pos, end))
  ------------------
  |  Branch (1862:6): [True: 362, False: 5]
  ------------------
 1863|    362|		return;
 1864|      5|	if (token)
  ------------------
  |  Branch (1864:6): [True: 5, False: 0]
  ------------------
 1865|      5|		*token = pos + 3;
 1866|      5|	if (token_len)
  ------------------
  |  Branch (1866:6): [True: 5, False: 0]
  ------------------
 1867|      5|		*token_len = pos[1] - 1;
 1868|      5|	wpa_hexdump(MSG_DEBUG, "SAE: Anti-Clogging Token (in container)",
 1869|      5|		    pos + 3, pos[1] - 1);
 1870|      5|}
sae.c:sae_is_token_container_elem:
 1803|    367|{
 1804|    367|	return end - pos >= 3 &&
  ------------------
  |  Branch (1804:9): [True: 332, False: 35]
  ------------------
 1805|    332|		pos[0] == WLAN_EID_EXTENSION &&
  ------------------
  |  |  505|    699|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (1805:3): [True: 276, False: 56]
  ------------------
 1806|    276|		pos[1] >= 1 &&
  ------------------
  |  Branch (1806:3): [True: 272, False: 4]
  ------------------
 1807|    272|		end - pos - 2 >= pos[1] &&
  ------------------
  |  Branch (1807:3): [True: 248, False: 24]
  ------------------
 1808|    248|		pos[2] == WLAN_EID_EXT_ANTI_CLOGGING_TOKEN;
  ------------------
  |  |  541|    248|#define WLAN_EID_EXT_ANTI_CLOGGING_TOKEN 93
  ------------------
  |  Branch (1808:3): [True: 5, False: 243]
  ------------------
 1809|    367|}
sae.c:sae_parse_akm_suite_selector:
 2134|    545|{
 2135|    545|	const u8 *epos;
 2136|    545|	u8 len;
 2137|       |
 2138|    545|	if (!sae_is_akm_suite_selector_elem(*pos, end))
  ------------------
  |  Branch (2138:6): [True: 322, False: 223]
  ------------------
 2139|    322|		return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|    322|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2140|       |
 2141|    223|	epos = *pos;
 2142|    223|	epos++; /* skip IE type */
 2143|    223|	len = *epos++; /* IE length */
 2144|    223|	if (len > end - epos || len < 1)
  ------------------
  |  Branch (2144:6): [True: 0, False: 223]
  |  Branch (2144:26): [True: 0, False: 223]
  ------------------
 2145|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2146|    223|	epos++; /* skip ext ID */
 2147|    223|	len--;
 2148|       |
 2149|    223|	if (len < RSN_SELECTOR_LEN)
  ------------------
  |  |   67|    223|#define RSN_SELECTOR_LEN 4
  ------------------
  |  Branch (2149:6): [True: 0, False: 223]
  ------------------
 2150|      0|		return WLAN_STATUS_UNSPECIFIED_FAILURE;
  ------------------
  |  |  135|      0|#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
  ------------------
 2151|    223|	sae->peer_akm_suite_selector = RSN_SELECTOR_GET(epos);
  ------------------
  |  |  171|    223|#define RSN_SELECTOR_GET(a) WPA_GET_BE32((const u8 *) (a))
  ------------------
 2152|    223|	wpa_printf(MSG_DEBUG, "SAE: Received AKM Suite Selector: %08x",
 2153|    223|		   sae->peer_akm_suite_selector);
 2154|    223|	*pos = epos + len;
 2155|    223|	return WLAN_STATUS_SUCCESS;
  ------------------
  |  |  134|    223|#define WLAN_STATUS_SUCCESS 0
  ------------------
 2156|    223|}
sae.c:sae_is_akm_suite_selector_elem:
 1813|    545|{
 1814|    545|	return end - pos >= 2 + 1 + RSN_SELECTOR_LEN &&
  ------------------
  |  |   67|  1.09k|#define RSN_SELECTOR_LEN 4
  ------------------
  |  Branch (1814:9): [True: 393, False: 152]
  ------------------
 1815|    393|		pos[0] == WLAN_EID_EXTENSION &&
  ------------------
  |  |  505|    938|#define WLAN_EID_EXTENSION 255
  ------------------
  |  Branch (1815:3): [True: 338, False: 55]
  ------------------
 1816|    338|		pos[1] >= 1 + RSN_SELECTOR_LEN &&
  ------------------
  |  |   67|    883|#define RSN_SELECTOR_LEN 4
  ------------------
  |  Branch (1816:3): [True: 298, False: 40]
  ------------------
 1817|    298|		end - pos - 2 >= pos[1] &&
  ------------------
  |  Branch (1817:3): [True: 275, False: 23]
  ------------------
 1818|    275|		pos[2] == WLAN_EID_EXT_AKM_SUITE_SELECTOR;
  ------------------
  |  |  549|    275|#define WLAN_EID_EXT_AKM_SUITE_SELECTOR 114
  ------------------
  |  Branch (1818:3): [True: 223, False: 52]
  ------------------
 1819|    545|}

crypto_bignum_init_set:
 2088|  1.14k|{
 2089|  1.14k|	BIGNUM *bn;
 2090|       |
 2091|  1.14k|	if (TEST_FAIL())
  ------------------
  |  |  688|  1.14k|#define TEST_FAIL() testing_test_fail(NULL, false)
  |  |  ------------------
  |  |  |  Branch (688:21): [True: 0, False: 1.14k]
  |  |  ------------------
  ------------------
 2092|      0|		return NULL;
 2093|       |
 2094|  1.14k|	bn = BN_bin2bn(buf, len, NULL);
 2095|  1.14k|	return (struct crypto_bignum *) bn;
 2096|  1.14k|}
crypto_bignum_deinit:
 2118|  13.9k|{
 2119|  13.9k|	if (clear)
  ------------------
  |  Branch (2119:6): [True: 2.31k, False: 11.6k]
  ------------------
 2120|  2.31k|		BN_clear_free((BIGNUM *) n);
 2121|  11.6k|	else
 2122|  11.6k|		BN_free((BIGNUM *) n);
 2123|  13.9k|}
crypto_bignum_to_bin:
 2128|  1.08k|{
 2129|  1.08k|	int num_bytes, offset;
 2130|       |
 2131|  1.08k|	if (TEST_FAIL())
  ------------------
  |  |  688|  1.08k|#define TEST_FAIL() testing_test_fail(NULL, false)
  |  |  ------------------
  |  |  |  Branch (688:21): [True: 0, False: 1.08k]
  |  |  ------------------
  ------------------
 2132|      0|		return -1;
 2133|       |
 2134|  1.08k|	if (padlen > buflen)
  ------------------
  |  Branch (2134:6): [True: 0, False: 1.08k]
  ------------------
 2135|      0|		return -1;
 2136|       |
 2137|  1.08k|	if (padlen) {
  ------------------
  |  Branch (2137:6): [True: 1.08k, 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.08k|#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
 2144|  1.08k|		return BN_bn2binpad((const BIGNUM *) a, buf, padlen);
 2145|  1.08k|#endif
 2146|  1.08k|#endif
 2147|  1.08k|	}
 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);
  ------------------
  |  |  529|      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.11k|{
 2359|  1.11k|	return BN_cmp((const BIGNUM *) a, (const BIGNUM *) b);
 2360|  1.11k|}
crypto_bignum_is_zero:
 2364|  1.14k|{
 2365|  1.14k|	return BN_is_zero((const BIGNUM *) a);
 2366|  1.14k|}
crypto_bignum_is_one:
 2370|  1.12k|{
 2371|  1.12k|	return BN_is_one((const BIGNUM *) a);
 2372|  1.12k|}
crypto_ec_init:
 2511|  1.15k|{
 2512|  1.15k|	struct crypto_ec *e;
 2513|  1.15k|	int nid;
 2514|       |
 2515|  1.15k|	nid = crypto_ec_group_2_nid(group);
 2516|  1.15k|	if (nid < 0)
  ------------------
  |  Branch (2516:6): [True: 0, False: 1.15k]
  ------------------
 2517|      0|		return NULL;
 2518|       |
 2519|  1.15k|	e = os_zalloc(sizeof(*e));
 2520|  1.15k|	if (e == NULL)
  ------------------
  |  Branch (2520:6): [True: 0, False: 1.15k]
  ------------------
 2521|      0|		return NULL;
 2522|       |
 2523|  1.15k|	e->nid = nid;
 2524|  1.15k|	e->iana_group = group;
 2525|  1.15k|	e->bnctx = BN_CTX_new();
 2526|  1.15k|	e->group = EC_GROUP_new_by_curve_name(nid);
 2527|  1.15k|	e->prime = BN_new();
 2528|  1.15k|	e->order = BN_new();
 2529|  1.15k|	e->a = BN_new();
 2530|  1.15k|	e->b = BN_new();
 2531|  1.15k|	if (e->group == NULL || e->bnctx == NULL || e->prime == NULL ||
  ------------------
  |  Branch (2531:6): [True: 0, False: 1.15k]
  |  Branch (2531:26): [True: 0, False: 1.15k]
  |  Branch (2531:46): [True: 0, False: 1.15k]
  ------------------
 2532|  1.15k|	    e->order == NULL || e->a == NULL || e->b == NULL ||
  ------------------
  |  Branch (2532:6): [True: 0, False: 1.15k]
  |  Branch (2532:26): [True: 0, False: 1.15k]
  |  Branch (2532:42): [True: 0, False: 1.15k]
  ------------------
 2533|  1.15k|	    !EC_GROUP_get_curve(e->group, e->prime, e->a, e->b, e->bnctx) ||
  ------------------
  |  Branch (2533:6): [True: 0, False: 1.15k]
  ------------------
 2534|  1.15k|	    !EC_GROUP_get_order(e->group, e->order, e->bnctx)) {
  ------------------
  |  Branch (2534:6): [True: 0, False: 1.15k]
  ------------------
 2535|      0|		crypto_ec_deinit(e);
 2536|      0|		e = NULL;
 2537|      0|	}
 2538|       |
 2539|  1.15k|	return e;
 2540|  1.15k|}
crypto_ec_deinit:
 2544|  1.15k|{
 2545|  1.15k|	if (e == NULL)
  ------------------
  |  Branch (2545:6): [True: 0, False: 1.15k]
  ------------------
 2546|      0|		return;
 2547|  1.15k|	BN_clear_free(e->b);
 2548|  1.15k|	BN_clear_free(e->a);
 2549|  1.15k|	BN_clear_free(e->order);
 2550|  1.15k|	BN_clear_free(e->prime);
 2551|  1.15k|	EC_GROUP_free(e->group);
 2552|  1.15k|	BN_CTX_free(e->bnctx);
 2553|  1.15k|	os_free(e);
  ------------------
  |  |  511|  1.15k|#define os_free(p) free((p))
  ------------------
 2554|  1.15k|}
crypto_ec_prime_len:
 2568|  1.15k|{
 2569|       |	return BN_num_bytes(e->prime);
 2570|  1.15k|}
crypto_ec_order_len:
 2580|  1.15k|{
 2581|       |	return BN_num_bytes(e->order);
 2582|  1.15k|}
crypto_ec_get_prime:
 2586|  1.15k|{
 2587|  1.15k|	return (const struct crypto_bignum *) e->prime;
 2588|  1.15k|}
crypto_ec_get_order:
 2592|  1.15k|{
 2593|  1.15k|	return (const struct crypto_bignum *) e->order;
 2594|  1.15k|}
crypto_ec_point_deinit:
 2617|  4.35k|{
 2618|  4.35k|	if (clear)
  ------------------
  |  Branch (2618:6): [True: 1.15k, False: 3.20k]
  ------------------
 2619|  1.15k|		EC_POINT_clear_free((EC_POINT *) p);
 2620|  3.20k|	else
 2621|  3.20k|		EC_POINT_free((EC_POINT *) p);
 2622|  4.35k|}
crypto_ec_point_from_bin:
 2672|    890|{
 2673|    890|	BIGNUM *x, *y;
 2674|    890|	EC_POINT *elem;
 2675|    890|	int len = BN_num_bytes(e->prime);
 2676|       |
 2677|    890|	if (TEST_FAIL())
  ------------------
  |  |  688|    890|#define TEST_FAIL() testing_test_fail(NULL, false)
  |  |  ------------------
  |  |  |  Branch (688:21): [True: 0, False: 890]
  |  |  ------------------
  ------------------
 2678|      0|		return NULL;
 2679|       |
 2680|    890|	x = BN_bin2bn(val, len, NULL);
 2681|    890|	y = BN_bin2bn(val + len, len, NULL);
 2682|    890|	elem = EC_POINT_new(e->group);
 2683|    890|	if (x == NULL || y == NULL || elem == NULL) {
  ------------------
  |  Branch (2683:6): [True: 0, False: 890]
  |  Branch (2683:19): [True: 0, False: 890]
  |  Branch (2683:32): [True: 0, False: 890]
  ------------------
 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|    890|	if (!EC_POINT_set_affine_coordinates(e->group, elem, x, y, e->bnctx)) {
  ------------------
  |  Branch (2690:6): [True: 292, False: 598]
  ------------------
 2691|    292|		EC_POINT_clear_free(elem);
 2692|    292|		elem = NULL;
 2693|    292|	}
 2694|       |
 2695|    890|	BN_clear_free(x);
 2696|    890|	BN_clear_free(y);
 2697|       |
 2698|    890|	return (struct crypto_ec_point *) elem;
 2699|    890|}
crypto_ec_point_is_on_curve:
 2766|    598|{
 2767|    598|	return EC_POINT_is_on_curve(e->group, (const EC_POINT *) p,
 2768|    598|				    e->bnctx) == 1;
 2769|    598|}
crypto_openssl.c:crypto_ec_group_2_nid:
 2437|  1.15k|{
 2438|       |	/* Map from IANA registry for IKE D-H groups to OpenSSL NID */
 2439|  1.15k|	switch (group) {
 2440|  1.15k|	case 19:
  ------------------
  |  Branch (2440:2): [True: 1.15k, False: 0]
  ------------------
 2441|  1.15k|		return NID_X9_62_prime256v1;
 2442|      0|	case 20:
  ------------------
  |  Branch (2442:2): [True: 0, False: 1.15k]
  ------------------
 2443|      0|		return NID_secp384r1;
 2444|      0|	case 21:
  ------------------
  |  Branch (2444:2): [True: 0, False: 1.15k]
  ------------------
 2445|      0|		return NID_secp521r1;
 2446|      0|	case 25:
  ------------------
  |  Branch (2446:2): [True: 0, False: 1.15k]
  ------------------
 2447|      0|		return NID_X9_62_prime192v1;
 2448|      0|	case 26:
  ------------------
  |  Branch (2448:2): [True: 0, False: 1.15k]
  ------------------
 2449|      0|		return NID_secp224r1;
 2450|      0|#ifdef NID_brainpoolP224r1
 2451|      0|	case 27:
  ------------------
  |  Branch (2451:2): [True: 0, False: 1.15k]
  ------------------
 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.15k]
  ------------------
 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.15k]
  ------------------
 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.15k]
  ------------------
 2464|      0|		return NID_brainpoolP512r1;
 2465|      0|#endif /* NID_brainpoolP512r1 */
 2466|      0|	default:
  ------------------
  |  Branch (2466:2): [True: 0, False: 1.15k]
  ------------------
 2467|      0|		return -1;
 2468|  1.15k|	}
 2469|  1.15k|}

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

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

crypto_openssl.c:testing_test_fail:
  697|  3.11k|{
  698|  3.11k|	return 0;
  699|  3.11k|}

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

wpa_printf:
  224|  3.44k|{
  225|  3.44k|	va_list ap;
  226|       |
  227|  3.44k|	if (level >= wpa_debug_level) {
  ------------------
  |  Branch (227:6): [True: 0, False: 3.44k]
  ------------------
  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.44k|}
wpa_hexdump:
  400|  3.74k|{
  401|  3.74k|	_wpa_hexdump(level, title, buf, len, 1, 0);
  402|  3.74k|}
wpa_hexdump_ascii:
  526|     78|{
  527|     78|	_wpa_hexdump_ascii(level, title, buf, len, 1);
  528|     78|}
wpa_debug.c:_wpa_hexdump:
  274|  3.74k|{
  275|  3.74k|	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.74k|	if (level < wpa_debug_level)
  ------------------
  |  Branch (295:6): [True: 3.74k, False: 0]
  ------------------
  296|  3.74k|		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.01k|{
  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.01k|	if (buf == NULL)
  ------------------
  |  Branch (203:6): [True: 3.98k, False: 31]
  ------------------
  204|  3.98k|		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);
  ------------------
  |  |  511|      0|#define os_free(p) free((p))
  ------------------
  207|     31|	os_free(buf);
  ------------------
  |  |  511|     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);
  ------------------
  |  |  523|     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|    604|{
   16|    604|	static int first = 1;
   17|       |
   18|    604|	if (first) {
  ------------------
  |  Branch (18:6): [True: 1, False: 603]
  ------------------
   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|    604|}

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

