From 11e56031c07ac5e4c16c684481828df3f50ee324 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 30 Aug 2016 13:38:08 -0500 Subject: [PATCH] wscutil: Add wsc_parse_m4_encrypted_settings --- src/wscutil.c | 13 +++++++++++++ src/wscutil.h | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/src/wscutil.c b/src/wscutil.c index e940bbe8..49c27acc 100644 --- a/src/wscutil.c +++ b/src/wscutil.c @@ -546,6 +546,8 @@ static attr_handler handler_for_type(enum wsc_attr type) case WSC_ATTR_R_HASH1: case WSC_ATTR_R_HASH2: return extract_hash; + case WSC_ATTR_R_SNONCE1: + return extract_nonce; case WSC_ATTR_SELECTED_REGISTRAR: return extract_bool; case WSC_ATTR_SELECTED_REGISTRAR_CONFIGURATION_METHODS: @@ -1148,6 +1150,17 @@ int wsc_parse_m4(const uint8_t *pdu, uint32_t len, struct wsc_m4 *out, return 0; } +int wsc_parse_m4_encrypted_settings(const uint8_t *pdu, uint32_t len, + struct wsc_m4_encrypted_settings *out) +{ + memset(out, 0, sizeof(*out)); + + return wsc_parse_attrs(pdu, len, NULL, NULL, + WSC_ATTR_KEY_WRAP_AUTHENTICATOR, out->authenticator, + REQUIRED(R_SNONCE1, out->r_snonce1), + WSC_ATTR_INVALID); +} + int wsc_parse_m5(const uint8_t *pdu, uint32_t len, struct wsc_m5 *out, struct iovec *out_encrypted) { diff --git a/src/wscutil.h b/src/wscutil.h index ca78f74a..632cba13 100644 --- a/src/wscutil.h +++ b/src/wscutil.h @@ -454,6 +454,11 @@ struct wsc_m4 { uint8_t authenticator[8]; }; +struct wsc_m4_encrypted_settings { + uint8_t r_snonce1[16]; + uint8_t authenticator[8]; +}; + struct wsc_m5 { bool version2; uint8_t registrar_nonce[16]; @@ -479,6 +484,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_m4_encrypted_settings(const uint8_t *pdu, uint32_t len, + struct wsc_m4_encrypted_settings *out); int wsc_parse_m5(const uint8_t *pdu, uint32_t len, struct wsc_m5 *out, struct iovec *out_encrypted);