aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAdam Langley <alangley@gmail.com>2018-12-06 17:15:58 -0800
committerCQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>2018-12-18 22:43:02 +0000
commita6a049a6fb51a052347611d41583a0622bc89d60 (patch)
tree4834cf3772e8c6c7d064008a1ea2e841e41c44a3 /CMakeLists.txt
parentc2897a158a02a05a4d7d1115e1d81f34166ef729 (diff)
downloadboringssl-a6a049a6fb51a052347611d41583a0622bc89d60.zip
boringssl-a6a049a6fb51a052347611d41583a0622bc89d60.tar.gz
boringssl-a6a049a6fb51a052347611d41583a0622bc89d60.tar.bz2
Add start of infrastructure for checking constant-time properties.
Valgrind's checking of uninitialised memory behaves very much like a check for constant-time code: branches and memory indexes based on uninitialised memory trigger warnings. Therefore, if we can tell Valgrind that some secret is “uninitialised”, it'll give us a warning if we do something non-constant-time with it. This was the idea behind https://github.com/agl/ctgrind. But tricks like that are no longer needed because Valgrind now comes with support for marking regions of memory as defined or not. Therefore we can use that API to check constant-time code. This CL defines |CONSTTIME_SECRET| and |CONSTTIME_DECLASSIFY|, which are no-ops unless the code is built with |BORINGSSL_CONSTANT_TIME_VALIDATION| defined, which it isn't by default. So this CL is a no-op itself so far. But it does show that a couple of bits of constant-time time are, in fact, constant-time—seemingly even when compiled with optimisations, which is nice. The annotations in the RSA code are a) probably not marking all the secrets as secret, and b) triggers warnings that are a little interesting: The anti-glitch check calls |BN_mod_exp_mont| which checks that the input is less than the modulus. Of course, it is because the input is the RSA plaintext that we just decrypted, but the plaintext is supposed to be secret and so branching based on its contents isn't allows by Valgrind. The answer isn't totally clear, but I've run out of time on this for now. Change-Id: I1608ed0b22d201e97595fafe46127159e02d5b1b Reviewed-on: https://boringssl-review.googlesource.com/c/33504 Reviewed-by: Adam Langley <agl@google.com> Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: Adam Langley <agl@google.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt6
1 files changed, 6 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bfde5d5..1f18782 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -336,6 +336,12 @@ if(OPENSSL_SMALL)
add_definitions(-DOPENSSL_SMALL)
endif()
+if(CONSTANT_TIME_VALIDATION)
+ add_definitions(-DBORINGSSL_CONSTANT_TIME_VALIDATION)
+ # Asserts will often test secret data.
+ add_definitions(-DNDEBUG)
+endif()
+
function(go_executable dest package)
set(godeps "${CMAKE_SOURCE_DIR}/util/godeps.go")
if(${CMAKE_VERSION} VERSION_LESS "3.7" OR