Nuke uses of memcmp outside of unit tests

We want to be saying fast_mem{cmp,eq,neq} when we're doing a
comparison that's allowed to exit early, or tor_mem{cmp,eq,neq} when
we need a data-invariant timing.  Direct use of memcmp tends to imply
that we haven't thought about the issue.
This commit is contained in:
Nick Mathewson
2012-12-13 17:34:05 -05:00
parent 579808d4cd
commit b1ff8daeb5
5 changed files with 9 additions and 7 deletions
+2 -1
View File
@@ -41,6 +41,7 @@
#include "aes.h"
#include "util.h"
#include "torlog.h"
#include "di_ops.h"
#ifdef ANDROID
/* Android's OpenSSL seems to have removed all of its Engine support. */
@@ -257,7 +258,7 @@ evaluate_ctr_for_aes(void)
for (i=0; i<16; ++i)
AES_ctr128_encrypt(&zero[i], &output[i], 1, &key, ivec, ivec_tmp, &pos);
if (memcmp(output, encrypt_zero, 16)) {
if (fast_memneq(output, encrypt_zero, 16)) {
/* Counter mode is buggy */
log_notice(LD_CRYPTO, "This OpenSSL has a buggy version of counter mode; "
"not using it.");