[tor-commits] [tor/master] Use timingsafe_memcmp() where available.
nickm at torproject.org
nickm at torproject.org
Tue Dec 29 14:43:23 UTC 2015
commit bc2cd0ff2bfc70916efe6b6a7fe0a4aae481df3b
Author: Nick Mathewson <nickm at torproject.org>
Date: Tue Dec 29 09:43:01 2015 -0500
Use timingsafe_memcmp() where available.
See ticket 17944; patch from "logan".
---
changes/17944 | 3 +++
configure.ac | 1 +
src/common/di_ops.c | 4 ++++
3 files changed, 8 insertions(+)
diff --git a/changes/17944 b/changes/17944
new file mode 100644
index 0000000..b279506
--- /dev/null
+++ b/changes/17944
@@ -0,0 +1,3 @@
+ o Minor features (portability):
+ - Use timingsafe_memcmp() where available. Closes ticket 17944;
+ patch from "logan".
diff --git a/configure.ac b/configure.ac
index ad86f76..a47cee6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -381,6 +381,7 @@ AC_CHECK_FUNCS(
backtrace_symbols_fd \
clock_gettime \
eventfd \
+ timingsafe_memcmp \
flock \
ftime \
getaddrinfo \
diff --git a/src/common/di_ops.c b/src/common/di_ops.c
index c9d1350..70f2da7 100644
--- a/src/common/di_ops.c
+++ b/src/common/di_ops.c
@@ -25,6 +25,9 @@
int
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 *y = b;
size_t i = len;
@@ -83,6 +86,7 @@ tor_memcmp(const void *a, const void *b, size_t len)
}
return retval;
+#endif /* timingsafe_memcmp */
}
/**
More information about the tor-commits
mailing list