|
@@ -1626,50 +1626,10 @@ struct wpabuf * hostapd_wps_nfc_config_token(struct hostapd_data *hapd,
|
|
|
|
|
|
struct wpabuf * hostapd_wps_nfc_token_gen(struct hostapd_data *hapd, int ndef)
|
|
|
{
|
|
|
- struct wpabuf *priv = NULL, *pub = NULL, *pw;
|
|
|
- void *dh_ctx;
|
|
|
- struct wpabuf *ret;
|
|
|
- u16 val;
|
|
|
-
|
|
|
- pw = wpabuf_alloc(WPS_OOB_DEVICE_PASSWORD_LEN);
|
|
|
- if (pw == NULL)
|
|
|
- return NULL;
|
|
|
-
|
|
|
- if (random_get_bytes(wpabuf_put(pw, WPS_OOB_DEVICE_PASSWORD_LEN),
|
|
|
- WPS_OOB_DEVICE_PASSWORD_LEN) ||
|
|
|
- random_get_bytes((u8 *) &val, sizeof(val))) {
|
|
|
- wpabuf_free(pw);
|
|
|
- return NULL;
|
|
|
- }
|
|
|
-
|
|
|
- dh_ctx = dh5_init(&priv, &pub);
|
|
|
- if (dh_ctx == NULL) {
|
|
|
- wpabuf_free(pw);
|
|
|
- return NULL;
|
|
|
- }
|
|
|
- dh5_free(dh_ctx);
|
|
|
-
|
|
|
- hapd->conf->wps_nfc_dev_pw_id = 0x10 + val % 0xfff0;
|
|
|
- wpabuf_free(hapd->conf->wps_nfc_dh_pubkey);
|
|
|
- hapd->conf->wps_nfc_dh_pubkey = pub;
|
|
|
- wpabuf_free(hapd->conf->wps_nfc_dh_privkey);
|
|
|
- hapd->conf->wps_nfc_dh_privkey = priv;
|
|
|
- wpabuf_free(hapd->conf->wps_nfc_dev_pw);
|
|
|
- hapd->conf->wps_nfc_dev_pw = pw;
|
|
|
-
|
|
|
- ret = wps_build_nfc_pw_token(hapd->conf->wps_nfc_dev_pw_id,
|
|
|
- hapd->conf->wps_nfc_dh_pubkey,
|
|
|
- hapd->conf->wps_nfc_dev_pw);
|
|
|
- if (ndef && ret) {
|
|
|
- struct wpabuf *tmp;
|
|
|
- tmp = ndef_build_wifi(ret);
|
|
|
- wpabuf_free(ret);
|
|
|
- if (tmp == NULL)
|
|
|
- return NULL;
|
|
|
- ret = tmp;
|
|
|
- }
|
|
|
-
|
|
|
- return ret;
|
|
|
+ return wps_nfc_token_gen(ndef, &hapd->conf->wps_nfc_dev_pw_id,
|
|
|
+ &hapd->conf->wps_nfc_dh_pubkey,
|
|
|
+ &hapd->conf->wps_nfc_dh_privkey,
|
|
|
+ &hapd->conf->wps_nfc_dev_pw);
|
|
|
}
|
|
|
|
|
|
|