From ab5edbe7fca2deeccf3f0aa567d1612bf918b2a2 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Wed, 27 Jan 2021 16:49:50 -0500 Subject: Benchmark BORINGSSL_self_test in FIPS mode. Probably worth benchmarking this, given it slows down every process startup. Change-Id: I603c79a445203f87e26fa23d9afc4450688f2929 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45245 Reviewed-by: Adam Langley --- tool/speed.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tool') diff --git a/tool/speed.cc b/tool/speed.cc index 8aa8f85..1b89b42 100644 --- a/tool/speed.cc +++ b/tool/speed.cc @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -1221,6 +1222,24 @@ static bool SpeedTrustToken(std::string name, const TRUST_TOKEN_METHOD *method, return true; } +#if defined(BORINGSSL_FIPS) +static bool SpeedSelfTest(const std::string &selected) { + if (!selected.empty() && selected.find("self-test") == std::string::npos) { + return true; + } + + TimeResults results; + if (!TimeFunction(&results, []() -> bool { return BORINGSSL_self_test(); })) { + fprintf(stderr, "BORINGSSL_self_test faileid.\n"); + ERR_print_errors_fp(stderr); + return false; + } + + results.Print("self-test"); + return true; +} +#endif + static const struct argument kArguments[] = { { "-filter", @@ -1367,6 +1386,11 @@ bool Speed(const std::vector &args) { TRUST_TOKEN_experiment_v2_pmb(), 10, selected)) { return false; } +#if defined(BORINGSSL_FIPS) + if (!SpeedSelfTest(selected)) { + return false; + } +#endif if (g_print_json) { puts("\n]"); } -- cgit v1.1