diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-11-17 00:32:06 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-11-17 00:32:06 +0100 |
commit | 357bc17975e3a60a64c46f56b5330747c67705b2 (patch) | |
tree | a433ef446817659ae3a4fc8c60f2adb68082650d /src/libsystemd-network/dhcp-identifier.c | |
parent | 8702319e119008954baa872d50d0e4098e6e83db (diff) | |
parent | 933f9caeeb2b3c1b951d330e04beb04226e5a890 (diff) |
Merge pull request #1923 from zonque/siphash
siphash24: let siphash24_finalize() and siphash24() return the result…
Diffstat (limited to 'src/libsystemd-network/dhcp-identifier.c')
-rw-r--r-- | src/libsystemd-network/dhcp-identifier.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libsystemd-network/dhcp-identifier.c b/src/libsystemd-network/dhcp-identifier.c index f8e6cb6ea9..d40c8a7f9c 100644 --- a/src/libsystemd-network/dhcp-identifier.c +++ b/src/libsystemd-network/dhcp-identifier.c @@ -52,7 +52,7 @@ int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len) { /* a bit of snake-oil perhaps, but no need to expose the machine-id directly; duid->en.id might not be aligned, so we need to copy */ - siphash24(&hash, &machine_id, sizeof(machine_id), HASH_KEY.bytes); + hash = htole64(siphash24(&machine_id, sizeof(machine_id), HASH_KEY.bytes)); memcpy(duid->en.id, &hash, sizeof(duid->en.id)); return 0; @@ -86,10 +86,12 @@ int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, void *_i } if (name) - siphash24(&id, name, strlen(name), HASH_KEY.bytes); + id = siphash24(name, strlen(name), HASH_KEY.bytes); else /* fall back to MAC address if no predictable name available */ - siphash24(&id, mac, mac_len, HASH_KEY.bytes); + id = siphash24(mac, mac_len, HASH_KEY.bytes); + + id = htole64(id); /* fold into 32 bits */ unaligned_write_be32(_id, (id & 0xffffffff) ^ (id >> 32)); |