all: use NM_HASH_SEED_16() macro

This commit is contained in:
Thomas Haller
2023-11-03 11:23:11 +01:00
parent 27ae71b504
commit 4f62600e21
3 changed files with 69 additions and 68 deletions

View File

@@ -3191,7 +3191,11 @@ ensure_hotspot_frequency(NMDeviceWifi *self, NMSettingWireless *s_wifi, NMWifiAP
GBytes *ssid;
gsize ssid_len;
const guint8 *ssid_data;
const guint8 random_seed[16] = {0x9a,
/* Calculate a stable "random" number based on the SSID. */
ssid = nm_setting_wireless_get_ssid(s_wifi);
ssid_data = g_bytes_get_data(ssid, &ssid_len);
rnd = c_siphash_hash(NM_HASH_SEED_16(0x9a,
0xdc,
0x86,
0x9a,
@@ -3206,12 +3210,9 @@ ensure_hotspot_frequency(NMDeviceWifi *self, NMSettingWireless *s_wifi, NMWifiAP
0x9f,
0xa8,
0x09,
0x2b};
/* Calculate a stable "random" number based on the SSID. */
ssid = nm_setting_wireless_get_ssid(s_wifi);
ssid_data = g_bytes_get_data(ssid, &ssid_len);
rnd = c_siphash_hash(random_seed, ssid_data, ssid_len);
0x2b),
ssid_data,
ssid_len);
}
if (nm_streq0(band, "a")) {

View File

@@ -3820,7 +3820,7 @@ nm_utils_dhcp_client_id_mac(int arp_type, const guint8 *hwaddr, gsize hwaddr_len
}
#define HASH_KEY \
((const guint8[16]){0x80, \
NM_HASH_SEED_16(0x80, \
0x11, \
0x8c, \
0xc2, \
@@ -3835,7 +3835,7 @@ nm_utils_dhcp_client_id_mac(int arp_type, const guint8 *hwaddr, gsize hwaddr_len
0x36, \
0x39, \
0x14, \
0x09})
0x09)
/**
* nm_utils_create_dhcp_iaid:

View File

@@ -391,7 +391,7 @@ _ipv4ll_addrgen(NML3IPv4LL *self, gboolean generate_new_addr)
/* MAC_HASH_KEY is the same as used by systemd. */
#define MAC_HASH_KEY \
((const guint8[16]){0xdf, \
NM_HASH_SEED_16(0xdf, \
0x04, \
0x22, \
0x98, \
@@ -406,7 +406,7 @@ _ipv4ll_addrgen(NML3IPv4LL *self, gboolean generate_new_addr)
0x9c, \
0x70, \
0xe2, \
0xf2})
0xf2)
if (self->mac_set && (!self->seed_set || !nm_ether_addr_equal(&self->mac, &self->seed_mac))) {
/* systemd's ipv4ll library by default only hashes the MAC address (as we do here).
@@ -466,7 +466,7 @@ _ipv4ll_addrgen(NML3IPv4LL *self, gboolean generate_new_addr)
gen_addr:
#define PICK_HASH_KEY \
((const guint8[16]){0x15, \
NM_HASH_SEED_16(0x15, \
0xac, \
0x82, \
0xa6, \
@@ -481,7 +481,7 @@ gen_addr:
0x69, \
0x02, \
0x94, \
0x0b})
0x0b)
h = c_siphash_hash(PICK_HASH_KEY, (const guint8 *) &self->seed, sizeof(self->seed));