From 5550a608d63e39461f4d71321ecee8d27e26b463 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Tue, 9 Jun 2020 10:47:37 -0700 Subject: [PATCH] [fuzz] limit PBKDF2 iterations to avoid OSS-Fuzz timeout (#5069) --- src/core/crypto/pbkdf2_cmac.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/crypto/pbkdf2_cmac.cpp b/src/core/crypto/pbkdf2_cmac.cpp index e46dc14e1..c2ad91b20 100644 --- a/src/core/crypto/pbkdf2_cmac.cpp +++ b/src/core/crypto/pbkdf2_cmac.cpp @@ -63,6 +63,11 @@ void otPbkdf2Cmac(const uint8_t *aPassword, OT_ASSERT(aIterationCounter % 2 == 0); aIterationCounter /= 2; +#if FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + // limit iterations to avoid OSS-Fuzz timeouts + aIterationCounter = 2; +#endif + while (keyLen) { ++blockCounter;