wireguard: use clib helpers for endianness
In some cases, the Linux helpers for endianness conversion are not present. We use clib helpers to fix this. Type: fix Signed-off-by: Guillaume Solignac <gsoligna@cisco.com> Change-Id: I4d21fb5edae6fa6413b10f298a84ff4b88bda5db Signed-off-by: Pierre Pfister <ppfister@cisco.com> Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
This commit is contained in:

committed by
Damjan Marion

parent
9d5fed08ae
commit
9e45a5732b
@ -72,11 +72,11 @@ wg_xchacha20poly1305_encrypt (vlib_main_t *vm, u8 *src, u32 src_len, u8 *dst,
|
||||
u64 h_nonce;
|
||||
|
||||
clib_memcpy (&h_nonce, nonce + 16, sizeof (h_nonce));
|
||||
h_nonce = le64toh (h_nonce);
|
||||
h_nonce = clib_little_to_host_u64 (h_nonce);
|
||||
hchacha20 (derived_key, nonce, key);
|
||||
|
||||
for (i = 0; i < (sizeof (derived_key) / sizeof (derived_key[0])); i++)
|
||||
(derived_key[i]) = htole32 ((derived_key[i]));
|
||||
(derived_key[i]) = clib_host_to_little_u32 ((derived_key[i]));
|
||||
|
||||
uint32_t key_idx;
|
||||
|
||||
@ -102,11 +102,11 @@ wg_xchacha20poly1305_decrypt (vlib_main_t *vm, u8 *src, u32 src_len, u8 *dst,
|
||||
u64 h_nonce;
|
||||
|
||||
clib_memcpy (&h_nonce, nonce + 16, sizeof (h_nonce));
|
||||
h_nonce = le64toh (h_nonce);
|
||||
h_nonce = clib_little_to_host_u64 (h_nonce);
|
||||
hchacha20 (derived_key, nonce, key);
|
||||
|
||||
for (i = 0; i < (sizeof (derived_key) / sizeof (derived_key[0])); i++)
|
||||
(derived_key[i]) = htole32 ((derived_key[i]));
|
||||
(derived_key[i]) = clib_host_to_little_u32 ((derived_key[i]));
|
||||
|
||||
uint32_t key_idx;
|
||||
|
||||
|
@ -751,8 +751,8 @@ noise_tai64n_now (uint8_t output[NOISE_TIMESTAMP_LEN])
|
||||
unix_nanosec &= REJECT_INTERVAL_MASK;
|
||||
|
||||
/* https://cr.yp.to/libtai/tai64.html */
|
||||
sec = htobe64 (0x400000000000000aULL + unix_sec);
|
||||
nsec = htobe32 (unix_nanosec);
|
||||
sec = clib_host_to_big_u64 (0x400000000000000aULL + unix_sec);
|
||||
nsec = clib_host_to_big_u32 (unix_nanosec);
|
||||
|
||||
/* memcpy to output buffer, assuming output could be unaligned. */
|
||||
clib_memcpy (output, &sec, sizeof (sec));
|
||||
|
Reference in New Issue
Block a user