summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2018-12-05 13:51:06 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-12-06 22:06:26 -0800
commita45e42da1a5c16a94d4d02531802f87061b8891c (patch)
tree7b7697d05a32e987ef99437a78b26a1aa91df8e0
parent74a598dd11bdfb03001e8ab8e62757beb8622583 (diff)
downloadchrome-ec-a45e42da1a5c16a94d4d02531802f87061b8891c.tar.gz
cr50: provide DCRYPTO_ladder_is_enabled() for test and fuzz builds
This function is called from common/nvmem.c, it should be available when compiling for tests, the stub could be filled up later when new tests are added. BRANCH=cr50, cr50-mp BUG=b:119221935 TEST=make buildall -j still succeeds. Change-Id: I082292818c7f2b10336c9a7c49e0a9195e25a12b Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1363816 Reviewed-by: Allen Webb <allenwebb@google.com>
-rw-r--r--chip/g/dcrypto/dcrypto.h24
-rw-r--r--common/nvmem.c5
-rw-r--r--fuzz/cr50_fuzz.cc4
-rw-r--r--test/nvmem.c5
4 files changed, 24 insertions, 14 deletions
diff --git a/chip/g/dcrypto/dcrypto.h b/chip/g/dcrypto/dcrypto.h
index 848373dbcb..bd81b322ac 100644
--- a/chip/g/dcrypto/dcrypto.h
+++ b/chip/g/dcrypto/dcrypto.h
@@ -13,6 +13,12 @@
#define CRYPTO_TEST_SETUP
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(TEST_FUZZ) || !defined(TEST_BUILD)
+
#include "internal.h"
#include "crypto_api.h"
@@ -21,10 +27,6 @@
#include "cryptoc/hmac.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
enum cipher_mode {
CIPHER_MODE_ECB = 0,
CIPHER_MODE_CTR = 1,
@@ -305,12 +307,6 @@ struct APPKEY_CTX {
int DCRYPTO_ladder_compute_frk2(size_t major_fw_version, uint8_t *frk2);
int DCRYPTO_ladder_random(void *output);
void DCRYPTO_ladder_revoke(void);
-/*
- * Query whether Key Ladder is enabled.
- *
- * @return 1 if Key Ladder is enabled, and 0 otherwise.
- */
-int DCRYPTO_ladder_is_enabled(void);
int DCRYPTO_appkey_init(enum dcrypto_appid id, struct APPKEY_CTX *ctx);
void DCRYPTO_appkey_finish(struct APPKEY_CTX *ctx);
@@ -348,6 +344,14 @@ BUILD_ASSERT(DCRYPTO_CIPHER_SALT_SIZE == CIPHER_SALT_SIZE);
int DCRYPTO_app_cipher(enum dcrypto_appid appid, const void *salt,
void *out, const void *in, size_t len);
+#endif /* ^^^^^^^^^^^^^^^^^^^^^ !TEST_BUILD */
+/*
+ * Query whether Key Ladder is enabled.
+ *
+ * @return 1 if Key Ladder is enabled, and 0 otherwise.
+ */
+int DCRYPTO_ladder_is_enabled(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/common/nvmem.c b/common/nvmem.c
index b4c82d0154..1c911ccddf 100644
--- a/common/nvmem.c
+++ b/common/nvmem.c
@@ -5,9 +5,7 @@
#include "common.h"
#include "console.h"
-#ifndef TEST_BUILD
#include "dcrypto.h"
-#endif
#include "flash.h"
#include "nvmem.h"
#include "task.h"
@@ -111,13 +109,12 @@ static int nvmem_save(void)
uint8_t sha_comp[NVMEM_SHA_SIZE];
int rv = EC_SUCCESS;
-#ifndef TEST_BUILD
if (!DCRYPTO_ladder_is_enabled()) {
CPRINTF("%s: Key ladder is disabled. Skipping flash write\n",
__func__);
goto release_cache;
}
-#endif
+
part = (struct nvmem_partition *)nvmem_cache;
/* Has anything changed in the cache? */
diff --git a/fuzz/cr50_fuzz.cc b/fuzz/cr50_fuzz.cc
index 67103ad5b0..4c842631bd 100644
--- a/fuzz/cr50_fuzz.cc
+++ b/fuzz/cr50_fuzz.cc
@@ -139,3 +139,7 @@ extern "C" int test_fuzz_one_input(const uint8_t* data, unsigned int size) {
}
return 0;
}
+
+extern "C" int DCRYPTO_ladder_is_enabled(void) {
+ return 1;
+}
diff --git a/test/nvmem.c b/test/nvmem.c
index d09bf8752a..8ce978d750 100644
--- a/test/nvmem.c
+++ b/test/nvmem.c
@@ -696,6 +696,11 @@ static void run_test_setup(void)
test_reset();
}
+int DCRYPTO_ladder_is_enabled(void)
+{
+ return 1;
+}
+
void run_test(void)
{
run_test_setup();