3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-21 03:32:42 +01:00

wscutil: Add wsc_build_m4_encrypted_settings

This commit is contained in:
Denis Kenzior 2016-08-30 13:57:28 -05:00
parent 11e56031c0
commit d59086c791
2 changed files with 30 additions and 0 deletions

View File

@ -1463,6 +1463,13 @@ static void build_enrollee_nonce(struct wsc_attr_builder *builder,
wsc_attr_builder_put_bytes(builder, nonce, 16);
}
static void build_key_wrap_authenticator(struct wsc_attr_builder *builder,
const uint8_t *authenticator)
{
wsc_attr_builder_start_attr(builder, WSC_ATTR_KEY_WRAP_AUTHENTICATOR);
wsc_attr_builder_put_bytes(builder, authenticator, 8);
}
static void build_mac_address(struct wsc_attr_builder *builder,
const uint8_t *addr)
{
@ -1556,6 +1563,13 @@ static void build_r_hash2(struct wsc_attr_builder *builder,
wsc_attr_builder_put_bytes(builder, r_hash2, 32);
}
static void build_r_snonce1(struct wsc_attr_builder *builder,
const uint8_t *nonce)
{
wsc_attr_builder_start_attr(builder, WSC_ATTR_R_SNONCE1);
wsc_attr_builder_put_bytes(builder, nonce, 16);
}
static void build_serial_number(struct wsc_attr_builder *builder,
const char *serial_number)
{
@ -1772,6 +1786,19 @@ done:
return ret;
}
uint8_t *wsc_build_m4_encrypted_settings(
const struct wsc_m4_encrypted_settings *in,
size_t *out_len)
{
struct wsc_attr_builder *builder;
builder = wsc_attr_builder_new(256);
build_r_snonce1(builder, in->r_snonce1);
build_key_wrap_authenticator(builder, in->authenticator);
return wsc_attr_builder_free(builder, false, out_len);
}
uint8_t *wsc_build_m5(const struct wsc_m5 *m5, const uint8_t *encrypted,
size_t encrypted_len, size_t *out_len)
{

View File

@ -498,6 +498,9 @@ uint8_t *wsc_build_m2(const struct wsc_m2 *m2, size_t *out_len);
uint8_t *wsc_build_m3(const struct wsc_m3 *m3, size_t *out_len);
uint8_t *wsc_build_m4(const struct wsc_m4 *m4, const uint8_t *encrypted,
size_t encrypted_len, size_t *out_len);
uint8_t *wsc_build_m4_encrypted_settings(
const struct wsc_m4_encrypted_settings *in,
size_t *out_len);
uint8_t *wsc_build_m5(const struct wsc_m5 *m5, const uint8_t *encrypted,
size_t encrypted_len, size_t *out_len);