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/11 19:58:46 UTC
[mynewt-core] branch master updated: Enable Mbed TLS self-tests
which were not running
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
The following commit(s) were added to refs/heads/master by this push:
new 461f880 Enable Mbed TLS self-tests which were not running
461f880 is described below
commit 461f8808954c9fcd4b13e0098232cc4913b020c3
Author: Fabio Utzig <ut...@apache.org>
AuthorDate: Thu Feb 11 11:35:53 2021 -0300
Enable Mbed TLS self-tests which were not running
Enable extra self-tests from Mbed TLS. Added ARIA, CMAC, MD2, MD4 and
J-PAKE tests. The test order was sorted for easier reading.
Signed-off-by: Fabio Utzig <ut...@apache.org>
---
crypto/mbedtls/include/mbedtls/config.h | 10 ++--
crypto/mbedtls/include/mbedtls/config_mynewt.h | 17 +++++++
crypto/mbedtls/selftest/pkg.yml | 2 +-
crypto/mbedtls/selftest/src/mbedtls_test.c | 59 ++++++++++++++---------
crypto/mbedtls/selftest/src/mbedtls_test.h | 29 ++++++-----
crypto/mbedtls/selftest/src/testcases/aria_test.c | 27 +++++++++++
crypto/mbedtls/selftest/src/testcases/cmac.c | 27 +++++++++++
crypto/mbedtls/selftest/src/testcases/ecjpake.c | 27 +++++++++++
crypto/mbedtls/selftest/src/testcases/md2_test.c | 27 +++++++++++
crypto/mbedtls/selftest/src/testcases/md4_test.c | 27 +++++++++++
crypto/mbedtls/selftest/syscfg.yml | 5 ++
crypto/mbedtls/syscfg.yml | 10 ++++
12 files changed, 225 insertions(+), 42 deletions(-)
diff --git a/crypto/mbedtls/include/mbedtls/config.h b/crypto/mbedtls/include/mbedtls/config.h
index ad0fa6a..9d5dbfa 100644
--- a/crypto/mbedtls/include/mbedtls/config.h
+++ b/crypto/mbedtls/include/mbedtls/config.h
@@ -2161,7 +2161,7 @@
* MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256
* MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384
*/
-//#define MBEDTLS_ARIA_C
+#define MBEDTLS_ARIA_C
/**
* \def MBEDTLS_CCM_C
@@ -2232,7 +2232,7 @@
* Requires: MBEDTLS_AES_C or MBEDTLS_DES_C
*
*/
-//#define MBEDTLS_CMAC_C
+#define MBEDTLS_CMAC_C
/**
* \def MBEDTLS_CTR_DRBG_C
@@ -2366,7 +2366,7 @@
*
* Requires: MBEDTLS_ECP_C, MBEDTLS_MD_C
*/
-//#define MBEDTLS_ECJPAKE_C
+#define MBEDTLS_ECJPAKE_C
/**
* \def MBEDTLS_ECP_C
@@ -2514,7 +2514,7 @@
* it, and considering stronger message digests instead.
*
*/
-//#define MBEDTLS_MD2_C
+#define MBEDTLS_MD2_C
/**
* \def MBEDTLS_MD4_C
@@ -2531,7 +2531,7 @@
* it, and considering stronger message digests instead.
*
*/
-//#define MBEDTLS_MD4_C
+#define MBEDTLS_MD4_C
/**
* \def MBEDTLS_MD5_C
diff --git a/crypto/mbedtls/include/mbedtls/config_mynewt.h b/crypto/mbedtls/include/mbedtls/config_mynewt.h
index 1d2ed0a..9620b9d 100644
--- a/crypto/mbedtls/include/mbedtls/config_mynewt.h
+++ b/crypto/mbedtls/include/mbedtls/config_mynewt.h
@@ -183,6 +183,10 @@ extern "C" {
#undef MBEDTLS_ECP_DP_CURVE25519_ENABLED
#endif
+#if MYNEWT_VAL(MBEDTLS_ECJPAKE_C) == 0
+#undef MBEDTLS_ECJPAKE_C
+#endif
+
#if MYNEWT_VAL(MBEDTLS_AES_ALT) == 0
#undef MBEDTLS_AES_ALT
#endif
@@ -202,6 +206,9 @@ extern "C" {
#if MYNEWT_VAL(MBEDTLS_ARC4_C) == 0
#undef MBEDTLS_ARC4_C
#endif
+#if MYNEWT_VAL(MBEDTLS_ARIA_C) == 0
+#undef MBEDTLS_ARIA_C
+#endif
#if MYNEWT_VAL(MBEDTLS_BLOWFISH_C) == 0
#undef MBEDTLS_BLOWFISH_C
#endif
@@ -227,6 +234,10 @@ extern "C" {
#undef MBEDTLS_POLY1305_C
#endif
+#if MYNEWT_VAL(MBEDTLS_CMAC_C) == 0
+#undef MBEDTLS_CMAC_C
+#endif
+
#if MYNEWT_VAL(MBEDTLS_CIPHER_MODE_CBC) == 0
#undef MBEDTLS_CIPHER_MODE_CBC
#endif
@@ -258,6 +269,12 @@ extern "C" {
#if MYNEWT_VAL(MBEDTLS_SHA256_C) == 0
#undef MBEDTLS_SHA256_C
#endif
+#if MYNEWT_VAL(MBEDTLS_MD2_C) == 0
+#undef MBEDTLS_MD2_C
+#endif
+#if MYNEWT_VAL(MBEDTLS_MD4_C) == 0
+#undef MBEDTLS_MD4_C
+#endif
#if MYNEWT_VAL(MBEDTLS_MD5_C) == 0
#undef MBEDTLS_MD5_C
#endif
diff --git a/crypto/mbedtls/selftest/pkg.yml b/crypto/mbedtls/selftest/pkg.yml
index daf3e83..b84ebc1 100644
--- a/crypto/mbedtls/selftest/pkg.yml
+++ b/crypto/mbedtls/selftest/pkg.yml
@@ -17,7 +17,7 @@
#
pkg.name: crypto/mbedtls/selftest
pkg.type: unittest
-pkg.description: "mbedtls unit tests."
+pkg.description: "Mbed TLS unit tests."
pkg.author: "Apache Mynewt <de...@mynewt.apache.org>"
pkg.homepage: "http://mynewt.apache.org/"
pkg.keywords:
diff --git a/crypto/mbedtls/selftest/src/mbedtls_test.c b/crypto/mbedtls/selftest/src/mbedtls_test.c
index 77b0903..a8941cc 100644
--- a/crypto/mbedtls/selftest/src/mbedtls_test.c
+++ b/crypto/mbedtls/selftest/src/mbedtls_test.c
@@ -52,63 +52,74 @@
#include "mbedtls/base64.h"
#include "mbedtls/timing.h"
-TEST_CASE_DECL(sha1_test)
-TEST_CASE_DECL(sha256_test)
-TEST_CASE_DECL(sha512_test)
TEST_CASE_DECL(aes_test)
TEST_CASE_DECL(arc4_test)
+TEST_CASE_DECL(aria_test)
+TEST_CASE_DECL(base64_test)
TEST_CASE_DECL(bignum_test)
+TEST_CASE_DECL(camellia_test)
TEST_CASE_DECL(ccm_test)
+TEST_CASE_DECL(chacha20_test)
+TEST_CASE_DECL(chachapoly_test)
+TEST_CASE_DECL(cmac_test)
+TEST_CASE_DECL(ctr_drbg_test)
+TEST_CASE_DECL(des_test)
TEST_CASE_DECL(dhm_test)
+TEST_CASE_DECL(ecjpake_test)
TEST_CASE_DECL(ecp_test)
TEST_CASE_DECL(entropy_test)
TEST_CASE_DECL(gcm_test)
TEST_CASE_DECL(hmac_drbg_test)
+TEST_CASE_DECL(md2_test)
+TEST_CASE_DECL(md4_test)
TEST_CASE_DECL(md5_test)
+TEST_CASE_DECL(memory_buffer_alloc_test)
+TEST_CASE_DECL(nist_kw_test)
TEST_CASE_DECL(pkcs5_test)
+TEST_CASE_DECL(poly1305_test)
TEST_CASE_DECL(ripemd160_test)
TEST_CASE_DECL(rsa_test)
+TEST_CASE_DECL(sha1_test)
+TEST_CASE_DECL(sha256_test)
+TEST_CASE_DECL(sha512_test)
+TEST_CASE_DECL(timing_test)
TEST_CASE_DECL(x509_test)
TEST_CASE_DECL(xtea_test)
-TEST_CASE_DECL(poly1305_test)
-TEST_CASE_DECL(chacha20_test)
-TEST_CASE_DECL(chachapoly_test)
-TEST_CASE_DECL(des_test)
-TEST_CASE_DECL(camellia_test)
-TEST_CASE_DECL(nist_kw_test)
-TEST_CASE_DECL(ctr_drbg_test)
-TEST_CASE_DECL(base64_test)
-TEST_CASE_DECL(timing_test)
TEST_SUITE(mbedtls_test_all)
{
- sha1_test();
- sha256_test();
- sha512_test();
aes_test();
arc4_test();
+ aria_test();
+ base64_test();
bignum_test();
+ camellia_test();
ccm_test();
+ chacha20_test();
+ chachapoly_test();
+ cmac_test();
+ ctr_drbg_test();
+ des_test();
dhm_test();
+ ecjpake_test();
ecp_test();
entropy_test();
gcm_test();
hmac_drbg_test();
+ md2_test();
+ md4_test();
md5_test();
+ nist_kw_test();
pkcs5_test();
+ poly1305_test();
ripemd160_test();
rsa_test();
+ sha1_test();
+ sha256_test();
+ sha512_test();
+ timing_test();
x509_test();
xtea_test();
- poly1305_test();
- chacha20_test();
- chachapoly_test();
- des_test();
- camellia_test();
- nist_kw_test();
- ctr_drbg_test();
- base64_test();
- timing_test();
}
int
diff --git a/crypto/mbedtls/selftest/src/mbedtls_test.h b/crypto/mbedtls/selftest/src/mbedtls_test.h
index 1c1b1cc..f0ffc7a 100644
--- a/crypto/mbedtls/selftest/src/mbedtls_test.h
+++ b/crypto/mbedtls/selftest/src/mbedtls_test.h
@@ -25,34 +25,39 @@
#include "testutil/testutil.h"
#include "mbedtls/mbedtls_test.h"
-#include "mbedtls/sha1.h"
-#include "mbedtls/sha256.h"
-#include "mbedtls/sha512.h"
+
#include "mbedtls/aes.h"
#include "mbedtls/arc4.h"
+#include "mbedtls/aria.h"
+#include "mbedtls/base64.h"
#include "mbedtls/bignum.h"
+#include "mbedtls/camellia.h"
#include "mbedtls/ccm.h"
+#include "mbedtls/chacha20.h"
+#include "mbedtls/chachapoly.h"
+#include "mbedtls/cmac.h"
+#include "mbedtls/ctr_drbg.h"
+#include "mbedtls/des.h"
#include "mbedtls/dhm.h"
#include "mbedtls/ecjpake.h"
#include "mbedtls/ecp.h"
#include "mbedtls/entropy.h"
#include "mbedtls/gcm.h"
#include "mbedtls/hmac_drbg.h"
+#include "mbedtls/md2.h"
+#include "mbedtls/md4.h"
#include "mbedtls/md5.h"
+#include "mbedtls/nist_kw.h"
#include "mbedtls/pkcs5.h"
+#include "mbedtls/poly1305.h"
#include "mbedtls/ripemd160.h"
#include "mbedtls/rsa.h"
+#include "mbedtls/sha1.h"
+#include "mbedtls/sha256.h"
+#include "mbedtls/sha512.h"
+#include "mbedtls/timing.h"
#include "mbedtls/x509.h"
#include "mbedtls/xtea.h"
-#include "mbedtls/poly1305.h"
-#include "mbedtls/chacha20.h"
-#include "mbedtls/chachapoly.h"
-#include "mbedtls/des.h"
-#include "mbedtls/camellia.h"
-#include "mbedtls/nist_kw.h"
-#include "mbedtls/ctr_drbg.h"
-#include "mbedtls/base64.h"
-#include "mbedtls/timing.h"
#ifdef __cplusplus
extern "C" {
diff --git a/crypto/mbedtls/selftest/src/testcases/aria_test.c b/crypto/mbedtls/selftest/src/testcases/aria_test.c
new file mode 100644
index 0000000..894a94b
--- /dev/null
+++ b/crypto/mbedtls/selftest/src/testcases/aria_test.c
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "mbedtls_test.h"
+
+TEST_CASE_SELF(aria_test)
+{
+ int rc;
+
+ rc = mbedtls_aria_self_test(1);
+ TEST_ASSERT(rc == 0);
+}
diff --git a/crypto/mbedtls/selftest/src/testcases/cmac.c b/crypto/mbedtls/selftest/src/testcases/cmac.c
new file mode 100644
index 0000000..0ac10b9
--- /dev/null
+++ b/crypto/mbedtls/selftest/src/testcases/cmac.c
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "mbedtls_test.h"
+
+TEST_CASE_SELF(cmac_test)
+{
+ int rc;
+
+ rc = mbedtls_cmac_self_test(1);
+ TEST_ASSERT(rc == 0);
+}
diff --git a/crypto/mbedtls/selftest/src/testcases/ecjpake.c b/crypto/mbedtls/selftest/src/testcases/ecjpake.c
new file mode 100644
index 0000000..b5615f2
--- /dev/null
+++ b/crypto/mbedtls/selftest/src/testcases/ecjpake.c
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "mbedtls_test.h"
+
+TEST_CASE_SELF(ecjpake_test)
+{
+ int rc;
+
+ rc = mbedtls_ecjpake_self_test(1);
+ TEST_ASSERT(rc == 0);
+}
diff --git a/crypto/mbedtls/selftest/src/testcases/md2_test.c b/crypto/mbedtls/selftest/src/testcases/md2_test.c
new file mode 100644
index 0000000..c65be75
--- /dev/null
+++ b/crypto/mbedtls/selftest/src/testcases/md2_test.c
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "mbedtls_test.h"
+
+TEST_CASE_SELF(md2_test)
+{
+ int rc;
+
+ rc = mbedtls_md2_self_test(1);
+ TEST_ASSERT(rc == 0);
+}
diff --git a/crypto/mbedtls/selftest/src/testcases/md4_test.c b/crypto/mbedtls/selftest/src/testcases/md4_test.c
new file mode 100644
index 0000000..1edf8e1
--- /dev/null
+++ b/crypto/mbedtls/selftest/src/testcases/md4_test.c
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "mbedtls_test.h"
+
+TEST_CASE_SELF(md4_test)
+{
+ int rc;
+
+ rc = mbedtls_md4_self_test(1);
+ TEST_ASSERT(rc == 0);
+}
diff --git a/crypto/mbedtls/selftest/syscfg.yml b/crypto/mbedtls/selftest/syscfg.yml
index 85b76b8..bf78d87 100644
--- a/crypto/mbedtls/selftest/syscfg.yml
+++ b/crypto/mbedtls/selftest/syscfg.yml
@@ -29,11 +29,13 @@ syscfg.vals:
MBEDTLS_ECP_DP_BP384R1: 1
MBEDTLS_ECP_DP_BP512R1: 1
MBEDTLS_ECP_DP_CURVE25519: 1
+ MBEDTLS_ECJPAKE_C: 1
# Ciphers
MBEDTLS_AES_C: 1
MBEDTLS_AES_ALT: 0
MBEDTLS_ARC4_C: 1
+ MBEDTLS_ARIA_C: 1
MBEDTLS_BLOWFISH_C: 1
MBEDTLS_CAMELLIA_C: 1
MBEDTLS_DES_C: 1
@@ -58,6 +60,8 @@ syscfg.vals:
# Hash functions
MBEDTLS_SHA256_C: 1
MBEDTLS_SHA256_ALT: 0
+ MBEDTLS_MD2_C: 1
+ MBEDTLS_MD4_C: 1
MBEDTLS_MD5_C: 1
MBEDTLS_SHA1_C: 1
MBEDTLS_SHA512_C: 1
@@ -65,6 +69,7 @@ syscfg.vals:
# Message Authentication Code
MBEDTLS_POLY1305_C: 1
+ MBEDTLS_CMAC_C: 1
# Stream ciphers
MBEDTLS_CHACHA20_C: 1
diff --git a/crypto/mbedtls/syscfg.yml b/crypto/mbedtls/syscfg.yml
index faf79da..415cea2 100644
--- a/crypto/mbedtls/syscfg.yml
+++ b/crypto/mbedtls/syscfg.yml
@@ -42,6 +42,8 @@ syscfg.defs:
value: 0
MBEDTLS_ECP_DP_CURVE25519:
value: 0
+ MBEDTLS_ECJPAKE_C:
+ value: 0
# Ciphers
MBEDTLS_AES_ALT:
@@ -55,6 +57,8 @@ syscfg.defs:
value: 0
MBEDTLS_ARC4_C:
value: 0
+ MBEDTLS_ARIA_C:
+ value: 0
MBEDTLS_BLOWFISH_C:
value: 0
MBEDTLS_CAMELLIA_C:
@@ -78,6 +82,8 @@ syscfg.defs:
value: 0
# MAC
+ MBEDTLS_CMAC_C:
+ value: 0
MBEDTLS_POLY1305_C:
value: 0
@@ -101,6 +107,10 @@ syscfg.defs:
value: 0
MBEDTLS_SHA256_C:
value: 1
+ MBEDTLS_MD2_C:
+ value: 0
+ MBEDTLS_MD4_C:
+ value: 0
MBEDTLS_MD5_C:
value: 0
MBEDTLS_SHA1_C: