You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ut...@apache.org on 2021/02/17 15:11:32 UTC
[mynewt-core] 02/02: apps: crypto_test: fix warnings from syscfg
This is an automated email from the ASF dual-hosted git repository.
utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 0f43d24dece396379bb96affa51bfdf3301c3061
Author: Fabio Utzig <ut...@apache.org>
AuthorDate: Wed Feb 17 11:29:34 2021 -0300
apps: crypto_test: fix warnings from syscfg
Enabling/disabling some of the crypto_test syscfgs resulted in warnings
from non-used variables, etc. This commit fixes the issues so each
individual syscfg can be isolatedly used.
Signed-off-by: Fabio Utzig <ut...@apache.org>
---
apps/crypto_test/src/main.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/apps/crypto_test/src/main.c b/apps/crypto_test/src/main.c
index 09cc811..8e28879 100755
--- a/apps/crypto_test/src/main.c
+++ b/apps/crypto_test/src/main.c
@@ -46,6 +46,12 @@ struct test_vectors {
static struct os_mutex mtx;
+#if (MYNEWT_VAL(CRYPTOTEST_VECTORS_ECB) || \
+ MYNEWT_VAL(CRYPTOTEST_VECTORS_CBC) || \
+ MYNEWT_VAL(CRYPTOTEST_VECTORS_CTR))
+#define RUN_VECTOR_TESTS 1
+#endif
+
/*
* Test vectors from "NIST Special Publication 800-38A"
*/
@@ -236,6 +242,7 @@ static struct test_vectors aes_256_ctr_vectors = {
};
#endif /* MYNEWT_VAL(CRYPTOTEST_VECTORS_CTR) */
+#if RUN_VECTOR_TESTS
static struct test_vectors *all_tests[] = {
#if MYNEWT_VAL(CRYPTOTEST_VECTORS_ECB)
&aes_128_ecb_vectors,
@@ -251,6 +258,7 @@ static struct test_vectors *all_tests[] = {
#endif
NULL,
};
+#endif
void
run_test_vectors(struct crypto_dev *crypto, struct test_vectors *test_mode)
@@ -326,10 +334,13 @@ run_test_vectors(struct crypto_dev *crypto, struct test_vectors *test_mode)
}
}
-#if MYNEWT_VAL(CRYPTOTEST_BENCHMARK)
+#if MYNEWT_VAL(CRYPTOTEST_BENCHMARK) || MYNEWT_VAL(CRYPTOTEST_CONCURRENCY)
extern uint8_t aes_128_key[];
extern uint8_t aes_128_input[];
extern uint8_t aes_128_ecb_expected[];
+#endif
+
+#if MYNEWT_VAL(CRYPTOTEST_BENCHMARK)
extern uint8_t aes_128_cbc_expected[];
extern uint8_t aes_128_cbc_iv[];
extern uint8_t aes_128_ctr_expected[];
@@ -460,6 +471,7 @@ run_ctr_bench(struct crypto_dev *crypto, uint8_t iter)
}
#endif /* MYNEWT_VAL(CRYPTOTEST_BENCHMARK) */
+#if MYNEWT_VAL(CRYPTOTEST_CONCURRENCY)
static void
lock(void)
{
@@ -478,7 +490,6 @@ unlock(void)
assert(rc == 0);
}
-#if MYNEWT_VAL(CRYPTOTEST_CONCURRENCY)
static void
concurrency_test_handler(void *arg)
{
@@ -930,7 +941,9 @@ main(void)
struct tc_aes_key_sched_struct tc_aes;
int iterations;
#endif
+#if RUN_VECTOR_TESTS || MYNEWT_VAL(CRYPTOTEST_BENCHMARK)
int i;
+#endif
int rc;
sysinit();
@@ -941,10 +954,12 @@ main(void)
rc = os_mutex_init(&mtx);
assert(rc == 0);
+#if RUN_VECTOR_TESTS
printf("=== Test vectors ===\n");
for (i = 0; all_tests[i] != NULL; i++) {
run_test_vectors(crypto, all_tests[i]);
}
+#endif
#if MYNEWT_VAL(CRYPTOTEST_INPLACE)
printf("\n=== In-place encrypt/decrypt ===\n");