]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP: Bootstrapping via NFC URI Record
authorJouni Malinen <jouni@codeaurora.org>
Tue, 3 Dec 2019 16:22:36 +0000 (18:22 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 5 Dec 2019 10:37:51 +0000 (12:37 +0200)
This extends hostapd and wpa_supplicant DPP implementation to allow the
bootstrapping URI to be generated for and parsed from an NFC Tag with an
NFC URI Record. This is similar to the way the bootstrapping URI is used
with QR Code for unidirectional authentication.

The DPP_BOOTSTRAP_GEN command uses "type=nfc-uri" to request the URI to
be assigned for NFC URI Record. In practice, the URI is generated
identically to the QR Code case, but the internal entry maintains the
NFC-URI type.

A new command "DPP_NFC_URI <uri>" can now be used to parse the URI read
from an NFC Tag with the NFC URI Record. This is similar to the
DPP_QR_CODE command.

Other commands (mainly, DPP_LISTEN and DPP_AUTH_INIT) are used for NFC
URI in the same way as they are used for QR Code.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
hostapd/ctrl_iface.c
src/ap/dpp_hostapd.c
src/ap/dpp_hostapd.h
src/common/dpp.c
src/common/dpp.h
wpa_supplicant/ctrl_iface.c
wpa_supplicant/dpp_supplicant.c
wpa_supplicant/dpp_supplicant.h

index 00febc30f19db4f1246a412b7214e61c18e46d09..8692284d126cb6a299c9084cc83a6ccb482094b0 100644 (file)
@@ -3318,6 +3318,15 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
                        if (os_snprintf_error(reply_size, reply_len))
                                reply_len = -1;
                }
+       } else if (os_strncmp(buf, "DPP_NFC_URI ", 12) == 0) {
+               res = hostapd_dpp_nfc_uri(hapd, buf + 12);
+               if (res < 0) {
+                       reply_len = -1;
+               } else {
+                       reply_len = os_snprintf(reply, reply_size, "%d", res);
+                       if (os_snprintf_error(reply_size, reply_len))
+                               reply_len = -1;
+               }
        } else if (os_strncmp(buf, "DPP_BOOTSTRAP_GEN ", 18) == 0) {
                res = dpp_bootstrap_gen(hapd->iface->interfaces->dpp, buf + 18);
                if (res < 0) {
index 085d42325b8a2348c1910ad08a663cbb5d415a4e..64158fc7e6b6c6f52be3772d7c02f353ed8a0dcc 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * hostapd / DPP integration
  * Copyright (c) 2017, Qualcomm Atheros, Inc.
+ * Copyright (c) 2018-2019, The Linux Foundation
  *
  * This software may be distributed under the terms of the BSD license.
  * See README for more details.
@@ -62,6 +63,24 @@ int hostapd_dpp_qr_code(struct hostapd_data *hapd, const char *cmd)
 }
 
 
+/**
+ * hostapd_dpp_nfc_uri - Parse and add DPP bootstrapping info from NFC Tag (URI)
+ * @hapd: Pointer to hostapd_data
+ * @cmd: DPP URI read from a NFC Tag (URI NDEF message)
+ * Returns: Identifier of the stored info or -1 on failure
+ */
+int hostapd_dpp_nfc_uri(struct hostapd_data *hapd, const char *cmd)
+{
+       struct dpp_bootstrap_info *bi;
+
+       bi = dpp_add_nfc_uri(hapd->iface->interfaces->dpp, cmd);
+       if (!bi)
+               return -1;
+
+       return bi->id;
+}
+
+
 static void hostapd_dpp_auth_resp_retry_timeout(void *eloop_ctx,
                                                void *timeout_ctx)
 {
index c1ec5d70e4114b70bef2e52e13936e0ace8fb584..e151c2fc633705edbfa9e042099262dd07eacc15 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * hostapd / DPP integration
  * Copyright (c) 2017, Qualcomm Atheros, Inc.
+ * Copyright (c) 2018-2019, The Linux Foundation
  *
  * This software may be distributed under the terms of the BSD license.
  * See README for more details.
@@ -10,6 +11,7 @@
 #define DPP_HOSTAPD_H
 
 int hostapd_dpp_qr_code(struct hostapd_data *hapd, const char *cmd);
+int hostapd_dpp_nfc_uri(struct hostapd_data *hapd, const char *cmd);
 int hostapd_dpp_auth_init(struct hostapd_data *hapd, const char *cmd);
 int hostapd_dpp_listen(struct hostapd_data *hapd, const char *cmd);
 void hostapd_dpp_listen_stop(struct hostapd_data *hapd);
index 6c20fc1e6969d9c15b7185a3fab9f0e3d07a9adf..834fae0e0c0928e971c3f702644d121da31a9607 100644 (file)
@@ -830,6 +830,8 @@ const char * dpp_bootstrap_type_txt(enum dpp_bootstrap_type type)
                return "QRCODE";
        case DPP_BOOTSTRAP_PKEX:
                return "PKEX";
+       case DPP_BOOTSTRAP_NFC_URI:
+               return "NFC-URI";
        }
        return "??";
 }
@@ -1181,17 +1183,6 @@ static struct dpp_bootstrap_info * dpp_parse_uri(const char *uri)
 }
 
 
-struct dpp_bootstrap_info * dpp_parse_qr_code(const char *uri)
-{
-       struct dpp_bootstrap_info *bi;
-
-       bi = dpp_parse_uri(uri);
-       if (bi)
-               bi->type = DPP_BOOTSTRAP_QR_CODE;
-       return bi;
-}
-
-
 static void dpp_debug_print_key(const char *title, EVP_PKEY *key)
 {
        EC_KEY *eckey;
@@ -8959,10 +8950,30 @@ struct dpp_bootstrap_info * dpp_add_qr_code(struct dpp_global *dpp,
        if (!dpp)
                return NULL;
 
-       bi = dpp_parse_qr_code(uri);
+       bi = dpp_parse_uri(uri);
+       if (!bi)
+               return NULL;
+
+       bi->type = DPP_BOOTSTRAP_QR_CODE;
+       bi->id = dpp_next_id(dpp);
+       dl_list_add(&dpp->bootstrap, &bi->list);
+       return bi;
+}
+
+
+struct dpp_bootstrap_info * dpp_add_nfc_uri(struct dpp_global *dpp,
+                                           const char *uri)
+{
+       struct dpp_bootstrap_info *bi;
+
+       if (!dpp)
+               return NULL;
+
+       bi = dpp_parse_uri(uri);
        if (!bi)
                return NULL;
 
+       bi->type = DPP_BOOTSTRAP_NFC_URI;
        bi->id = dpp_next_id(dpp);
        dl_list_add(&dpp->bootstrap, &bi->list);
        return bi;
@@ -8990,6 +9001,8 @@ int dpp_bootstrap_gen(struct dpp_global *dpp, const char *cmd)
                bi->type = DPP_BOOTSTRAP_QR_CODE;
        else if (os_strstr(cmd, "type=pkex"))
                bi->type = DPP_BOOTSTRAP_PKEX;
+       else if (os_strstr(cmd, "type=nfc-uri"))
+               bi->type = DPP_BOOTSTRAP_NFC_URI;
        else
                goto fail;
 
index 2a558b63c65aac272866c3ca36f0646fff3563ea..7d14e76d3c9d7d38d80514d532d8c1555c1ad5ac 100644 (file)
@@ -106,6 +106,7 @@ struct dpp_curve_params {
 enum dpp_bootstrap_type {
        DPP_BOOTSTRAP_QR_CODE,
        DPP_BOOTSTRAP_PKEX,
+       DPP_BOOTSTRAP_NFC_URI,
 };
 
 struct dpp_bootstrap_info {
@@ -414,7 +415,6 @@ int dpp_parse_uri_chan_list(struct dpp_bootstrap_info *bi,
                            const char *chan_list);
 int dpp_parse_uri_mac(struct dpp_bootstrap_info *bi, const char *mac);
 int dpp_parse_uri_info(struct dpp_bootstrap_info *bi, const char *info);
-struct dpp_bootstrap_info * dpp_parse_qr_code(const char *uri);
 char * dpp_keygen(struct dpp_bootstrap_info *bi, const char *curve,
                  const u8 *privkey, size_t privkey_len);
 struct hostapd_hw_modes;
@@ -534,6 +534,8 @@ void dpp_pfs_free(struct dpp_pfs *pfs);
 
 struct dpp_bootstrap_info * dpp_add_qr_code(struct dpp_global *dpp,
                                            const char *uri);
+struct dpp_bootstrap_info * dpp_add_nfc_uri(struct dpp_global *dpp,
+                                           const char *uri);
 int dpp_bootstrap_gen(struct dpp_global *dpp, const char *cmd);
 struct dpp_bootstrap_info *
 dpp_bootstrap_get_id(struct dpp_global *dpp, unsigned int id);
index 7f8ec4a6a4f6c235d6bc2e4bb535cdc4b5b6d193..f238bc73f5d5c8c6f04b52a7d76920b4dca51fc7 100644 (file)
@@ -10678,6 +10678,17 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
                        if (os_snprintf_error(reply_size, reply_len))
                                reply_len = -1;
                }
+       } else if (os_strncmp(buf, "DPP_NFC_URI ", 12) == 0) {
+               int res;
+
+               res = wpas_dpp_nfc_uri(wpa_s, buf + 12);
+               if (res < 0) {
+                       reply_len = -1;
+               } else {
+                       reply_len = os_snprintf(reply, reply_size, "%d", res);
+                       if (os_snprintf_error(reply_size, reply_len))
+                               reply_len = -1;
+               }
        } else if (os_strncmp(buf, "DPP_BOOTSTRAP_GEN ", 18) == 0) {
                int res;
 
index 78adab61386c589ef494ad5069439d6014744a19..80d2c9ce742aae56091796f1c3479802b11fc5d9 100644 (file)
@@ -88,6 +88,24 @@ int wpas_dpp_qr_code(struct wpa_supplicant *wpa_s, const char *cmd)
 }
 
 
+/**
+ * wpas_dpp_nfc_uri - Parse and add DPP bootstrapping info from NFC Tag (URI)
+ * @wpa_s: Pointer to wpa_supplicant data
+ * @cmd: DPP URI read from a NFC Tag (URI NDEF message)
+ * Returns: Identifier of the stored info or -1 on failure
+ */
+int wpas_dpp_nfc_uri(struct wpa_supplicant *wpa_s, const char *cmd)
+{
+       struct dpp_bootstrap_info *bi;
+
+       bi = dpp_add_nfc_uri(wpa_s->dpp, cmd);
+       if (!bi)
+               return -1;
+
+       return bi->id;
+}
+
+
 static void wpas_dpp_auth_resp_retry_timeout(void *eloop_ctx, void *timeout_ctx)
 {
        struct wpa_supplicant *wpa_s = eloop_ctx;
index b33798265c1739655ed489c8917bf33fcd1de7e1..607036a38205794c34d9763017fd465eebbce17c 100644 (file)
@@ -13,6 +13,7 @@
 enum dpp_status_error;
 
 int wpas_dpp_qr_code(struct wpa_supplicant *wpa_s, const char *cmd);
+int wpas_dpp_nfc_uri(struct wpa_supplicant *wpa_s, const char *cmd);
 int wpas_dpp_auth_init(struct wpa_supplicant *wpa_s, const char *cmd);
 int wpas_dpp_listen(struct wpa_supplicant *wpa_s, const char *cmd);
 void wpas_dpp_listen_stop(struct wpa_supplicant *wpa_s);