]> git.ipfire.org Git - thirdparty/chrony.git/commit
util: add function for constant-time memory comparison
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 2 Apr 2025 13:32:05 +0000 (15:32 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 3 Apr 2025 14:05:04 +0000 (16:05 +0200)
commitdab98fa8da2ff7a4637ff2229dfeefb3accdcff4
tree23b495c005c86206734a7f71ccac069b6ca4be11
parentdd8738119bf9228cc718f2f67091efcd428a2970
util: add function for constant-time memory comparison

Add a function to check if two buffers of the same length contain the
same data, but do the comparison in a constant time with respect to the
returned value to avoid creating a timing side channel, i.e. the time
depends only on the buffer length, not on the content.

Use the gnutls_memcmp() or nettle_memeql_sec() functions if available,
otherwise use the same algorithm as nettle - bitwise ORing XORed data.
configure
test/unit/util.c
util.c
util.h