From b7d44d302ae558df135b78bedf6045f1bad6df87 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 31 Aug 2016 11:32:21 -0500 Subject: [PATCH] wscutil: Add wsc_parse_m7 --- src/wscutil.c | 27 +++++++++++++++++++++++++++ src/wscutil.h | 8 ++++++++ 2 files changed, 35 insertions(+) diff --git a/src/wscutil.c b/src/wscutil.c index 33af46eb..2c4d20e7 100644 --- a/src/wscutil.c +++ b/src/wscutil.c @@ -1240,6 +1240,33 @@ int wsc_parse_m6_encrypted_settings(const uint8_t *pdu, uint32_t len, WSC_ATTR_INVALID); } +int wsc_parse_m7(const uint8_t *pdu, uint32_t len, struct wsc_m7 *out, + struct iovec *out_encrypted) +{ + int r; + struct wsc_wfa_ext_iter iter; + uint8_t version; + enum wsc_message_type msg_type; + + memset(out, 0, sizeof(struct wsc_m7)); + + r = wsc_parse_attrs(pdu, len, &out->version2, &iter, + WSC_ATTR_AUTHENTICATOR, out->authenticator, + REQUIRED(VERSION, &version), + REQUIRED(MESSAGE_TYPE, &msg_type), + REQUIRED(REGISTRAR_NONCE, &out->registrar_nonce), + REQUIRED(ENCRYPTED_SETTINGS, out_encrypted), + WSC_ATTR_INVALID); + + if (r < 0) + return r; + + if (msg_type != WSC_MESSAGE_TYPE_M7) + return -EBADMSG; + + return 0; +} + int wsc_parse_nack(const uint8_t *pdu, uint32_t len, struct wsc_nack *out) { int r; diff --git a/src/wscutil.h b/src/wscutil.h index b6bc068e..b16f70ee 100644 --- a/src/wscutil.h +++ b/src/wscutil.h @@ -481,6 +481,12 @@ struct wsc_m6_encrypted_settings { uint8_t authenticator[8]; }; +struct wsc_m7 { + bool version2; + uint8_t registrar_nonce[16]; + uint8_t authenticator[8]; +}; + struct wsc_nack { bool version2; uint8_t enrollee_nonce[16]; @@ -510,6 +516,8 @@ int wsc_parse_m6(const uint8_t *pdu, uint32_t len, struct wsc_m6 *out, struct iovec *out_encrypted); int wsc_parse_m6_encrypted_settings(const uint8_t *pdu, uint32_t len, struct wsc_m6_encrypted_settings *out); +int wsc_parse_m7(const uint8_t *pdu, uint32_t len, struct wsc_m7 *out, + struct iovec *out_encrypted); int wsc_parse_nack(const uint8_t *pdu, uint32_t len, struct wsc_nack *out);