Use timingsafe_memcmp() where available.

See ticket 17944; patch from "logan".
This commit is contained in:
Nick Mathewson 2015-12-29 09:43:01 -05:00
parent 9a901aaa01
commit bc2cd0ff2b
3 changed files with 8 additions and 0 deletions

3
changes/17944 Normal file
View File

@ -0,0 +1,3 @@
o Minor features (portability):
- Use timingsafe_memcmp() where available. Closes ticket 17944;
patch from "logan".

View File

@ -381,6 +381,7 @@ AC_CHECK_FUNCS(
backtrace_symbols_fd \ backtrace_symbols_fd \
clock_gettime \ clock_gettime \
eventfd \ eventfd \
timingsafe_memcmp \
flock \ flock \
ftime \ ftime \
getaddrinfo \ getaddrinfo \

View File

@ -25,6 +25,9 @@
int int
tor_memcmp(const void *a, const void *b, size_t len) tor_memcmp(const void *a, const void *b, size_t len)
{ {
#ifdef HAVE_TIMINGSAFE_MEMCMP
return timingsafe_memcmp(a, b, len);
#else
const uint8_t *x = a; const uint8_t *x = a;
const uint8_t *y = b; const uint8_t *y = b;
size_t i = len; size_t i = len;
@ -83,6 +86,7 @@ tor_memcmp(const void *a, const void *b, size_t len)
} }
return retval; return retval;
#endif /* timingsafe_memcmp */
} }
/** /**