mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-18 21:28:02 +00:00
hostapd: fix building mini variants
Some checks are pending
Build all core packages / Build all core packages for selected target (push) Waiting to run
Some checks are pending
Build all core packages / Build all core packages for selected target (push) Waiting to run
Move function and add ifdef to avoid undefined reference to hmac_sha256_kdf. Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
b6c7d8a0d6
commit
225b84d583
@ -817,6 +817,45 @@ out:
|
|||||||
ucv_put(val);
|
ucv_put(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uc_value_t *
|
||||||
|
uc_wpa_rkh_derive_key(uc_vm_t *vm, size_t nargs)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_IEEE80211R_AP
|
||||||
|
u8 oldkey[16];
|
||||||
|
char *oldkey_hex;
|
||||||
|
u8 key[SHA256_MAC_LEN];
|
||||||
|
size_t key_len = sizeof(key);
|
||||||
|
char key_hex[2 * ARRAY_SIZE(key) + 1];
|
||||||
|
uc_value_t *val = uc_fn_arg(0);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (ucv_type(val) != UC_STRING)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
oldkey_hex = ucv_string_get(val);
|
||||||
|
|
||||||
|
if (!hexstr2bin(oldkey_hex, key, key_len))
|
||||||
|
return ucv_string_new_length(oldkey_hex, 2 * ARRAY_SIZE(key));
|
||||||
|
|
||||||
|
if (hexstr2bin(oldkey_hex, oldkey, sizeof(oldkey))) {
|
||||||
|
wpa_printf(MSG_ERROR, "Invalid RxKH key: '%s'", oldkey_hex);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hmac_sha256_kdf(oldkey, sizeof(oldkey), "FT OLDKEY", NULL, 0, key, key_len) < 0) {
|
||||||
|
wpa_printf(MSG_ERROR, "Invalid RxKH key: '%s'", oldkey_hex);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(key); i++)
|
||||||
|
sprintf(key_hex + 2 * i, "%02x", key[i]);
|
||||||
|
|
||||||
|
return ucv_string_new_length(key_hex, 2 * ARRAY_SIZE(key));
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int hostapd_ucode_init(struct hapd_interfaces *ifaces)
|
int hostapd_ucode_init(struct hapd_interfaces *ifaces)
|
||||||
{
|
{
|
||||||
static const uc_function_list_t global_fns[] = {
|
static const uc_function_list_t global_fns[] = {
|
||||||
|
@ -237,40 +237,6 @@ uc_value_t *uc_wpa_sha1(uc_vm_t *vm, size_t nargs)
|
|||||||
return ucv_string_new_length(hash_hex, 2 * ARRAY_SIZE(hash));
|
return ucv_string_new_length(hash_hex, 2 * ARRAY_SIZE(hash));
|
||||||
}
|
}
|
||||||
|
|
||||||
uc_value_t *uc_wpa_rkh_derive_key(uc_vm_t *vm, size_t nargs)
|
|
||||||
{
|
|
||||||
u8 oldkey[16];
|
|
||||||
char *oldkey_hex;
|
|
||||||
u8 key[SHA256_MAC_LEN];
|
|
||||||
size_t key_len = sizeof(key);
|
|
||||||
char key_hex[2 * ARRAY_SIZE(key) + 1];
|
|
||||||
uc_value_t *val = uc_fn_arg(0);
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (ucv_type(val) != UC_STRING)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
oldkey_hex = ucv_string_get(val);
|
|
||||||
|
|
||||||
if (!hexstr2bin(oldkey_hex, key, key_len))
|
|
||||||
return ucv_string_new_length(oldkey_hex, 2 * ARRAY_SIZE(key));
|
|
||||||
|
|
||||||
if (hexstr2bin(oldkey_hex, oldkey, sizeof(oldkey))) {
|
|
||||||
wpa_printf(MSG_ERROR, "Invalid RxKH key: '%s'", oldkey_hex);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hmac_sha256_kdf(oldkey, sizeof(oldkey), "FT OLDKEY", NULL, 0, key, key_len) < 0) {
|
|
||||||
wpa_printf(MSG_ERROR, "Invalid RxKH key: '%s'", oldkey_hex);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(key); i++)
|
|
||||||
sprintf(key_hex + 2 * i, "%02x", key[i]);
|
|
||||||
|
|
||||||
return ucv_string_new_length(key_hex, 2 * ARRAY_SIZE(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
uc_vm_t *wpa_ucode_create_vm(void)
|
uc_vm_t *wpa_ucode_create_vm(void)
|
||||||
{
|
{
|
||||||
static uc_parse_config_t config = {
|
static uc_parse_config_t config = {
|
||||||
|
@ -25,7 +25,6 @@ uc_value_t *uc_wpa_udebug_set(uc_vm_t *vm, size_t nargs);
|
|||||||
uc_value_t *uc_wpa_printf(uc_vm_t *vm, size_t nargs);
|
uc_value_t *uc_wpa_printf(uc_vm_t *vm, size_t nargs);
|
||||||
uc_value_t *uc_wpa_getpid(uc_vm_t *vm, size_t nargs);
|
uc_value_t *uc_wpa_getpid(uc_vm_t *vm, size_t nargs);
|
||||||
uc_value_t *uc_wpa_sha1(uc_vm_t *vm, size_t nargs);
|
uc_value_t *uc_wpa_sha1(uc_vm_t *vm, size_t nargs);
|
||||||
uc_value_t *uc_wpa_rkh_derive_key(uc_vm_t *vm, size_t nargs);
|
|
||||||
uc_value_t *uc_wpa_freq_info(uc_vm_t *vm, size_t nargs);
|
uc_value_t *uc_wpa_freq_info(uc_vm_t *vm, size_t nargs);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user