[dpdk-dev v3 1/2] eal: Add rte_consttime_memneq() to prevent timing attacks memcmp.
Stephen Hemminger
stephen at networkplumber.org
Fri Sep 26 20:12:33 CEST 2025
On Fri, 26 Sep 2025 16:02:08 +0000
Kai Ji <kai.ji at intel.com> wrote:
> +/**
> + * Constant-time memory inequality comparison.
> + *
> + * This function compares two memory regions in constant time, making it
> + * resistant to timing side-channel attacks. The execution time depends only
> + * on the length parameter, not on the actual data values being compared.
> + *
> + * This is particularly important for cryptographic operations where timing
> + * differences could leak information about secret keys, passwords, or other
> + * sensitive data.
> + *
> + * @param a
> + * Pointer to the first memory region to compare
> + * @param b
> + * Pointer to the second memory region to compare
> + * @param n
> + * Number of bytes to compare
> + * @return
> + * false if the memory regions are identical, true if they differ
> + */
> +static inline bool
> +rte_consttime_memneq(const void *a, const void *b, size_t n)
prefer FreeBSD naming i.e memeq instead of memneq
More information about the dev
mailing list