3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +01:00

wscutil: Add wsc_build_m8_encrypted_settings

This commit is contained in:
Andrew Zaborowski 2020-01-09 20:40:18 +01:00 committed by Denis Kenzior
parent c67219a292
commit c6c45e0569
2 changed files with 46 additions and 0 deletions

View File

@ -1928,6 +1928,13 @@ static void build_network_key(struct wsc_attr_builder *builder,
wsc_attr_builder_put_bytes(builder, key, key_len);
}
static void build_new_password(struct wsc_attr_builder *builder,
const uint8_t *password, size_t password_len)
{
wsc_attr_builder_start_attr(builder, WSC_ATTR_NEW_PASSWORD);
wsc_attr_builder_put_bytes(builder, password, password_len);
}
static void build_os_version(struct wsc_attr_builder *builder,
uint32_t os_version)
{
@ -2072,6 +2079,17 @@ uint8_t *wsc_build_credential(const struct wsc_credential *in, size_t *out_len)
return ret;
}
static void build_credential(struct wsc_attr_builder *builder,
const struct wsc_credential *cred)
{
size_t data_len;
uint8_t *data = wsc_build_credential(cred, &data_len);
wsc_attr_builder_start_attr(builder, WSC_ATTR_CREDENTIAL);
wsc_attr_builder_put_bytes(builder, data, data_len);
l_free(data);
}
uint8_t *wsc_build_probe_request(const struct wsc_probe_request *probe_request,
size_t *out_len)
{
@ -2447,6 +2465,30 @@ done:
return ret;
}
uint8_t *wsc_build_m8_encrypted_settings(
const struct wsc_m8_encrypted_settings *in,
const struct wsc_credential *creds,
unsigned int creds_cnt, size_t *out_len)
{
struct wsc_attr_builder *builder;
unsigned int i;
builder = wsc_attr_builder_new(256);
for (i = 0; i < creds_cnt; i++)
build_credential(builder, &creds[i]);
if (in->new_password_len) {
build_new_password(builder, in->new_password,
in->new_password_len);
build_device_password_id(builder, in->device_password_id);
}
build_key_wrap_authenticator(builder, in->authenticator);
return wsc_attr_builder_free(builder, false, out_len);
}
uint8_t *wsc_build_wsc_ack(const struct wsc_ack *ack, size_t *out_len)
{
struct wsc_attr_builder *builder;

View File

@ -638,6 +638,10 @@ uint8_t *wsc_build_m7_encrypted_settings(
size_t *out_len);
uint8_t *wsc_build_m8(const struct wsc_m8 *m8, const uint8_t *encrypted,
size_t encrypted_len, size_t *out_len);
uint8_t *wsc_build_m8_encrypted_settings(
const struct wsc_m8_encrypted_settings *in,
const struct wsc_credential *creds,
unsigned int creds_cnt, size_t *out_len);
uint8_t *wsc_build_wsc_ack(const struct wsc_ack *ack, size_t *out_len);
uint8_t *wsc_build_wsc_nack(const struct wsc_nack *nack, size_t *out_len);