diff options
Diffstat (limited to 'src/p2p')
| -rw-r--r-- | src/p2p/p2p.c | 16 | ||||
| -rw-r--r-- | src/p2p/p2p.h | 10 |
2 files changed, 23 insertions, 3 deletions
diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 104f77ba..d0191e74 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -1561,7 +1561,7 @@ void p2p_build_ssid(struct p2p_data *p2p, u8 *ssid, size_t *ssid_len) int p2p_go_params(struct p2p_data *p2p, struct p2p_go_neg_results *params) { p2p_build_ssid(p2p, params->ssid, ¶ms->ssid_len); - p2p_random(params->passphrase, 8); + p2p_random(params->passphrase, p2p->cfg->passphrase_len); return 0; } @@ -1595,7 +1595,7 @@ void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer) p2p->op_channel); os_memcpy(res.ssid, p2p->ssid, p2p->ssid_len); res.ssid_len = p2p->ssid_len; - p2p_random(res.passphrase, 8); + p2p_random(res.passphrase, p2p->cfg->passphrase_len); } else { res.freq = peer->oper_freq; if (p2p->ssid_len) { @@ -2388,7 +2388,8 @@ struct p2p_data * p2p_init(const struct p2p_config *cfg) { struct p2p_data *p2p; - if (cfg->max_peers < 1) + if (cfg->max_peers < 1 || + cfg->passphrase_len < 8 || cfg->passphrase_len > 63) return NULL; p2p = os_zalloc(sizeof(*p2p) + sizeof(*cfg)); @@ -4719,3 +4720,12 @@ void p2p_set_authorized_oob_dev_pw_id(struct p2p_data *p2p, u16 dev_pw_id, } #endif /* CONFIG_WPS_NFC */ + + +int p2p_set_passphrase_len(struct p2p_data *p2p, unsigned int len) +{ + if (len < 8 || len > 63) + return -1; + p2p->cfg->passphrase_len = len; + return 0; +} diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 9cf100fa..5938aa71 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -395,6 +395,14 @@ struct p2p_config { unsigned int max_listen; /** + * passphrase_len - Passphrase length (8..63) + * + * This parameter controls the length of the random passphrase that is + * generated at the GO. + */ + unsigned int passphrase_len; + + /** * cb_ctx - Context to use with callback functions */ void *cb_ctx; @@ -1960,4 +1968,6 @@ void p2p_set_authorized_oob_dev_pw_id(struct p2p_data *p2p, u16 dev_pw_id, int go_intent, const u8 *own_interface_addr); +int p2p_set_passphrase_len(struct p2p_data *p2p, unsigned int len); + #endif /* P2P_H */ |
