From: Felix Fietkau Date: Fri, 13 Dec 2024 10:04:04 +0000 (+0100) Subject: hostapd: fix building mini variants X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=225b84d5832ddcc35ebc73e7cea34e9846cfa6f5;p=openwrt%2Fstaging%2Fblocktrron.git hostapd: fix building mini variants Move function and add ifdef to avoid undefined reference to hmac_sha256_kdf. Signed-off-by: Felix Fietkau --- diff --git a/package/network/services/hostapd/src/src/ap/ucode.c b/package/network/services/hostapd/src/src/ap/ucode.c index adc7c41914..e496b8b7aa 100644 --- a/package/network/services/hostapd/src/src/ap/ucode.c +++ b/package/network/services/hostapd/src/src/ap/ucode.c @@ -817,6 +817,45 @@ out: 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) { static const uc_function_list_t global_fns[] = { diff --git a/package/network/services/hostapd/src/src/utils/ucode.c b/package/network/services/hostapd/src/src/utils/ucode.c index 50b87982ce..a1762844b5 100644 --- a/package/network/services/hostapd/src/src/utils/ucode.c +++ b/package/network/services/hostapd/src/src/utils/ucode.c @@ -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)); } -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) { static uc_parse_config_t config = { diff --git a/package/network/services/hostapd/src/src/utils/ucode.h b/package/network/services/hostapd/src/src/utils/ucode.h index a273c19b7b..c083241e07 100644 --- a/package/network/services/hostapd/src/src/utils/ucode.h +++ b/package/network/services/hostapd/src/src/utils/ucode.h @@ -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_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_rkh_derive_key(uc_vm_t *vm, size_t nargs); uc_value_t *uc_wpa_freq_info(uc_vm_t *vm, size_t nargs); #endif