blob: 0f31ae56a5261ad604675fe6e89335e9206fabce [file] [log] [blame]
Hai Shalom4fbc08f2020-05-18 12:37:00 -07001/*
2 * DPP module internal definitions
3 * Copyright (c) 2017, Qualcomm Atheros, Inc.
4 * Copyright (c) 2018-2020, The Linux Foundation
Hai Shaloma20dcd72022-02-04 13:43:00 -08005 * Copyright (c) 2021-2022, Qualcomm Innovation Center, Inc.
Hai Shalom4fbc08f2020-05-18 12:37:00 -07006 *
7 * This software may be distributed under the terms of the BSD license.
8 * See README for more details.
9 */
10
11#ifndef DPP_I_H
12#define DPP_I_H
13
14#ifdef CONFIG_DPP
15
16struct dpp_global {
17 void *msg_ctx;
18 struct dl_list bootstrap; /* struct dpp_bootstrap_info */
19 struct dl_list configurator; /* struct dpp_configurator */
20#ifdef CONFIG_DPP2
21 struct dl_list controllers; /* struct dpp_relay_controller */
22 struct dpp_controller *controller;
23 struct dl_list tcp_init; /* struct dpp_connection */
24 void *cb_ctx;
25 int (*process_conf_obj)(void *ctx, struct dpp_authentication *auth);
Hai Shaloma20dcd72022-02-04 13:43:00 -080026 bool (*tcp_msg_sent)(void *ctx, struct dpp_authentication *auth);
Hai Shalom4fbc08f2020-05-18 12:37:00 -070027 void (*remove_bi)(void *ctx, struct dpp_bootstrap_info *bi);
28#endif /* CONFIG_DPP2 */
29};
30
31/* dpp.c */
32
33void dpp_build_attr_status(struct wpabuf *msg, enum dpp_status_error status);
34void dpp_build_attr_r_bootstrap_key_hash(struct wpabuf *msg, const u8 *hash);
35unsigned int dpp_next_id(struct dpp_global *dpp);
36struct wpabuf * dpp_build_conn_status(enum dpp_status_error result,
37 const u8 *ssid, size_t ssid_len,
38 const char *channel_list);
39struct json_token * dpp_parse_own_connector(const char *own_connector);
40int dpp_connector_match_groups(struct json_token *own_root,
41 struct json_token *peer_root, bool reconfig);
Hai Shaloma20dcd72022-02-04 13:43:00 -080042int dpp_build_jwk(struct wpabuf *buf, const char *name,
43 struct crypto_ec_key *key, const char *kid,
44 const struct dpp_curve_params *curve);
45struct crypto_ec_key * dpp_parse_jwk(struct json_token *jwk,
46 const struct dpp_curve_params **key_curve);
Hai Shalom4fbc08f2020-05-18 12:37:00 -070047int dpp_prepare_channel_list(struct dpp_authentication *auth,
48 unsigned int neg_freq,
49 struct hostapd_hw_modes *own_modes, u16 num_modes);
50void dpp_auth_fail(struct dpp_authentication *auth, const char *txt);
51int dpp_gen_uri(struct dpp_bootstrap_info *bi);
52void dpp_write_adv_proto(struct wpabuf *buf);
53void dpp_write_gas_query(struct wpabuf *buf, struct wpabuf *query);
54
55/* dpp_backup.c */
56
57void dpp_free_asymmetric_key(struct dpp_asymmetric_key *key);
58struct wpabuf * dpp_build_enveloped_data(struct dpp_authentication *auth);
59int dpp_conf_resp_env_data(struct dpp_authentication *auth,
60 const u8 *env_data, size_t env_data_len);
61
62/* dpp_crypto.c */
63
64struct dpp_signed_connector_info {
65 unsigned char *payload;
66 size_t payload_len;
67};
68
69enum dpp_status_error
70dpp_process_signed_connector(struct dpp_signed_connector_info *info,
Hai Shaloma20dcd72022-02-04 13:43:00 -080071 struct crypto_ec_key *csign_pub,
72 const char *connector);
Hai Shalom4fbc08f2020-05-18 12:37:00 -070073enum dpp_status_error
74dpp_check_signed_connector(struct dpp_signed_connector_info *info,
75 const u8 *csign_key, size_t csign_key_len,
76 const u8 *peer_connector, size_t peer_connector_len);
77const struct dpp_curve_params * dpp_get_curve_name(const char *name);
78const struct dpp_curve_params * dpp_get_curve_jwk_crv(const char *name);
Hai Shalom899fcc72020-10-19 14:38:18 -070079const struct dpp_curve_params * dpp_get_curve_ike_group(u16 group);
Hai Shalom4fbc08f2020-05-18 12:37:00 -070080int dpp_bi_pubkey_hash(struct dpp_bootstrap_info *bi,
81 const u8 *data, size_t data_len);
Hai Shaloma20dcd72022-02-04 13:43:00 -080082struct crypto_ec_key * dpp_set_pubkey_point(struct crypto_ec_key *group_key,
83 const u8 *buf, size_t len);
Hai Shalom4fbc08f2020-05-18 12:37:00 -070084int dpp_hkdf_expand(size_t hash_len, const u8 *secret, size_t secret_len,
85 const char *label, u8 *out, size_t outlen);
86int dpp_hmac_vector(size_t hash_len, const u8 *key, size_t key_len,
87 size_t num_elem, const u8 *addr[], const size_t *len,
88 u8 *mac);
Hai Shaloma20dcd72022-02-04 13:43:00 -080089int dpp_ecdh(struct crypto_ec_key *own, struct crypto_ec_key *peer,
90 u8 *secret, size_t *secret_len);
91void dpp_debug_print_key(const char *title, struct crypto_ec_key *key);
Hai Shalom4fbc08f2020-05-18 12:37:00 -070092int dpp_pbkdf2(size_t hash_len, const u8 *password, size_t password_len,
93 const u8 *salt, size_t salt_len, unsigned int iterations,
94 u8 *buf, size_t buflen);
95int dpp_get_subject_public_key(struct dpp_bootstrap_info *bi,
96 const u8 *data, size_t data_len);
97int dpp_bootstrap_key_hash(struct dpp_bootstrap_info *bi);
98int dpp_keygen(struct dpp_bootstrap_info *bi, const char *curve,
99 const u8 *privkey, size_t privkey_len);
Hai Shaloma20dcd72022-02-04 13:43:00 -0800100struct crypto_ec_key * dpp_set_keypair(const struct dpp_curve_params **curve,
101 const u8 *privkey, size_t privkey_len);
102struct crypto_ec_key * dpp_gen_keypair(const struct dpp_curve_params *curve);
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700103int dpp_derive_k1(const u8 *Mx, size_t Mx_len, u8 *k1, unsigned int hash_len);
104int dpp_derive_k2(const u8 *Nx, size_t Nx_len, u8 *k2, unsigned int hash_len);
105int dpp_derive_bk_ke(struct dpp_authentication *auth);
106int dpp_gen_r_auth(struct dpp_authentication *auth, u8 *r_auth);
107int dpp_gen_i_auth(struct dpp_authentication *auth, u8 *i_auth);
108int dpp_auth_derive_l_responder(struct dpp_authentication *auth);
109int dpp_auth_derive_l_initiator(struct dpp_authentication *auth);
110int dpp_derive_pmk(const u8 *Nx, size_t Nx_len, u8 *pmk, unsigned int hash_len);
111int dpp_derive_pmkid(const struct dpp_curve_params *curve,
Hai Shaloma20dcd72022-02-04 13:43:00 -0800112 struct crypto_ec_key *own_key,
113 struct crypto_ec_key *peer_key, u8 *pmkid);
114struct crypto_ec_point *
115dpp_pkex_derive_Qi(const struct dpp_curve_params *curve, const u8 *mac_init,
116 const char *code, const char *identifier,
117 struct crypto_ec **ret_ec);
118struct crypto_ec_point *
119dpp_pkex_derive_Qr(const struct dpp_curve_params *curve, const u8 *mac_resp,
120 const char *code, const char *identifier,
121 struct crypto_ec **ret_ec);
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700122int dpp_pkex_derive_z(const u8 *mac_init, const u8 *mac_resp,
Hai Shaloma20dcd72022-02-04 13:43:00 -0800123 u8 ver_init, u8 ver_resp,
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700124 const u8 *Mx, size_t Mx_len,
125 const u8 *Nx, size_t Nx_len,
126 const char *code,
127 const u8 *Kx, size_t Kx_len,
128 u8 *z, unsigned int hash_len);
129int dpp_reconfig_derive_ke_responder(struct dpp_authentication *auth,
130 const u8 *net_access_key,
131 size_t net_access_key_len,
132 struct json_token *peer_net_access_key);
133int dpp_reconfig_derive_ke_initiator(struct dpp_authentication *auth,
134 const u8 *r_proto, u16 r_proto_len,
135 struct json_token *net_access_key);
Hai Shaloma20dcd72022-02-04 13:43:00 -0800136struct crypto_ec_point * dpp_decrypt_e_id(struct crypto_ec_key *ppkey,
137 struct crypto_ec_key *a_nonce,
138 struct crypto_ec_key *e_prime_id);
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700139char * dpp_sign_connector(struct dpp_configurator *conf,
140 const struct wpabuf *dppcon);
141int dpp_test_gen_invalid_key(struct wpabuf *msg,
142 const struct dpp_curve_params *curve);
143
Hai Shalom899fcc72020-10-19 14:38:18 -0700144struct dpp_reconfig_id {
Hai Shaloma20dcd72022-02-04 13:43:00 -0800145 struct crypto_ec *ec;
146 struct crypto_ec_point *e_id; /* E-id */
147 struct crypto_ec_key *csign;
148 struct crypto_ec_key *a_nonce; /* A-NONCE */
149 struct crypto_ec_key *e_prime_id; /* E'-id */
150 struct crypto_ec_key *pp_key;
Hai Shalom899fcc72020-10-19 14:38:18 -0700151};
152
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700153/* dpp_tcp.c */
154
155void dpp_controller_conn_status_result_wait_timeout(void *eloop_ctx,
156 void *timeout_ctx);
157void dpp_tcp_init_flush(struct dpp_global *dpp);
158void dpp_relay_flush_controllers(struct dpp_global *dpp);
159
160#endif /* CONFIG_DPP */
161#endif /* DPP_I_H */