• Home
  • Raw
  • Download

Lines Matching refs:auth

557 static void dpp_auth_fail(struct dpp_authentication *auth, const char *txt)  in dpp_auth_fail()  argument
559 wpa_msg(auth->msg_ctx, MSG_INFO, DPP_EVENT_FAIL "%s", txt); in dpp_auth_fail()
1434 static int dpp_derive_ke(struct dpp_authentication *auth, u8 *ke, in dpp_derive_ke() argument
1446 if (!auth->Mx_len || !auth->Nx_len) { in dpp_derive_ke()
1455 nonce_len = auth->curve->nonce_len; in dpp_derive_ke()
1456 os_memcpy(nonces, auth->i_nonce, nonce_len); in dpp_derive_ke()
1457 os_memcpy(&nonces[nonce_len], auth->r_nonce, nonce_len); in dpp_derive_ke()
1458 addr[num_elem] = auth->Mx; in dpp_derive_ke()
1459 len[num_elem] = auth->Mx_len; in dpp_derive_ke()
1461 addr[num_elem] = auth->Nx; in dpp_derive_ke()
1462 len[num_elem] = auth->Nx_len; in dpp_derive_ke()
1464 if (auth->peer_bi && auth->own_bi) { in dpp_derive_ke()
1465 if (!auth->Lx_len) { in dpp_derive_ke()
1470 addr[num_elem] = auth->Lx; in dpp_derive_ke()
1471 len[num_elem] = auth->secret_len; in dpp_derive_ke()
1527 static struct wpabuf * dpp_auth_build_req(struct dpp_authentication *auth, in dpp_auth_build_req() argument
1620 os_memcpy(pos, auth->i_nonce, nonce_len - 1); in dpp_auth_build_req()
1631 os_memcpy(pos, auth->i_nonce, nonce_len); in dpp_auth_build_req()
1647 auth->i_capab = auth->allowed_roles; in dpp_auth_build_req()
1648 *pos++ = auth->i_capab; in dpp_auth_build_req()
1671 if (aes_siv_encrypt(auth->k1, auth->curve->hash_len, clear, siv_len, in dpp_auth_build_req()
1699 static struct wpabuf * dpp_auth_build_resp(struct dpp_authentication *auth, in dpp_auth_build_resp() argument
1719 auth->waiting_auth_conf = 1; in dpp_auth_build_resp()
1720 auth->auth_resp_tries = 0; in dpp_auth_build_resp()
1812 auth->r_capab = auth->configurator ? DPP_CAPAB_CONFIGURATOR : in dpp_auth_build_resp()
1814 *pos++ = auth->r_capab; in dpp_auth_build_resp()
1822 if ((auth->i_capab & DPP_CAPAB_ROLE_MASK) == in dpp_auth_build_resp()
1826 pos[-1] = auth->configurator ? DPP_CAPAB_ENROLLEE : in dpp_auth_build_resp()
1854 if (aes_siv_encrypt(siv_key, auth->curve->hash_len, clear, siv_len, in dpp_auth_build_resp()
1935 static int dpp_channel_intersect(struct dpp_authentication *auth, in dpp_channel_intersect() argument
1939 struct dpp_bootstrap_info *peer_bi = auth->peer_bi; in dpp_channel_intersect()
1944 if (freq_included(auth->freq, auth->num_freq, freq)) in dpp_channel_intersect()
1947 auth->freq[auth->num_freq++] = freq; in dpp_channel_intersect()
1949 if (!auth->num_freq) { in dpp_channel_intersect()
1954 auth->curr_freq = auth->freq[0]; in dpp_channel_intersect()
1959 static int dpp_channel_local_list(struct dpp_authentication *auth, in dpp_channel_local_list() argument
1967 auth->num_freq = 0; in dpp_channel_local_list()
1970 auth->freq[0] = 2412; in dpp_channel_local_list()
1971 auth->freq[1] = 2437; in dpp_channel_local_list()
1972 auth->freq[2] = 2462; in dpp_channel_local_list()
1973 auth->num_freq = 3; in dpp_channel_local_list()
1985 if (freq_included(auth->freq, auth->num_freq, freq)) in dpp_channel_local_list()
1987 auth->freq[auth->num_freq++] = freq; in dpp_channel_local_list()
1988 if (auth->num_freq == DPP_BOOTSTRAP_MAX_FREQ) { in dpp_channel_local_list()
1995 return auth->num_freq == 0 ? -1 : 0; in dpp_channel_local_list()
1999 static int dpp_prepare_channel_list(struct dpp_authentication *auth, in dpp_prepare_channel_list() argument
2007 if (auth->peer_bi->num_freq > 0) in dpp_prepare_channel_list()
2008 res = dpp_channel_intersect(auth, own_modes, num_modes); in dpp_prepare_channel_list()
2010 res = dpp_channel_local_list(auth, own_modes, num_modes); in dpp_prepare_channel_list()
2016 freq_to_start(auth->freq, auth->num_freq, 2462); in dpp_prepare_channel_list()
2017 freq_to_start(auth->freq, auth->num_freq, 2412); in dpp_prepare_channel_list()
2018 freq_to_start(auth->freq, auth->num_freq, 2437); in dpp_prepare_channel_list()
2020 auth->freq_idx = 0; in dpp_prepare_channel_list()
2021 auth->curr_freq = auth->freq[0]; in dpp_prepare_channel_list()
2025 for (i = 0; i < auth->num_freq; i++) { in dpp_prepare_channel_list()
2026 res = os_snprintf(pos, end - pos, " %u", auth->freq[i]); in dpp_prepare_channel_list()
2039 static int dpp_autogen_bootstrap_key(struct dpp_authentication *auth) in dpp_autogen_bootstrap_key() argument
2045 if (auth->own_bi) in dpp_autogen_bootstrap_key()
2052 pk = dpp_keygen(bi, auth->peer_bi->curve->name, NULL, 0); in dpp_autogen_bootstrap_key()
2066 auth->tmp_own_bi = auth->own_bi = bi; in dpp_autogen_bootstrap_key()
2086 struct dpp_authentication *auth; in dpp_auth_init() local
2096 auth = os_zalloc(sizeof(*auth)); in dpp_auth_init()
2097 if (!auth) in dpp_auth_init()
2099 auth->msg_ctx = msg_ctx; in dpp_auth_init()
2100 auth->initiator = 1; in dpp_auth_init()
2101 auth->waiting_auth_resp = 1; in dpp_auth_init()
2102 auth->allowed_roles = dpp_allowed_roles; in dpp_auth_init()
2103 auth->configurator = !!(dpp_allowed_roles & DPP_CAPAB_CONFIGURATOR); in dpp_auth_init()
2104 auth->peer_bi = peer_bi; in dpp_auth_init()
2105 auth->own_bi = own_bi; in dpp_auth_init()
2106 auth->curve = peer_bi->curve; in dpp_auth_init()
2108 if (dpp_autogen_bootstrap_key(auth) < 0 || in dpp_auth_init()
2109 dpp_prepare_channel_list(auth, own_modes, num_modes) < 0) in dpp_auth_init()
2116 os_memcpy(auth->i_nonce, dpp_nonce_override, nonce_len); in dpp_auth_init()
2118 nonce_len = auth->curve->nonce_len; in dpp_auth_init()
2119 if (random_get_bytes(auth->i_nonce, nonce_len)) { in dpp_auth_init()
2126 nonce_len = auth->curve->nonce_len; in dpp_auth_init()
2127 if (random_get_bytes(auth->i_nonce, nonce_len)) { in dpp_auth_init()
2132 wpa_hexdump(MSG_DEBUG, "DPP: I-nonce", auth->i_nonce, nonce_len); in dpp_auth_init()
2140 auth->own_protocol_key = dpp_set_keypair( in dpp_auth_init()
2144 auth->own_protocol_key = dpp_gen_keypair(auth->curve); in dpp_auth_init()
2147 auth->own_protocol_key = dpp_gen_keypair(auth->curve); in dpp_auth_init()
2149 if (!auth->own_protocol_key) in dpp_auth_init()
2152 pi = dpp_get_pubkey_point(auth->own_protocol_key, 0); in dpp_auth_init()
2157 ctx = EVP_PKEY_CTX_new(auth->own_protocol_key, NULL); in dpp_auth_init()
2160 EVP_PKEY_derive_set_peer(ctx, auth->peer_bi->pubkey) != 1 || in dpp_auth_init()
2163 EVP_PKEY_derive(ctx, auth->Mx, &secret_len) != 1) { in dpp_auth_init()
2169 auth->secret_len = secret_len; in dpp_auth_init()
2174 auth->Mx, auth->secret_len); in dpp_auth_init()
2175 auth->Mx_len = auth->secret_len; in dpp_auth_init()
2177 if (dpp_derive_k1(auth->Mx, auth->secret_len, auth->k1, in dpp_auth_init()
2178 auth->curve->hash_len) < 0) in dpp_auth_init()
2181 r_pubkey_hash = auth->peer_bi->pubkey_hash; in dpp_auth_init()
2182 i_pubkey_hash = auth->own_bi->pubkey_hash; in dpp_auth_init()
2210 pi = wpabuf_alloc(2 * auth->curve->prime_len); in dpp_auth_init()
2211 if (!pi || dpp_test_gen_invalid_key(pi, auth->curve) < 0) in dpp_auth_init()
2216 auth->req_msg = dpp_auth_build_req(auth, pi, nonce_len, r_pubkey_hash, in dpp_auth_init()
2218 if (!auth->req_msg) in dpp_auth_init()
2224 return auth; in dpp_auth_init()
2226 dpp_auth_deinit(auth); in dpp_auth_init()
2227 auth = NULL; in dpp_auth_init()
2232 static struct wpabuf * dpp_build_conf_req_attr(struct dpp_authentication *auth, in dpp_build_conf_req_attr() argument
2243 nonce_len = auth->curve->nonce_len; in dpp_build_conf_req_attr()
2244 if (random_get_bytes(auth->e_nonce, nonce_len)) { in dpp_build_conf_req_attr()
2248 wpa_hexdump(MSG_DEBUG, "DPP: E-nonce", auth->e_nonce, nonce_len); in dpp_build_conf_req_attr()
2273 wpabuf_put_data(clear, auth->e_nonce, nonce_len - 1); in dpp_build_conf_req_attr()
2285 wpabuf_put_data(clear, auth->e_nonce, nonce_len); in dpp_build_conf_req_attr()
2310 if (aes_siv_encrypt(auth->ke, auth->curve->hash_len, in dpp_build_conf_req_attr()
2359 struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth, in dpp_build_conf_req() argument
2364 conf_req = dpp_build_conf_req_attr(auth, json); in dpp_build_conf_req()
2386 static void dpp_auth_success(struct dpp_authentication *auth) in dpp_auth_success() argument
2390 os_memset(auth->Mx, 0, sizeof(auth->Mx)); in dpp_auth_success()
2391 auth->Mx_len = 0; in dpp_auth_success()
2392 os_memset(auth->Nx, 0, sizeof(auth->Nx)); in dpp_auth_success()
2393 auth->Nx_len = 0; in dpp_auth_success()
2394 os_memset(auth->Lx, 0, sizeof(auth->Lx)); in dpp_auth_success()
2395 auth->Lx_len = 0; in dpp_auth_success()
2396 os_memset(auth->k1, 0, sizeof(auth->k1)); in dpp_auth_success()
2397 os_memset(auth->k2, 0, sizeof(auth->k2)); in dpp_auth_success()
2399 auth->auth_success = 1; in dpp_auth_success()
2403 static int dpp_gen_r_auth(struct dpp_authentication *auth, u8 *r_auth) in dpp_gen_r_auth() argument
2414 nonce_len = auth->curve->nonce_len; in dpp_gen_r_auth()
2416 if (auth->initiator) { in dpp_gen_r_auth()
2417 pix = dpp_get_pubkey_point(auth->own_protocol_key, 0); in dpp_gen_r_auth()
2418 prx = dpp_get_pubkey_point(auth->peer_protocol_key, 0); in dpp_gen_r_auth()
2419 if (auth->own_bi) in dpp_gen_r_auth()
2420 bix = dpp_get_pubkey_point(auth->own_bi->pubkey, 0); in dpp_gen_r_auth()
2423 brx = dpp_get_pubkey_point(auth->peer_bi->pubkey, 0); in dpp_gen_r_auth()
2425 pix = dpp_get_pubkey_point(auth->peer_protocol_key, 0); in dpp_gen_r_auth()
2426 prx = dpp_get_pubkey_point(auth->own_protocol_key, 0); in dpp_gen_r_auth()
2427 if (auth->peer_bi) in dpp_gen_r_auth()
2428 bix = dpp_get_pubkey_point(auth->peer_bi->pubkey, 0); in dpp_gen_r_auth()
2431 brx = dpp_get_pubkey_point(auth->own_bi->pubkey, 0); in dpp_gen_r_auth()
2436 addr[num_elem] = auth->i_nonce; in dpp_gen_r_auth()
2440 addr[num_elem] = auth->r_nonce; in dpp_gen_r_auth()
2469 res = dpp_hash_vector(auth->curve, num_elem, addr, len, r_auth); in dpp_gen_r_auth()
2472 auth->curve->hash_len); in dpp_gen_r_auth()
2482 static int dpp_gen_i_auth(struct dpp_authentication *auth, u8 *i_auth) in dpp_gen_i_auth() argument
2493 nonce_len = auth->curve->nonce_len; in dpp_gen_i_auth()
2495 if (auth->initiator) { in dpp_gen_i_auth()
2496 pix = dpp_get_pubkey_point(auth->own_protocol_key, 0); in dpp_gen_i_auth()
2497 prx = dpp_get_pubkey_point(auth->peer_protocol_key, 0); in dpp_gen_i_auth()
2498 if (auth->own_bi) in dpp_gen_i_auth()
2499 bix = dpp_get_pubkey_point(auth->own_bi->pubkey, 0); in dpp_gen_i_auth()
2502 if (!auth->peer_bi) in dpp_gen_i_auth()
2504 brx = dpp_get_pubkey_point(auth->peer_bi->pubkey, 0); in dpp_gen_i_auth()
2506 pix = dpp_get_pubkey_point(auth->peer_protocol_key, 0); in dpp_gen_i_auth()
2507 prx = dpp_get_pubkey_point(auth->own_protocol_key, 0); in dpp_gen_i_auth()
2508 if (auth->peer_bi) in dpp_gen_i_auth()
2509 bix = dpp_get_pubkey_point(auth->peer_bi->pubkey, 0); in dpp_gen_i_auth()
2512 if (!auth->own_bi) in dpp_gen_i_auth()
2514 brx = dpp_get_pubkey_point(auth->own_bi->pubkey, 0); in dpp_gen_i_auth()
2519 addr[num_elem] = auth->r_nonce; in dpp_gen_i_auth()
2523 addr[num_elem] = auth->i_nonce; in dpp_gen_i_auth()
2552 res = dpp_hash_vector(auth->curve, num_elem, addr, len, i_auth); in dpp_gen_i_auth()
2555 auth->curve->hash_len); in dpp_gen_i_auth()
2565 static int dpp_auth_derive_l_responder(struct dpp_authentication *auth) in dpp_auth_derive_l_responder() argument
2584 BI = EVP_PKEY_get1_EC_KEY(auth->peer_bi->pubkey); in dpp_auth_derive_l_responder()
2592 bR = EVP_PKEY_get1_EC_KEY(auth->own_bi->pubkey); in dpp_auth_derive_l_responder()
2593 pR = EVP_PKEY_get1_EC_KEY(auth->own_protocol_key); in dpp_auth_derive_l_responder()
2614 if (dpp_bn2bin_pad(lx, auth->Lx, auth->secret_len) < 0) in dpp_auth_derive_l_responder()
2616 wpa_hexdump_key(MSG_DEBUG, "DPP: L.x", auth->Lx, auth->secret_len); in dpp_auth_derive_l_responder()
2617 auth->Lx_len = auth->secret_len; in dpp_auth_derive_l_responder()
2632 static int dpp_auth_derive_l_initiator(struct dpp_authentication *auth) in dpp_auth_derive_l_initiator() argument
2649 BR = EVP_PKEY_get1_EC_KEY(auth->peer_bi->pubkey); in dpp_auth_derive_l_initiator()
2650 PR = EVP_PKEY_get1_EC_KEY(auth->peer_protocol_key); in dpp_auth_derive_l_initiator()
2656 bI = EVP_PKEY_get1_EC_KEY(auth->own_bi->pubkey); in dpp_auth_derive_l_initiator()
2676 if (dpp_bn2bin_pad(lx, auth->Lx, auth->secret_len) < 0) in dpp_auth_derive_l_initiator()
2678 wpa_hexdump_key(MSG_DEBUG, "DPP: L.x", auth->Lx, auth->secret_len); in dpp_auth_derive_l_initiator()
2679 auth->Lx_len = auth->secret_len; in dpp_auth_derive_l_initiator()
2693 static int dpp_auth_build_resp_ok(struct dpp_authentication *auth) in dpp_auth_build_resp_ok() argument
2710 if (!auth->own_bi) in dpp_auth_build_resp_ok()
2717 os_memcpy(auth->r_nonce, dpp_nonce_override, nonce_len); in dpp_auth_build_resp_ok()
2719 nonce_len = auth->curve->nonce_len; in dpp_auth_build_resp_ok()
2720 if (random_get_bytes(auth->r_nonce, nonce_len)) { in dpp_auth_build_resp_ok()
2727 nonce_len = auth->curve->nonce_len; in dpp_auth_build_resp_ok()
2728 if (random_get_bytes(auth->r_nonce, nonce_len)) { in dpp_auth_build_resp_ok()
2733 wpa_hexdump(MSG_DEBUG, "DPP: R-nonce", auth->r_nonce, nonce_len); in dpp_auth_build_resp_ok()
2741 auth->own_protocol_key = dpp_set_keypair( in dpp_auth_build_resp_ok()
2745 auth->own_protocol_key = dpp_gen_keypair(auth->curve); in dpp_auth_build_resp_ok()
2748 auth->own_protocol_key = dpp_gen_keypair(auth->curve); in dpp_auth_build_resp_ok()
2750 if (!auth->own_protocol_key) in dpp_auth_build_resp_ok()
2753 pr = dpp_get_pubkey_point(auth->own_protocol_key, 0); in dpp_auth_build_resp_ok()
2758 ctx = EVP_PKEY_CTX_new(auth->own_protocol_key, NULL); in dpp_auth_build_resp_ok()
2761 EVP_PKEY_derive_set_peer(ctx, auth->peer_protocol_key) != 1 || in dpp_auth_build_resp_ok()
2764 EVP_PKEY_derive(ctx, auth->Nx, &secret_len) != 1) { in dpp_auth_build_resp_ok()
2774 auth->Nx, auth->secret_len); in dpp_auth_build_resp_ok()
2775 auth->Nx_len = auth->secret_len; in dpp_auth_build_resp_ok()
2777 if (dpp_derive_k2(auth->Nx, auth->secret_len, auth->k2, in dpp_auth_build_resp_ok()
2778 auth->curve->hash_len) < 0) in dpp_auth_build_resp_ok()
2781 if (auth->own_bi && auth->peer_bi) { in dpp_auth_build_resp_ok()
2783 if (dpp_auth_derive_l_responder(auth) < 0) in dpp_auth_build_resp_ok()
2787 if (dpp_derive_ke(auth, auth->ke, auth->curve->hash_len) < 0) in dpp_auth_build_resp_ok()
2792 WPA_PUT_LE16(&r_auth[2], auth->curve->hash_len); in dpp_auth_build_resp_ok()
2793 if (dpp_gen_r_auth(auth, r_auth + 4) < 0) in dpp_auth_build_resp_ok()
2798 r_auth[4 + auth->curve->hash_len / 2] ^= 0x01; in dpp_auth_build_resp_ok()
2801 if (aes_siv_encrypt(auth->ke, auth->curve->hash_len, in dpp_auth_build_resp_ok()
2802 r_auth, 4 + auth->curve->hash_len, in dpp_auth_build_resp_ok()
2805 wrapped_r_auth_len = 4 + auth->curve->hash_len + AES_BLOCK_SIZE; in dpp_auth_build_resp_ok()
2810 r_pubkey_hash = auth->own_bi->pubkey_hash; in dpp_auth_build_resp_ok()
2811 if (auth->peer_bi) in dpp_auth_build_resp_ok()
2812 i_pubkey_hash = auth->peer_bi->pubkey_hash; in dpp_auth_build_resp_ok()
2816 i_nonce = auth->i_nonce; in dpp_auth_build_resp_ok()
2817 r_nonce = auth->r_nonce; in dpp_auth_build_resp_ok()
2850 pr = wpabuf_alloc(2 * auth->curve->prime_len); in dpp_auth_build_resp_ok()
2851 if (!pr || dpp_test_gen_invalid_key(pr, auth->curve) < 0) in dpp_auth_build_resp_ok()
2872 msg = dpp_auth_build_resp(auth, status, pr, nonce_len, in dpp_auth_build_resp_ok()
2876 auth->k2); in dpp_auth_build_resp_ok()
2879 wpabuf_free(auth->resp_msg); in dpp_auth_build_resp_ok()
2880 auth->resp_msg = msg; in dpp_auth_build_resp_ok()
2888 static int dpp_auth_build_resp_status(struct dpp_authentication *auth, in dpp_auth_build_resp_status() argument
2897 if (!auth->own_bi) in dpp_auth_build_resp_status()
2901 r_pubkey_hash = auth->own_bi->pubkey_hash; in dpp_auth_build_resp_status()
2902 if (auth->peer_bi) in dpp_auth_build_resp_status()
2903 i_pubkey_hash = auth->peer_bi->pubkey_hash; in dpp_auth_build_resp_status()
2907 i_nonce = auth->i_nonce; in dpp_auth_build_resp_status()
2942 msg = dpp_auth_build_resp(auth, status, NULL, auth->curve->nonce_len, in dpp_auth_build_resp_status()
2944 NULL, i_nonce, NULL, 0, auth->k1); in dpp_auth_build_resp_status()
2947 wpabuf_free(auth->resp_msg); in dpp_auth_build_resp_status()
2948 auth->resp_msg = msg; in dpp_auth_build_resp_status()
2971 struct dpp_authentication *auth = NULL; in dpp_auth_req_rx() local
2996 auth = os_zalloc(sizeof(*auth)); in dpp_auth_req_rx()
2997 if (!auth) in dpp_auth_req_rx()
2999 auth->msg_ctx = msg_ctx; in dpp_auth_req_rx()
3000 auth->peer_bi = peer_bi; in dpp_auth_req_rx()
3001 auth->own_bi = own_bi; in dpp_auth_req_rx()
3002 auth->curve = own_bi->curve; in dpp_auth_req_rx()
3003 auth->curr_freq = freq; in dpp_auth_req_rx()
3005 auth->peer_version = 1; /* default to the first version */ in dpp_auth_req_rx()
3011 dpp_auth_fail(auth, in dpp_auth_req_rx()
3015 auth->peer_version = version[0]; in dpp_auth_req_rx()
3017 auth->peer_version); in dpp_auth_req_rx()
3027 dpp_auth_fail(auth, "Too short Channel attribute"); in dpp_auth_req_rx()
3036 dpp_auth_fail(auth, in dpp_auth_req_rx()
3041 if (auth->curr_freq != (unsigned int) neg_freq) { in dpp_auth_req_rx()
3045 auth->curr_freq = neg_freq; in dpp_auth_req_rx()
3052 dpp_auth_fail(auth, in dpp_auth_req_rx()
3062 dpp_auth_fail(auth, "Invalid Initiator Protocol Key"); in dpp_auth_req_rx()
3073 EVP_PKEY_derive(ctx, auth->Mx, &secret_len) != 1) { in dpp_auth_req_rx()
3077 dpp_auth_fail(auth, "Failed to derive ECDH shared secret"); in dpp_auth_req_rx()
3080 auth->secret_len = secret_len; in dpp_auth_req_rx()
3085 auth->Mx, auth->secret_len); in dpp_auth_req_rx()
3086 auth->Mx_len = auth->secret_len; in dpp_auth_req_rx()
3088 if (dpp_derive_k1(auth->Mx, auth->secret_len, auth->k1, in dpp_auth_req_rx()
3089 auth->curve->hash_len) < 0) in dpp_auth_req_rx()
3104 if (aes_siv_decrypt(auth->k1, auth->curve->hash_len, in dpp_auth_req_rx()
3107 dpp_auth_fail(auth, "AES-SIV decryption failed"); in dpp_auth_req_rx()
3114 dpp_auth_fail(auth, "Invalid attribute in unwrapped data"); in dpp_auth_req_rx()
3120 if (!i_nonce || i_nonce_len != auth->curve->nonce_len) { in dpp_auth_req_rx()
3121 dpp_auth_fail(auth, "Missing or invalid I-nonce"); in dpp_auth_req_rx()
3125 os_memcpy(auth->i_nonce, i_nonce, i_nonce_len); in dpp_auth_req_rx()
3131 dpp_auth_fail(auth, "Missing or invalid I-capabilities"); in dpp_auth_req_rx()
3134 auth->i_capab = i_capab[0]; in dpp_auth_req_rx()
3135 wpa_printf(MSG_DEBUG, "DPP: I-capabilities: 0x%02x", auth->i_capab); in dpp_auth_req_rx()
3140 switch (auth->i_capab & DPP_CAPAB_ROLE_MASK) { in dpp_auth_req_rx()
3148 auth->configurator = 1; in dpp_auth_req_rx()
3157 auth->configurator = 0; in dpp_auth_req_rx()
3162 auth->configurator = 0; in dpp_auth_req_rx()
3165 auth->configurator = 1; in dpp_auth_req_rx()
3174 wpa_msg(auth->msg_ctx, MSG_INFO, in dpp_auth_req_rx()
3176 auth->i_capab & DPP_CAPAB_ROLE_MASK); in dpp_auth_req_rx()
3180 auth->peer_protocol_key = pi; in dpp_auth_req_rx()
3187 if (dpp_auth_build_resp_status(auth, in dpp_auth_req_rx()
3194 auth->response_pending = 1; in dpp_auth_req_rx()
3195 os_memcpy(auth->waiting_pubkey_hash, in dpp_auth_req_rx()
3203 wpa_msg(auth->msg_ctx, MSG_INFO, DPP_EVENT_SCAN_PEER_QR_CODE in dpp_auth_req_rx()
3205 return auth; in dpp_auth_req_rx()
3207 if (dpp_auth_build_resp_ok(auth) < 0) in dpp_auth_req_rx()
3210 return auth; in dpp_auth_req_rx()
3213 wpa_msg(auth->msg_ctx, MSG_INFO, DPP_EVENT_NOT_COMPATIBLE in dpp_auth_req_rx()
3214 "i-capab=0x%02x", auth->i_capab); in dpp_auth_req_rx()
3216 auth->configurator = 1; in dpp_auth_req_rx()
3218 auth->configurator = 0; in dpp_auth_req_rx()
3219 auth->peer_protocol_key = pi; in dpp_auth_req_rx()
3221 if (dpp_auth_build_resp_status(auth, DPP_STATUS_NOT_COMPATIBLE) < 0) in dpp_auth_req_rx()
3224 auth->remove_on_tx_status = 1; in dpp_auth_req_rx()
3225 return auth; in dpp_auth_req_rx()
3230 dpp_auth_deinit(auth); in dpp_auth_req_rx()
3235 int dpp_notify_new_qr_code(struct dpp_authentication *auth, in dpp_notify_new_qr_code() argument
3238 if (!auth || !auth->response_pending || in dpp_notify_new_qr_code()
3239 os_memcmp(auth->waiting_pubkey_hash, peer_bi->pubkey_hash, in dpp_notify_new_qr_code()
3245 MACSTR, MAC2STR(auth->peer_mac_addr)); in dpp_notify_new_qr_code()
3246 auth->peer_bi = peer_bi; in dpp_notify_new_qr_code()
3248 if (dpp_auth_build_resp_ok(auth) < 0) in dpp_notify_new_qr_code()
3255 static struct wpabuf * dpp_auth_build_conf(struct dpp_authentication *auth, in dpp_auth_build_conf() argument
3275 i_auth_len = 4 + auth->curve->hash_len; in dpp_auth_build_conf()
3276 r_nonce_len = 4 + auth->curve->nonce_len; in dpp_auth_build_conf()
3290 r_pubkey_hash = auth->peer_bi->pubkey_hash; in dpp_auth_build_conf()
3291 if (auth->own_bi) in dpp_auth_build_conf()
3292 i_pubkey_hash = auth->own_bi->pubkey_hash; in dpp_auth_build_conf()
3376 WPA_PUT_LE16(&i_auth[2], auth->curve->hash_len); in dpp_auth_build_conf()
3377 if (dpp_gen_i_auth(auth, i_auth + 4) < 0) in dpp_auth_build_conf()
3383 i_auth[4 + auth->curve->hash_len / 2] ^= 0x01; in dpp_auth_build_conf()
3387 if (aes_siv_encrypt(auth->ke, auth->curve->hash_len, in dpp_auth_build_conf()
3400 WPA_PUT_LE16(&r_nonce[2], auth->curve->nonce_len); in dpp_auth_build_conf()
3401 os_memcpy(r_nonce + 4, auth->r_nonce, auth->curve->nonce_len); in dpp_auth_build_conf()
3403 if (aes_siv_encrypt(auth->k2, auth->curve->hash_len, in dpp_auth_build_conf()
3423 dpp_auth_success(auth); in dpp_auth_build_conf()
3434 dpp_auth_resp_rx_status(struct dpp_authentication *auth, const u8 *hdr, in dpp_auth_resp_rx_status() argument
3456 dpp_auth_fail(auth, "Responder reported failure"); in dpp_auth_resp_rx_status()
3472 if (aes_siv_decrypt(auth->k1, auth->curve->hash_len, in dpp_auth_resp_rx_status()
3475 dpp_auth_fail(auth, "AES-SIV decryption failed"); in dpp_auth_resp_rx_status()
3482 dpp_auth_fail(auth, "Invalid attribute in unwrapped data"); in dpp_auth_resp_rx_status()
3488 if (!i_nonce || i_nonce_len != auth->curve->nonce_len) { in dpp_auth_resp_rx_status()
3489 dpp_auth_fail(auth, "Missing or invalid I-nonce"); in dpp_auth_resp_rx_status()
3493 if (os_memcmp(auth->i_nonce, i_nonce, i_nonce_len) != 0) { in dpp_auth_resp_rx_status()
3494 dpp_auth_fail(auth, "I-nonce mismatch"); in dpp_auth_resp_rx_status()
3502 dpp_auth_fail(auth, "Missing or invalid R-capabilities"); in dpp_auth_resp_rx_status()
3505 auth->r_capab = r_capab[0]; in dpp_auth_resp_rx_status()
3506 wpa_printf(MSG_DEBUG, "DPP: R-capabilities: 0x%02x", auth->r_capab); in dpp_auth_resp_rx_status()
3508 wpa_msg(auth->msg_ctx, MSG_INFO, DPP_EVENT_NOT_COMPATIBLE in dpp_auth_resp_rx_status()
3509 "r-capab=0x%02x", auth->r_capab); in dpp_auth_resp_rx_status()
3511 u8 role = auth->r_capab & DPP_CAPAB_ROLE_MASK; in dpp_auth_resp_rx_status()
3513 if ((auth->configurator && role != DPP_CAPAB_ENROLLEE) || in dpp_auth_resp_rx_status()
3514 (!auth->configurator && role != DPP_CAPAB_CONFIGURATOR)) { in dpp_auth_resp_rx_status()
3515 wpa_msg(auth->msg_ctx, MSG_INFO, in dpp_auth_resp_rx_status()
3521 wpa_msg(auth->msg_ctx, MSG_INFO, in dpp_auth_resp_rx_status()
3523 auth->tmp_own_bi ? auth->tmp_own_bi->uri : ""); in dpp_auth_resp_rx_status()
3532 dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr, in dpp_auth_resp_rx() argument
3562 if (!auth->initiator || !auth->peer_bi) { in dpp_auth_resp_rx()
3563 dpp_auth_fail(auth, "Unexpected Authentication Response"); in dpp_auth_resp_rx()
3567 auth->waiting_auth_resp = 0; in dpp_auth_resp_rx()
3572 dpp_auth_fail(auth, in dpp_auth_resp_rx()
3585 dpp_auth_fail(auth, in dpp_auth_resp_rx()
3591 if (os_memcmp(r_bootstrap, auth->peer_bi->pubkey_hash, in dpp_auth_resp_rx()
3593 dpp_auth_fail(auth, in dpp_auth_resp_rx()
3597 auth->peer_bi->pubkey_hash, SHA256_MAC_LEN); in dpp_auth_resp_rx()
3606 dpp_auth_fail(auth, in dpp_auth_resp_rx()
3613 if (!auth->own_bi || in dpp_auth_resp_rx()
3614 os_memcmp(i_bootstrap, auth->own_bi->pubkey_hash, in dpp_auth_resp_rx()
3616 dpp_auth_fail(auth, in dpp_auth_resp_rx()
3620 } else if (auth->own_bi && auth->own_bi->type == DPP_BOOTSTRAP_PKEX) { in dpp_auth_resp_rx()
3622 dpp_auth_fail(auth, in dpp_auth_resp_rx()
3627 auth->peer_version = 1; /* default to the first version */ in dpp_auth_resp_rx()
3633 dpp_auth_fail(auth, in dpp_auth_resp_rx()
3637 auth->peer_version = version[0]; in dpp_auth_resp_rx()
3639 auth->peer_version); in dpp_auth_resp_rx()
3646 dpp_auth_fail(auth, in dpp_auth_resp_rx()
3651 auth->auth_resp_status = status[0]; in dpp_auth_resp_rx()
3653 dpp_auth_resp_rx_status(auth, hdr, attr_start, in dpp_auth_resp_rx()
3659 if (!i_bootstrap && auth->own_bi) { in dpp_auth_resp_rx()
3662 auth->own_bi = NULL; in dpp_auth_resp_rx()
3665 wpa_msg(auth->msg_ctx, MSG_INFO, DPP_EVENT_AUTH_DIRECTION "mutual=%d", in dpp_auth_resp_rx()
3666 auth->own_bi != NULL); in dpp_auth_resp_rx()
3671 dpp_auth_fail(auth, in dpp_auth_resp_rx()
3679 pr = dpp_set_pubkey_point(auth->own_protocol_key, r_proto, r_proto_len); in dpp_auth_resp_rx()
3681 dpp_auth_fail(auth, "Invalid Responder Protocol Key"); in dpp_auth_resp_rx()
3686 ctx = EVP_PKEY_CTX_new(auth->own_protocol_key, NULL); in dpp_auth_resp_rx()
3692 EVP_PKEY_derive(ctx, auth->Nx, &secret_len) != 1) { in dpp_auth_resp_rx()
3696 dpp_auth_fail(auth, "Failed to derive ECDH shared secret"); in dpp_auth_resp_rx()
3701 auth->peer_protocol_key = pr; in dpp_auth_resp_rx()
3705 auth->Nx, auth->secret_len); in dpp_auth_resp_rx()
3706 auth->Nx_len = auth->secret_len; in dpp_auth_resp_rx()
3708 if (dpp_derive_k2(auth->Nx, auth->secret_len, auth->k2, in dpp_auth_resp_rx()
3709 auth->curve->hash_len) < 0) in dpp_auth_resp_rx()
3724 if (aes_siv_decrypt(auth->k2, auth->curve->hash_len, in dpp_auth_resp_rx()
3727 dpp_auth_fail(auth, "AES-SIV decryption failed"); in dpp_auth_resp_rx()
3734 dpp_auth_fail(auth, "Invalid attribute in unwrapped data"); in dpp_auth_resp_rx()
3740 if (!r_nonce || r_nonce_len != auth->curve->nonce_len) { in dpp_auth_resp_rx()
3741 dpp_auth_fail(auth, "DPP: Missing or invalid R-nonce"); in dpp_auth_resp_rx()
3745 os_memcpy(auth->r_nonce, r_nonce, r_nonce_len); in dpp_auth_resp_rx()
3749 if (!i_nonce || i_nonce_len != auth->curve->nonce_len) { in dpp_auth_resp_rx()
3750 dpp_auth_fail(auth, "Missing or invalid I-nonce"); in dpp_auth_resp_rx()
3754 if (os_memcmp(auth->i_nonce, i_nonce, i_nonce_len) != 0) { in dpp_auth_resp_rx()
3755 dpp_auth_fail(auth, "I-nonce mismatch"); in dpp_auth_resp_rx()
3759 if (auth->own_bi) { in dpp_auth_resp_rx()
3761 if (dpp_auth_derive_l_initiator(auth) < 0) in dpp_auth_resp_rx()
3769 dpp_auth_fail(auth, "Missing or invalid R-capabilities"); in dpp_auth_resp_rx()
3772 auth->r_capab = r_capab[0]; in dpp_auth_resp_rx()
3773 wpa_printf(MSG_DEBUG, "DPP: R-capabilities: 0x%02x", auth->r_capab); in dpp_auth_resp_rx()
3774 role = auth->r_capab & DPP_CAPAB_ROLE_MASK; in dpp_auth_resp_rx()
3775 if ((auth->allowed_roles == in dpp_auth_resp_rx()
3780 auth->configurator = role == DPP_CAPAB_ENROLLEE; in dpp_auth_resp_rx()
3782 auth->configurator ? "Configurator" : "Enrollee"); in dpp_auth_resp_rx()
3783 } else if ((auth->configurator && role != DPP_CAPAB_ENROLLEE) || in dpp_auth_resp_rx()
3784 (!auth->configurator && role != DPP_CAPAB_CONFIGURATOR)) { in dpp_auth_resp_rx()
3786 wpa_msg(auth->msg_ctx, MSG_INFO, DPP_EVENT_FAIL in dpp_auth_resp_rx()
3793 auth->remove_on_tx_status = 1; in dpp_auth_resp_rx()
3794 return dpp_auth_build_conf(auth, DPP_STATUS_NOT_COMPATIBLE); in dpp_auth_resp_rx()
3800 dpp_auth_fail(auth, in dpp_auth_resp_rx()
3808 if (dpp_derive_ke(auth, auth->ke, auth->curve->hash_len) < 0) in dpp_auth_resp_rx()
3815 if (aes_siv_decrypt(auth->ke, auth->curve->hash_len, in dpp_auth_resp_rx()
3818 dpp_auth_fail(auth, "AES-SIV decryption failed"); in dpp_auth_resp_rx()
3825 dpp_auth_fail(auth, in dpp_auth_resp_rx()
3832 if (!r_auth || r_auth_len != auth->curve->hash_len) { in dpp_auth_resp_rx()
3833 dpp_auth_fail(auth, in dpp_auth_resp_rx()
3840 if (dpp_gen_r_auth(auth, r_auth2) < 0) in dpp_auth_resp_rx()
3845 dpp_auth_fail(auth, "Mismatching Responder Authenticating Tag"); in dpp_auth_resp_rx()
3848 auth->remove_on_tx_status = 1; in dpp_auth_resp_rx()
3849 return dpp_auth_build_conf(auth, DPP_STATUS_AUTH_FAILURE); in dpp_auth_resp_rx()
3859 if (dpp_auth_build_resp_ok(auth) < 0) in dpp_auth_resp_rx()
3861 return wpabuf_dup(auth->resp_msg); in dpp_auth_resp_rx()
3865 return dpp_auth_build_conf(auth, DPP_STATUS_OK); in dpp_auth_resp_rx()
3876 static int dpp_auth_conf_rx_failure(struct dpp_authentication *auth, in dpp_auth_conf_rx_failure() argument
3904 dpp_auth_fail(auth, "Authentication failed"); in dpp_auth_conf_rx_failure()
3907 if (aes_siv_decrypt(auth->k2, auth->curve->hash_len, in dpp_auth_conf_rx_failure()
3910 dpp_auth_fail(auth, "AES-SIV decryption failed"); in dpp_auth_conf_rx_failure()
3917 dpp_auth_fail(auth, "Invalid attribute in unwrapped data"); in dpp_auth_conf_rx_failure()
3923 if (!r_nonce || r_nonce_len != auth->curve->nonce_len) { in dpp_auth_conf_rx_failure()
3924 dpp_auth_fail(auth, "DPP: Missing or invalid R-nonce"); in dpp_auth_conf_rx_failure()
3927 if (os_memcmp(r_nonce, auth->r_nonce, r_nonce_len) != 0) { in dpp_auth_conf_rx_failure()
3931 auth->r_nonce, r_nonce_len); in dpp_auth_conf_rx_failure()
3932 dpp_auth_fail(auth, "R-nonce mismatch"); in dpp_auth_conf_rx_failure()
3937 dpp_auth_fail(auth, "Peer reported incompatible R-capab role"); in dpp_auth_conf_rx_failure()
3939 dpp_auth_fail(auth, "Peer reported authentication failure)"); in dpp_auth_conf_rx_failure()
3947 int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr, in dpp_auth_conf_rx() argument
3967 if (auth->initiator || !auth->own_bi) { in dpp_auth_conf_rx()
3968 dpp_auth_fail(auth, "Unexpected Authentication Confirm"); in dpp_auth_conf_rx()
3972 auth->waiting_auth_conf = 0; in dpp_auth_conf_rx()
3977 dpp_auth_fail(auth, in dpp_auth_conf_rx()
3990 dpp_auth_fail(auth, in dpp_auth_conf_rx()
3996 if (os_memcmp(r_bootstrap, auth->own_bi->pubkey_hash, in dpp_auth_conf_rx()
4000 auth->peer_bi->pubkey_hash, SHA256_MAC_LEN); in dpp_auth_conf_rx()
4001 dpp_auth_fail(auth, in dpp_auth_conf_rx()
4011 dpp_auth_fail(auth, in dpp_auth_conf_rx()
4018 if (!auth->peer_bi || in dpp_auth_conf_rx()
4019 os_memcmp(i_bootstrap, auth->peer_bi->pubkey_hash, in dpp_auth_conf_rx()
4021 dpp_auth_fail(auth, in dpp_auth_conf_rx()
4025 } else if (auth->peer_bi) { in dpp_auth_conf_rx()
4028 dpp_auth_fail(auth, in dpp_auth_conf_rx()
4036 dpp_auth_fail(auth, in dpp_auth_conf_rx()
4043 return dpp_auth_conf_rx_failure(auth, hdr, attr_start, in dpp_auth_conf_rx()
4048 dpp_auth_fail(auth, "Authentication failed"); in dpp_auth_conf_rx()
4064 if (aes_siv_decrypt(auth->ke, auth->curve->hash_len, in dpp_auth_conf_rx()
4067 dpp_auth_fail(auth, "AES-SIV decryption failed"); in dpp_auth_conf_rx()
4074 dpp_auth_fail(auth, "Invalid attribute in unwrapped data"); in dpp_auth_conf_rx()
4080 if (!i_auth || i_auth_len != auth->curve->hash_len) { in dpp_auth_conf_rx()
4081 dpp_auth_fail(auth, in dpp_auth_conf_rx()
4088 if (dpp_gen_i_auth(auth, i_auth2) < 0) in dpp_auth_conf_rx()
4093 dpp_auth_fail(auth, "Mismatching Initiator Authenticating Tag"); in dpp_auth_conf_rx()
4098 dpp_auth_success(auth); in dpp_auth_conf_rx()
4209 static int dpp_configuration_parse(struct dpp_authentication *auth, in dpp_configuration_parse() argument
4306 auth->conf_sta = conf_sta; in dpp_configuration_parse()
4307 auth->conf_ap = conf_ap; in dpp_configuration_parse()
4335 struct dpp_authentication *auth, in dpp_set_configurator() argument
4348 auth->conf = dpp_configurator_get_id(dpp, atoi(pos)); in dpp_set_configurator()
4349 if (!auth->conf) { in dpp_set_configurator()
4356 if (dpp_configuration_parse(auth, cmd) < 0) { in dpp_set_configurator()
4365 void dpp_auth_deinit(struct dpp_authentication *auth) in dpp_auth_deinit() argument
4367 if (!auth) in dpp_auth_deinit()
4369 dpp_configuration_free(auth->conf_ap); in dpp_auth_deinit()
4370 dpp_configuration_free(auth->conf_sta); in dpp_auth_deinit()
4371 EVP_PKEY_free(auth->own_protocol_key); in dpp_auth_deinit()
4372 EVP_PKEY_free(auth->peer_protocol_key); in dpp_auth_deinit()
4373 wpabuf_free(auth->req_msg); in dpp_auth_deinit()
4374 wpabuf_free(auth->resp_msg); in dpp_auth_deinit()
4375 wpabuf_free(auth->conf_req); in dpp_auth_deinit()
4376 os_free(auth->connector); in dpp_auth_deinit()
4377 wpabuf_free(auth->net_access_key); in dpp_auth_deinit()
4378 wpabuf_free(auth->c_sign_key); in dpp_auth_deinit()
4379 dpp_bootstrap_info_free(auth->tmp_own_bi); in dpp_auth_deinit()
4381 os_free(auth->config_obj_override); in dpp_auth_deinit()
4382 os_free(auth->discovery_override); in dpp_auth_deinit()
4383 os_free(auth->groups_override); in dpp_auth_deinit()
4385 bin_clear_free(auth, sizeof(*auth)); in dpp_auth_deinit()
4390 dpp_build_conf_start(struct dpp_authentication *auth, in dpp_build_conf_start() argument
4397 if (auth->discovery_override) in dpp_build_conf_start()
4398 tailroom += os_strlen(auth->discovery_override); in dpp_build_conf_start()
4406 if (auth->discovery_override) { in dpp_build_conf_start()
4408 auth->discovery_override); in dpp_build_conf_start()
4409 wpabuf_put_str(buf, auth->discovery_override); in dpp_build_conf_start()
4490 dpp_build_conf_obj_dpp(struct dpp_authentication *auth, int ap, in dpp_build_conf_obj_dpp() argument
4512 if (!auth->conf) { in dpp_build_conf_obj_dpp()
4517 curve = auth->conf->curve; in dpp_build_conf_obj_dpp()
4530 if (dpp_akm_ver2(akm) && auth->peer_version < 2) { in dpp_build_conf_obj_dpp()
4537 if (auth->groups_override) in dpp_build_conf_obj_dpp()
4538 extra_len += os_strlen(auth->groups_override); in dpp_build_conf_obj_dpp()
4545 dppcon = wpabuf_alloc(extra_len + 2 * auth->curve->prime_len * 4 / 3); in dpp_build_conf_obj_dpp()
4549 if (auth->groups_override) { in dpp_build_conf_obj_dpp()
4551 if (auth->groups_override) { in dpp_build_conf_obj_dpp()
4554 auth->groups_override); in dpp_build_conf_obj_dpp()
4556 wpabuf_put_str(dppcon, auth->groups_override); in dpp_build_conf_obj_dpp()
4568 if (dpp_build_jwk(dppcon, "netAccessKey", auth->peer_protocol_key, NULL, in dpp_build_conf_obj_dpp()
4569 auth->curve) < 0) { in dpp_build_conf_obj_dpp()
4592 auth->conf->kid, curve->jws_alg); in dpp_build_conf_obj_dpp()
4608 auth->conf->csign) != 1) { in dpp_build_conf_obj_dpp()
4655 tailroom += 2 * curve->prime_len * 4 / 3 + os_strlen(auth->conf->kid); in dpp_build_conf_obj_dpp()
4659 buf = dpp_build_conf_start(auth, conf, tailroom); in dpp_build_conf_obj_dpp()
4675 if (dpp_build_jwk(buf, "csign", auth->conf->csign, auth->conf->kid, in dpp_build_conf_obj_dpp()
4704 dpp_build_conf_obj_legacy(struct dpp_authentication *auth, int ap, in dpp_build_conf_obj_legacy() argument
4709 buf = dpp_build_conf_start(auth, conf, 1000); in dpp_build_conf_obj_legacy()
4725 dpp_build_conf_obj(struct dpp_authentication *auth, int ap) in dpp_build_conf_obj() argument
4730 if (auth->config_obj_override) { in dpp_build_conf_obj()
4732 return wpabuf_alloc_copy(auth->config_obj_override, in dpp_build_conf_obj()
4733 os_strlen(auth->config_obj_override)); in dpp_build_conf_obj()
4737 conf = ap ? auth->conf_ap : auth->conf_sta; in dpp_build_conf_obj()
4746 return dpp_build_conf_obj_dpp(auth, ap, conf); in dpp_build_conf_obj()
4747 return dpp_build_conf_obj_legacy(auth, ap, conf); in dpp_build_conf_obj()
4752 dpp_build_conf_resp(struct dpp_authentication *auth, const u8 *e_nonce, in dpp_build_conf_resp() argument
4763 conf = dpp_build_conf_obj(auth, ap); in dpp_build_conf_resp()
4769 auth->conf_resp_status = status; in dpp_build_conf_resp()
4851 if (aes_siv_encrypt(auth->ke, auth->curve->hash_len, in dpp_build_conf_resp()
4881 dpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start, in dpp_conf_req_rx() argument
4901 dpp_auth_fail(auth, "Invalid attribute in config request"); in dpp_conf_req_rx()
4908 dpp_auth_fail(auth, in dpp_conf_req_rx()
4919 if (aes_siv_decrypt(auth->ke, auth->curve->hash_len, in dpp_conf_req_rx()
4922 dpp_auth_fail(auth, "AES-SIV decryption failed"); in dpp_conf_req_rx()
4929 dpp_auth_fail(auth, "Invalid attribute in unwrapped data"); in dpp_conf_req_rx()
4936 if (!e_nonce || e_nonce_len != auth->curve->nonce_len) { in dpp_conf_req_rx()
4937 dpp_auth_fail(auth, in dpp_conf_req_rx()
4942 os_memcpy(auth->e_nonce, e_nonce, e_nonce_len); in dpp_conf_req_rx()
4948 dpp_auth_fail(auth, in dpp_conf_req_rx()
4957 dpp_auth_fail(auth, "Could not parse Config Attributes"); in dpp_conf_req_rx()
4963 dpp_auth_fail(auth, "No Config Attributes - name"); in dpp_conf_req_rx()
4970 dpp_auth_fail(auth, "No Config Attributes - wi-fi_tech"); in dpp_conf_req_rx()
4977 dpp_auth_fail(auth, "Unsupported wi-fi_tech"); in dpp_conf_req_rx()
4983 dpp_auth_fail(auth, "No Config Attributes - netRole"); in dpp_conf_req_rx()
4994 dpp_auth_fail(auth, "Unsupported netRole"); in dpp_conf_req_rx()
4998 resp = dpp_build_conf_resp(auth, e_nonce, e_nonce_len, ap); in dpp_conf_req_rx()
5087 static int dpp_parse_cred_legacy(struct dpp_authentication *auth, in dpp_parse_cred_legacy() argument
5104 os_strlcpy(auth->passphrase, pass->string, in dpp_parse_cred_legacy()
5105 sizeof(auth->passphrase)); in dpp_parse_cred_legacy()
5107 if (dpp_akm_sae(auth->akm) && !dpp_akm_psk(auth->akm)) { in dpp_parse_cred_legacy()
5113 hexstr2bin(psk_hex->string, auth->psk, PMK_LEN) < 0) { in dpp_parse_cred_legacy()
5118 auth->psk, PMK_LEN); in dpp_parse_cred_legacy()
5119 auth->psk_set = 1; in dpp_parse_cred_legacy()
5125 if (dpp_akm_sae(auth->akm) && !auth->passphrase[0]) { in dpp_parse_cred_legacy()
5291 static int dpp_parse_connector(struct dpp_authentication *auth, in dpp_parse_connector() argument
5346 &auth->net_access_key_expiry)) { in dpp_parse_connector()
5364 if (EVP_PKEY_cmp(key, auth->own_protocol_key) != 1) { in dpp_parse_connector()
5368 if (auth->ignore_netaccesskey_mismatch) { in dpp_parse_connector()
5419 static void dpp_copy_csign(struct dpp_authentication *auth, EVP_PKEY *csign) in dpp_copy_csign() argument
5427 wpabuf_free(auth->c_sign_key); in dpp_copy_csign()
5428 auth->c_sign_key = wpabuf_alloc_copy(der, der_len); in dpp_copy_csign()
5433 static void dpp_copy_netaccesskey(struct dpp_authentication *auth) in dpp_copy_netaccesskey() argument
5439 eckey = EVP_PKEY_get1_EC_KEY(auth->own_protocol_key); in dpp_copy_netaccesskey()
5448 wpabuf_free(auth->net_access_key); in dpp_copy_netaccesskey()
5449 auth->net_access_key = wpabuf_alloc_copy(der, der_len); in dpp_copy_netaccesskey()
5626 static int dpp_parse_cred_dpp(struct dpp_authentication *auth, in dpp_parse_cred_dpp() argument
5638 if (dpp_akm_psk(auth->akm) || dpp_akm_sae(auth->akm)) { in dpp_parse_cred_dpp()
5641 if (dpp_parse_cred_legacy(auth, cred) < 0) in dpp_parse_cred_dpp()
5680 if (dpp_parse_connector(auth, info.payload, info.payload_len) < 0) { in dpp_parse_cred_dpp()
5685 os_free(auth->connector); in dpp_parse_cred_dpp()
5686 auth->connector = os_strdup(signed_connector); in dpp_parse_cred_dpp()
5688 dpp_copy_csign(auth, csign_pub); in dpp_parse_cred_dpp()
5689 dpp_copy_netaccesskey(auth); in dpp_parse_cred_dpp()
5738 static int dpp_parse_conf_obj(struct dpp_authentication *auth, in dpp_parse_conf_obj() argument
5748 dpp_auth_fail(auth, "JSON root is not an object"); in dpp_parse_conf_obj()
5754 dpp_auth_fail(auth, "No wi-fi_tech string value found"); in dpp_parse_conf_obj()
5760 dpp_auth_fail(auth, "Unsupported wi-fi_tech value"); in dpp_parse_conf_obj()
5766 dpp_auth_fail(auth, "No discovery object in JSON"); in dpp_parse_conf_obj()
5772 dpp_auth_fail(auth, "No discovery::ssid string value found"); in dpp_parse_conf_obj()
5778 dpp_auth_fail(auth, "Too long discovery::ssid string value"); in dpp_parse_conf_obj()
5781 auth->ssid_len = os_strlen(token->string); in dpp_parse_conf_obj()
5782 os_memcpy(auth->ssid, token->string, auth->ssid_len); in dpp_parse_conf_obj()
5786 dpp_auth_fail(auth, "No cred object in JSON"); in dpp_parse_conf_obj()
5792 dpp_auth_fail(auth, "No cred::akm string value found"); in dpp_parse_conf_obj()
5795 auth->akm = dpp_akm_from_str(token->string); in dpp_parse_conf_obj()
5797 if (dpp_akm_legacy(auth->akm)) { in dpp_parse_conf_obj()
5798 if (dpp_parse_cred_legacy(auth, cred) < 0) in dpp_parse_conf_obj()
5800 } else if (dpp_akm_dpp(auth->akm)) { in dpp_parse_conf_obj()
5801 if (dpp_parse_cred_dpp(auth, cred) < 0) in dpp_parse_conf_obj()
5806 dpp_auth_fail(auth, "Unsupported akm"); in dpp_parse_conf_obj()
5818 int dpp_conf_resp_rx(struct dpp_authentication *auth, in dpp_conf_resp_rx() argument
5829 auth->conf_resp_status = 255; in dpp_conf_resp_rx()
5832 dpp_auth_fail(auth, "Invalid attribute in config response"); in dpp_conf_resp_rx()
5840 dpp_auth_fail(auth, in dpp_conf_resp_rx()
5856 if (aes_siv_decrypt(auth->ke, auth->curve->hash_len, in dpp_conf_resp_rx()
5859 dpp_auth_fail(auth, "AES-SIV decryption failed"); in dpp_conf_resp_rx()
5866 dpp_auth_fail(auth, "Invalid attribute in unwrapped data"); in dpp_conf_resp_rx()
5873 if (!e_nonce || e_nonce_len != auth->curve->nonce_len) { in dpp_conf_resp_rx()
5874 dpp_auth_fail(auth, in dpp_conf_resp_rx()
5879 if (os_memcmp(e_nonce, auth->e_nonce, e_nonce_len) != 0) { in dpp_conf_resp_rx()
5880 dpp_auth_fail(auth, "Enrollee Nonce mismatch"); in dpp_conf_resp_rx()
5887 dpp_auth_fail(auth, in dpp_conf_resp_rx()
5891 auth->conf_resp_status = status[0]; in dpp_conf_resp_rx()
5894 dpp_auth_fail(auth, "Configurator rejected configuration"); in dpp_conf_resp_rx()
5901 dpp_auth_fail(auth, in dpp_conf_resp_rx()
5907 if (dpp_parse_conf_obj(auth, conf_obj, conf_obj_len) < 0) in dpp_conf_resp_rx()
5919 enum dpp_status_error dpp_conf_result_rx(struct dpp_authentication *auth, in dpp_conf_result_rx() argument
5934 dpp_auth_fail(auth, in dpp_conf_result_rx()
5955 if (aes_siv_decrypt(auth->ke, auth->curve->hash_len, in dpp_conf_result_rx()
5958 dpp_auth_fail(auth, "AES-SIV decryption failed"); in dpp_conf_result_rx()
5965 dpp_auth_fail(auth, "Invalid attribute in unwrapped data"); in dpp_conf_result_rx()
5972 if (!e_nonce || e_nonce_len != auth->curve->nonce_len) { in dpp_conf_result_rx()
5973 dpp_auth_fail(auth, in dpp_conf_result_rx()
5978 if (os_memcmp(e_nonce, auth->e_nonce, e_nonce_len) != 0) { in dpp_conf_result_rx()
5979 dpp_auth_fail(auth, "Enrollee Nonce mismatch"); in dpp_conf_result_rx()
5981 auth->e_nonce, e_nonce_len); in dpp_conf_result_rx()
5988 dpp_auth_fail(auth, in dpp_conf_result_rx()
6002 struct wpabuf * dpp_build_conf_result(struct dpp_authentication *auth, in dpp_build_conf_result() argument
6011 nonce_len = auth->curve->nonce_len; in dpp_build_conf_result()
6025 wpabuf_put_data(clear, auth->e_nonce, nonce_len); in dpp_build_conf_result()
6043 if (aes_siv_encrypt(auth->ke, auth->curve->hash_len, in dpp_build_conf_result()
6155 int dpp_configurator_own_config(struct dpp_authentication *auth, in dpp_configurator_own_config() argument
6161 if (!auth->conf) { in dpp_configurator_own_config()
6167 auth->curve = &dpp_curves[0]; in dpp_configurator_own_config()
6169 auth->curve = dpp_get_curve_name(curve); in dpp_configurator_own_config()
6170 if (!auth->curve) { in dpp_configurator_own_config()
6178 auth->curve->name); in dpp_configurator_own_config()
6180 auth->own_protocol_key = dpp_gen_keypair(auth->curve); in dpp_configurator_own_config()
6181 if (!auth->own_protocol_key) in dpp_configurator_own_config()
6183 dpp_copy_netaccesskey(auth); in dpp_configurator_own_config()
6184 auth->peer_protocol_key = auth->own_protocol_key; in dpp_configurator_own_config()
6185 dpp_copy_csign(auth, auth->conf->csign); in dpp_configurator_own_config()
6187 conf_obj = dpp_build_conf_obj(auth, ap); in dpp_configurator_own_config()
6190 ret = dpp_parse_conf_obj(auth, wpabuf_head(conf_obj), in dpp_configurator_own_config()
6194 auth->peer_protocol_key = NULL; in dpp_configurator_own_config()