diff --git a/src/wscutil.c b/src/wscutil.c index a26a6f0b..d21bf299 100644 --- a/src/wscutil.c +++ b/src/wscutil.c @@ -1139,6 +1139,32 @@ int wsc_parse_m4(const uint8_t *pdu, uint32_t len, struct wsc_m4 *out, return 0; } +int wsc_parse_m5(const uint8_t *pdu, uint32_t len, struct wsc_m5 *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_m5)); + + r = wsc_parse_attrs(pdu, len, &out->version2, &iter, 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_M5) + 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 559a0b11..d98f62d4 100644 --- a/src/wscutil.h +++ b/src/wscutil.h @@ -454,6 +454,12 @@ struct wsc_m4 { uint8_t authenticator[8]; }; +struct wsc_m5 { + bool version2; + uint8_t registrar_nonce[16]; + uint8_t authenticator[8]; +}; + struct wsc_nack { bool version2; uint8_t enrollee_nonce[16]; @@ -473,6 +479,8 @@ int wsc_parse_m2(const uint8_t *pdu, uint32_t len, struct wsc_m2 *out); int wsc_parse_m3(const uint8_t *pdu, uint32_t len, struct wsc_m3 *out); int wsc_parse_m4(const uint8_t *pdu, uint32_t len, struct wsc_m4 *out, struct iovec *out_encrypted); +int wsc_parse_m5(const uint8_t *pdu, uint32_t len, struct wsc_m5 *out, + struct iovec *out_encrypted); int wsc_parse_nack(const uint8_t *pdu, uint32_t len, struct wsc_nack *out);