From a113cba4f2c0d7b45fab4206a81c76ed04c0323c Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 31 Aug 2016 11:32:51 -0500 Subject: [PATCH] wscutil: Add wsc_build_m7 --- src/wscutil.c | 26 ++++++++++++++++++++++++++ src/wscutil.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/src/wscutil.c b/src/wscutil.c index 2c4d20e7..bcc4e564 100644 --- a/src/wscutil.c +++ b/src/wscutil.c @@ -1970,6 +1970,32 @@ uint8_t *wsc_build_m6_encrypted_settings( return wsc_attr_builder_free(builder, false, out_len); } +uint8_t *wsc_build_m7(const struct wsc_m7 *m7, const uint8_t *encrypted, + size_t encrypted_len, size_t *out_len) +{ + struct wsc_attr_builder *builder; + uint8_t *ret; + + builder = wsc_attr_builder_new(256); + build_version(builder, 0x10); + build_message_type(builder, WSC_MESSAGE_TYPE_M7); + build_registrar_nonce(builder, m7->registrar_nonce); + + wsc_attr_builder_start_attr(builder, WSC_ATTR_ENCRYPTED_SETTINGS); + wsc_attr_builder_put_bytes(builder, encrypted, encrypted_len); + + if (!m7->version2) + goto done; + + START_WFA_VENDOR_EXTENSION(); + +done: + build_authenticator(builder, m7->authenticator); + + ret = wsc_attr_builder_free(builder, false, out_len); + return ret; +} + uint8_t *wsc_build_nack(const struct wsc_nack *nack, size_t *out_len) { struct wsc_attr_builder *builder; diff --git a/src/wscutil.h b/src/wscutil.h index b16f70ee..b13f6725 100644 --- a/src/wscutil.h +++ b/src/wscutil.h @@ -541,6 +541,8 @@ uint8_t *wsc_build_m6(const struct wsc_m6 *m6, const uint8_t *encrypted, uint8_t *wsc_build_m6_encrypted_settings( const struct wsc_m6_encrypted_settings *in, size_t *out_len); +uint8_t *wsc_build_m7(const struct wsc_m7 *m7, const uint8_t *encrypted, + size_t encrypted_len, size_t *out_len); uint8_t *wsc_build_nack(const struct wsc_nack *nack, size_t *out_len);