WPS NFC: Build new style carrier record for connection handover request

It is more useful to be able to build a single NFC carrier record
instead of the full connection handover request message to allow
external components to decide whether to negotiate which alternative
carrier is used. This updates the carrier record contents to the new
design to include Enrollee public key hash and provides this as a
carrier record instead of full message. An external program is expected
to be used to build the full NFC connection handover message with
potentially other alternative carrier records included.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2013-04-02 18:30:58 +03:00 committed by Jouni Malinen
parent 3f1639da57
commit 41f9ffb635
6 changed files with 40 additions and 100 deletions

View file

@ -168,87 +168,3 @@ struct wpabuf * ndef_build_wifi(const struct wpabuf *buf)
FLAG_TNF_RFC2046, wifi_handover_type,
os_strlen(wifi_handover_type), NULL, 0, buf);
}
struct wpabuf * ndef_build_wifi_hc(int begin)
{
struct wpabuf *hc, *carrier;
carrier = wpabuf_alloc(2 + os_strlen(wifi_handover_type));
if (carrier == NULL)
return NULL;
wpabuf_put_u8(carrier, 0x02); /* Carrier Type Format */
wpabuf_put_u8(carrier, os_strlen(wifi_handover_type));
wpabuf_put_str(carrier, wifi_handover_type);
hc = ndef_build_record((begin ? FLAG_MESSAGE_BEGIN : 0) |
FLAG_MESSAGE_END | FLAG_TNF_NFC_FORUM, "Hc", 2,
"0", 1, carrier);
wpabuf_free(carrier);
return hc;
}
struct wpabuf * ndef_build_wifi_hr(void)
{
struct wpabuf *rn, *cr, *ac_payload, *ac, *hr_payload, *hr;
struct wpabuf *hc;
rn = wpabuf_alloc(2);
if (rn == NULL)
return NULL;
wpabuf_put_be16(rn, os_random() & 0xffff);
cr = ndef_build_record(FLAG_MESSAGE_BEGIN | FLAG_TNF_NFC_FORUM, "cr", 2,
NULL, 0, rn);
wpabuf_free(rn);
if (cr == NULL)
return NULL;
ac_payload = wpabuf_alloc(4);
if (ac_payload == NULL) {
wpabuf_free(cr);
return NULL;
}
wpabuf_put_u8(ac_payload, 0x01); /* Carrier Flags: CRS=1 "active" */
wpabuf_put_u8(ac_payload, 0x01); /* Carrier Data Reference Length */
wpabuf_put_u8(ac_payload, '0'); /* Carrier Data Reference: "0" */
wpabuf_put_u8(ac_payload, 0); /* Aux Data Reference Count */
ac = ndef_build_record(FLAG_MESSAGE_END | FLAG_TNF_NFC_FORUM, "ac", 2,
NULL, 0, ac_payload);
wpabuf_free(ac_payload);
if (ac == NULL) {
wpabuf_free(cr);
return NULL;
}
hr_payload = wpabuf_alloc(1 + wpabuf_len(cr) + wpabuf_len(ac));
if (hr_payload == NULL) {
wpabuf_free(cr);
wpabuf_free(ac);
return NULL;
}
wpabuf_put_u8(hr_payload, 0x12); /* Connection Handover Version 1.2 */
wpabuf_put_buf(hr_payload, cr);
wpabuf_put_buf(hr_payload, ac);
wpabuf_free(cr);
wpabuf_free(ac);
hr = ndef_build_record(FLAG_MESSAGE_BEGIN | FLAG_TNF_NFC_FORUM, "Hr", 2,
NULL, 0, hr_payload);
wpabuf_free(hr_payload);
if (hr == NULL)
return NULL;
hc = ndef_build_wifi_hc(0);
if (hc == NULL) {
wpabuf_free(hr);
return NULL;
}
return wpabuf_concat(hr, hc);
}

View file

@ -868,8 +868,6 @@ struct wpabuf * wps_build_nfc_handover_sel(struct wps_context *ctx,
/* ndef.c */
struct wpabuf * ndef_parse_wifi(const struct wpabuf *buf);
struct wpabuf * ndef_build_wifi(const struct wpabuf *buf);
struct wpabuf * ndef_build_wifi_hc(int begin);
struct wpabuf * ndef_build_wifi_hr(void);
#ifdef CONFIG_WPS_STRICT
int wps_validate_beacon(const struct wpabuf *wps_ie);