Add support to get Device Identity Key from supplicant configuration file. Generate a new DIK if it is not present in conf file. Signed-off-by: Peddolla Harshavardhan Reddy <peddolla@xxxxxxxxxxxxxxxx> --- src/common/proximity_ranging.h | 13 +++++++++++++ wpa_supplicant/pr_supplicant.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/common/proximity_ranging.h b/src/common/proximity_ranging.h index 1eb889354..5aa7f7dce 100644 --- a/src/common/proximity_ranging.h +++ b/src/common/proximity_ranging.h @@ -14,6 +14,8 @@ #include "drivers/driver.h" +#define DEVICE_IDENTITY_KEY_LEN 16 + /** * PR_MAX_OP_CLASSES - Maximum number of operating classes */ @@ -279,6 +281,17 @@ struct pr_config { bool support_6ghz; + /* Cipher version type */ + int dik_cipher; + + /* Buffer to hold the DevIK */ + u8 dik_data[DEVICE_IDENTITY_KEY_LEN]; + + /* Length of DevIK in octets */ + size_t dik_len; + + /* DevIK expiration */ + int expiration; /** * cb_ctx - Context to use with callback functions diff --git a/wpa_supplicant/pr_supplicant.c b/wpa_supplicant/pr_supplicant.c index 95bcb511d..b45af7ad2 100644 --- a/wpa_supplicant/pr_supplicant.c +++ b/wpa_supplicant/pr_supplicant.c @@ -309,6 +309,35 @@ int wpas_pr_init(struct wpa_global *global, struct wpa_supplicant *wpa_s) os_memcpy(pr.country, "XX\x04", 3); } + if (wpa_s->conf->dik && + wpabuf_len(wpa_s->conf->dik) <= DEVICE_IDENTITY_KEY_LEN) { + pr.dik_cipher = wpa_s->conf->dik_cipher; + pr.dik_len = wpabuf_len(wpa_s->conf->dik); + os_memcpy(pr.dik_data, wpabuf_head(wpa_s->conf->dik), + pr.dik_len); + pr.expiration = 24; /* hours */ + } else { + pr.dik_cipher = DIRA_CIPHER_VERSION_128; + pr.dik_len = DEVICE_IDENTITY_KEY_LEN; + pr.expiration = 24; /* hours */ + if (os_get_random(pr.dik_data, pr.dik_len) < 0) + return -1; + + wpa_s->conf->dik = + wpabuf_alloc_copy(pr.dik_data, pr.dik_len); + if (!wpa_s->conf->dik) + return -1; + + wpa_s->conf->dik_cipher = pr.dik_cipher; + + wpa_printf(MSG_DEBUG, "PR: PR init new DIRA set"); + + if (wpa_s->conf->update_config && + wpa_config_write(wpa_s->confname, wpa_s->conf)) + wpa_printf(MSG_DEBUG, + "PR: Failed to update configuration"); + } + global->pr = pr_init(&pr); if (!global->pr) { wpa_printf(MSG_DEBUG, "PR: Failed to init PR"); -- 2.34.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap