all: use NM_HASH_SEED_16() macro
This commit is contained in:
@@ -3191,27 +3191,28 @@ ensure_hotspot_frequency(NMDeviceWifi *self, NMSettingWireless *s_wifi, NMWifiAP
|
||||
GBytes *ssid;
|
||||
gsize ssid_len;
|
||||
const guint8 *ssid_data;
|
||||
const guint8 random_seed[16] = {0x9a,
|
||||
0xdc,
|
||||
0x86,
|
||||
0x9a,
|
||||
0xa8,
|
||||
0xa2,
|
||||
0x07,
|
||||
0x97,
|
||||
0xbe,
|
||||
0x6d,
|
||||
0xe6,
|
||||
0x99,
|
||||
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);
|
||||
rnd = c_siphash_hash(NM_HASH_SEED_16(0x9a,
|
||||
0xdc,
|
||||
0x86,
|
||||
0x9a,
|
||||
0xa8,
|
||||
0xa2,
|
||||
0x07,
|
||||
0x97,
|
||||
0xbe,
|
||||
0x6d,
|
||||
0xe6,
|
||||
0x99,
|
||||
0x9f,
|
||||
0xa8,
|
||||
0x09,
|
||||
0x2b),
|
||||
ssid_data,
|
||||
ssid_len);
|
||||
}
|
||||
|
||||
if (nm_streq0(band, "a")) {
|
||||
|
@@ -3819,23 +3819,23 @@ nm_utils_dhcp_client_id_mac(int arp_type, const guint8 *hwaddr, gsize hwaddr_len
|
||||
return g_bytes_new_take(client_id_buf, hwaddr_len + 1);
|
||||
}
|
||||
|
||||
#define HASH_KEY \
|
||||
((const guint8[16]){0x80, \
|
||||
0x11, \
|
||||
0x8c, \
|
||||
0xc2, \
|
||||
0xfe, \
|
||||
0x4a, \
|
||||
0x03, \
|
||||
0xee, \
|
||||
0x3e, \
|
||||
0xd6, \
|
||||
0x0c, \
|
||||
0x6f, \
|
||||
0x36, \
|
||||
0x39, \
|
||||
0x14, \
|
||||
0x09})
|
||||
#define HASH_KEY \
|
||||
NM_HASH_SEED_16(0x80, \
|
||||
0x11, \
|
||||
0x8c, \
|
||||
0xc2, \
|
||||
0xfe, \
|
||||
0x4a, \
|
||||
0x03, \
|
||||
0xee, \
|
||||
0x3e, \
|
||||
0xd6, \
|
||||
0x0c, \
|
||||
0x6f, \
|
||||
0x36, \
|
||||
0x39, \
|
||||
0x14, \
|
||||
0x09)
|
||||
|
||||
/**
|
||||
* nm_utils_create_dhcp_iaid:
|
||||
|
@@ -390,23 +390,23 @@ _ipv4ll_addrgen(NML3IPv4LL *self, gboolean generate_new_addr)
|
||||
_ASSERT(self);
|
||||
|
||||
/* MAC_HASH_KEY is the same as used by systemd. */
|
||||
#define MAC_HASH_KEY \
|
||||
((const guint8[16]){0xdf, \
|
||||
0x04, \
|
||||
0x22, \
|
||||
0x98, \
|
||||
0x3f, \
|
||||
0xad, \
|
||||
0x14, \
|
||||
0x52, \
|
||||
0xf9, \
|
||||
0x87, \
|
||||
0x2e, \
|
||||
0xd1, \
|
||||
0x9c, \
|
||||
0x70, \
|
||||
0xe2, \
|
||||
0xf2})
|
||||
#define MAC_HASH_KEY \
|
||||
NM_HASH_SEED_16(0xdf, \
|
||||
0x04, \
|
||||
0x22, \
|
||||
0x98, \
|
||||
0x3f, \
|
||||
0xad, \
|
||||
0x14, \
|
||||
0x52, \
|
||||
0xf9, \
|
||||
0x87, \
|
||||
0x2e, \
|
||||
0xd1, \
|
||||
0x9c, \
|
||||
0x70, \
|
||||
0xe2, \
|
||||
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).
|
||||
@@ -465,23 +465,23 @@ _ipv4ll_addrgen(NML3IPv4LL *self, gboolean generate_new_addr)
|
||||
|
||||
gen_addr:
|
||||
|
||||
#define PICK_HASH_KEY \
|
||||
((const guint8[16]){0x15, \
|
||||
0xac, \
|
||||
0x82, \
|
||||
0xa6, \
|
||||
0xd6, \
|
||||
0x3f, \
|
||||
0x49, \
|
||||
0x78, \
|
||||
0x98, \
|
||||
0x77, \
|
||||
0x5d, \
|
||||
0x0c, \
|
||||
0x69, \
|
||||
0x02, \
|
||||
0x94, \
|
||||
0x0b})
|
||||
#define PICK_HASH_KEY \
|
||||
NM_HASH_SEED_16(0x15, \
|
||||
0xac, \
|
||||
0x82, \
|
||||
0xa6, \
|
||||
0xd6, \
|
||||
0x3f, \
|
||||
0x49, \
|
||||
0x78, \
|
||||
0x98, \
|
||||
0x77, \
|
||||
0x5d, \
|
||||
0x0c, \
|
||||
0x69, \
|
||||
0x02, \
|
||||
0x94, \
|
||||
0x0b)
|
||||
|
||||
h = c_siphash_hash(PICK_HASH_KEY, (const guint8 *) &self->seed, sizeof(self->seed));
|
||||
|
||||
|
Reference in New Issue
Block a user