Updates mynewt port to use bundled tinycrypt
This removes the dependency on tinycrypt lib provided by mynewt and
switches to the one bundled in mcuboot. Also fixes a bug where tc
was only being used when eliptic curve 256 was selected as sign
algorithm.
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/boot/bootutil/pkg.yml b/boot/bootutil/pkg.yml
index 1569dea..6d04674 100644
--- a/boot/bootutil/pkg.yml
+++ b/boot/bootutil/pkg.yml
@@ -39,5 +39,5 @@
- "@apache-mynewt-core/sys/defs"
- "@apache-mynewt-core/sys/flash_map"
-pkg.deps.BOOTUTIL_SIGN_EC256:
- - "@apache-mynewt-core/crypto/tinycrypt"
+pkg.deps.BOOTUTIL_USE_TINYCRYPT:
+ - "@mcuboot/boot/mynewt/tinycrypt"
diff --git a/boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h b/boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h
index fcc2fc5..4ce60d8 100644
--- a/boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h
+++ b/boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h
@@ -27,8 +27,17 @@
#if MYNEWT_VAL(BOOTUTIL_VALIDATE_SLOT0)
#define MCUBOOT_VALIDATE_SLOT0 1
#endif
+#if MYNEWT_VAL(BOOTUTIL_USE_MBED_TLS)
+#define MCUBOOT_USE_MBED_TLS 1
+#endif
+#if MYNEWT_VAL(BOOTUTIL_USE_TINYCRYPT)
+#define MCUBOOT_USE_TINYCRYPT 1
+#endif
#if MYNEWT_VAL(BOOTUTIL_SIGN_EC256)
#define MCUBOOT_SIGN_EC256 1
+ #ifndef MCUBOOT_USE_TINYCRYPT
+ #error "EC256 requires the use of tinycrypt."
+ #endif
#endif
#if MYNEWT_VAL(BOOTUTIL_SIGN_RSA)
#define MCUBOOT_SIGN_RSA 1
@@ -36,12 +45,6 @@
#if MYNEWT_VAL(BOOTUTIL_SIGN_EC)
#define MCUBOOT_SIGN_EC 1
#endif
-#if MYNEWT_VAL(BOOTUTIL_USE_MBED_TLS)
-#define MCUBOOT_USE_MBED_TLS 1
-#endif
-#if MYNEWT_VAL(BOOTUTIL_USE_TINYCRYPT)
-#define MCUBOOT_USE_TINYCRYPT 1
-#endif
#if MYNEWT_VAL(BOOTUTIL_OVERWRITE_ONLY)
#define MCUBOOT_OVERWRITE_ONLY 1
#endif
diff --git a/boot/mynewt/tinycrypt/include/tinycrypt/aes.h b/boot/mynewt/tinycrypt/include/tinycrypt/aes.h
new file mode 120000
index 0000000..559fd61
--- /dev/null
+++ b/boot/mynewt/tinycrypt/include/tinycrypt/aes.h
@@ -0,0 +1 @@
+../../../../../ext/tinycrypt/lib/include/tinycrypt/aes.h
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/include/tinycrypt/cbc_mode.h b/boot/mynewt/tinycrypt/include/tinycrypt/cbc_mode.h
new file mode 120000
index 0000000..f342701
--- /dev/null
+++ b/boot/mynewt/tinycrypt/include/tinycrypt/cbc_mode.h
@@ -0,0 +1 @@
+../../../../../ext/tinycrypt/lib/include/tinycrypt/cbc_mode.h
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/include/tinycrypt/ccm_mode.h b/boot/mynewt/tinycrypt/include/tinycrypt/ccm_mode.h
new file mode 120000
index 0000000..563305f
--- /dev/null
+++ b/boot/mynewt/tinycrypt/include/tinycrypt/ccm_mode.h
@@ -0,0 +1 @@
+../../../../../ext/tinycrypt/lib/include/tinycrypt/ccm_mode.h
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/include/tinycrypt/cmac_mode.h b/boot/mynewt/tinycrypt/include/tinycrypt/cmac_mode.h
new file mode 120000
index 0000000..4dda539
--- /dev/null
+++ b/boot/mynewt/tinycrypt/include/tinycrypt/cmac_mode.h
@@ -0,0 +1 @@
+../../../../../ext/tinycrypt/lib/include/tinycrypt/cmac_mode.h
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/include/tinycrypt/constants.h b/boot/mynewt/tinycrypt/include/tinycrypt/constants.h
new file mode 120000
index 0000000..a572a1b
--- /dev/null
+++ b/boot/mynewt/tinycrypt/include/tinycrypt/constants.h
@@ -0,0 +1 @@
+../../../../../ext/tinycrypt/lib/include/tinycrypt/constants.h
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/include/tinycrypt/ctr_mode.h b/boot/mynewt/tinycrypt/include/tinycrypt/ctr_mode.h
new file mode 120000
index 0000000..2d38453
--- /dev/null
+++ b/boot/mynewt/tinycrypt/include/tinycrypt/ctr_mode.h
@@ -0,0 +1 @@
+../../../../../ext/tinycrypt/lib/include/tinycrypt/ctr_mode.h
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/include/tinycrypt/ctr_prng.h b/boot/mynewt/tinycrypt/include/tinycrypt/ctr_prng.h
new file mode 120000
index 0000000..f6b12ef
--- /dev/null
+++ b/boot/mynewt/tinycrypt/include/tinycrypt/ctr_prng.h
@@ -0,0 +1 @@
+../../../../../ext/tinycrypt/lib/include/tinycrypt/ctr_prng.h
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/include/tinycrypt/ecc.h b/boot/mynewt/tinycrypt/include/tinycrypt/ecc.h
new file mode 120000
index 0000000..1487a34
--- /dev/null
+++ b/boot/mynewt/tinycrypt/include/tinycrypt/ecc.h
@@ -0,0 +1 @@
+../../../../../ext/tinycrypt/lib/include/tinycrypt/ecc.h
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/include/tinycrypt/ecc_dh.h b/boot/mynewt/tinycrypt/include/tinycrypt/ecc_dh.h
new file mode 120000
index 0000000..12dc17b
--- /dev/null
+++ b/boot/mynewt/tinycrypt/include/tinycrypt/ecc_dh.h
@@ -0,0 +1 @@
+../../../../../ext/tinycrypt/lib/include/tinycrypt/ecc_dh.h
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/include/tinycrypt/ecc_dsa.h b/boot/mynewt/tinycrypt/include/tinycrypt/ecc_dsa.h
new file mode 120000
index 0000000..b3c5824
--- /dev/null
+++ b/boot/mynewt/tinycrypt/include/tinycrypt/ecc_dsa.h
@@ -0,0 +1 @@
+../../../../../ext/tinycrypt/lib/include/tinycrypt/ecc_dsa.h
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/include/tinycrypt/hmac.h b/boot/mynewt/tinycrypt/include/tinycrypt/hmac.h
new file mode 120000
index 0000000..eb3224f
--- /dev/null
+++ b/boot/mynewt/tinycrypt/include/tinycrypt/hmac.h
@@ -0,0 +1 @@
+../../../../../ext/tinycrypt/lib/include/tinycrypt/hmac.h
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/include/tinycrypt/hmac_prng.h b/boot/mynewt/tinycrypt/include/tinycrypt/hmac_prng.h
new file mode 120000
index 0000000..fe11c1c
--- /dev/null
+++ b/boot/mynewt/tinycrypt/include/tinycrypt/hmac_prng.h
@@ -0,0 +1 @@
+../../../../../ext/tinycrypt/lib/include/tinycrypt/hmac_prng.h
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/include/tinycrypt/sha256.h b/boot/mynewt/tinycrypt/include/tinycrypt/sha256.h
new file mode 120000
index 0000000..9d74f28
--- /dev/null
+++ b/boot/mynewt/tinycrypt/include/tinycrypt/sha256.h
@@ -0,0 +1 @@
+../../../../../ext/tinycrypt/lib/include/tinycrypt/sha256.h
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/include/tinycrypt/utils.h b/boot/mynewt/tinycrypt/include/tinycrypt/utils.h
new file mode 120000
index 0000000..cb568e3
--- /dev/null
+++ b/boot/mynewt/tinycrypt/include/tinycrypt/utils.h
@@ -0,0 +1 @@
+../../../../../ext/tinycrypt/lib/include/tinycrypt/utils.h
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/pkg.yml b/boot/mynewt/tinycrypt/pkg.yml
new file mode 100644
index 0000000..154708b
--- /dev/null
+++ b/boot/mynewt/tinycrypt/pkg.yml
@@ -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.
+#
+
+pkg.name: boot/mynewt/tinycrypt
+pkg.description: "MCUboot's bundled tinycrypt"
+pkg.author: "Apache Mynewt <dev@mynewt.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+
+pkg.cflags:
+ - "-std=c99"
diff --git a/boot/mynewt/tinycrypt/src/aes_decrypt.c b/boot/mynewt/tinycrypt/src/aes_decrypt.c
new file mode 120000
index 0000000..dfadb18
--- /dev/null
+++ b/boot/mynewt/tinycrypt/src/aes_decrypt.c
@@ -0,0 +1 @@
+../../../../ext/tinycrypt/lib/source/aes_decrypt.c
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/src/aes_encrypt.c b/boot/mynewt/tinycrypt/src/aes_encrypt.c
new file mode 120000
index 0000000..1b19ebb
--- /dev/null
+++ b/boot/mynewt/tinycrypt/src/aes_encrypt.c
@@ -0,0 +1 @@
+../../../../ext/tinycrypt/lib/source/aes_encrypt.c
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/src/cbc_mode.c b/boot/mynewt/tinycrypt/src/cbc_mode.c
new file mode 120000
index 0000000..b408b0e
--- /dev/null
+++ b/boot/mynewt/tinycrypt/src/cbc_mode.c
@@ -0,0 +1 @@
+../../../../ext/tinycrypt/lib/source/cbc_mode.c
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/src/ccm_mode.c b/boot/mynewt/tinycrypt/src/ccm_mode.c
new file mode 120000
index 0000000..b9fc601
--- /dev/null
+++ b/boot/mynewt/tinycrypt/src/ccm_mode.c
@@ -0,0 +1 @@
+../../../../ext/tinycrypt/lib/source/ccm_mode.c
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/src/cmac_mode.c b/boot/mynewt/tinycrypt/src/cmac_mode.c
new file mode 120000
index 0000000..c9b1b15
--- /dev/null
+++ b/boot/mynewt/tinycrypt/src/cmac_mode.c
@@ -0,0 +1 @@
+../../../../ext/tinycrypt/lib/source/cmac_mode.c
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/src/ctr_mode.c b/boot/mynewt/tinycrypt/src/ctr_mode.c
new file mode 120000
index 0000000..02a6557
--- /dev/null
+++ b/boot/mynewt/tinycrypt/src/ctr_mode.c
@@ -0,0 +1 @@
+../../../../ext/tinycrypt/lib/source/ctr_mode.c
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/src/ctr_prng.c b/boot/mynewt/tinycrypt/src/ctr_prng.c
new file mode 120000
index 0000000..8d83ea4
--- /dev/null
+++ b/boot/mynewt/tinycrypt/src/ctr_prng.c
@@ -0,0 +1 @@
+../../../../ext/tinycrypt/lib/source/ctr_prng.c
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/src/ecc.c b/boot/mynewt/tinycrypt/src/ecc.c
new file mode 120000
index 0000000..50ea61d
--- /dev/null
+++ b/boot/mynewt/tinycrypt/src/ecc.c
@@ -0,0 +1 @@
+../../../../ext/tinycrypt/lib/source/ecc.c
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/src/ecc_dh.c b/boot/mynewt/tinycrypt/src/ecc_dh.c
new file mode 120000
index 0000000..04de4da
--- /dev/null
+++ b/boot/mynewt/tinycrypt/src/ecc_dh.c
@@ -0,0 +1 @@
+../../../../ext/tinycrypt/lib/source/ecc_dh.c
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/src/ecc_dsa.c b/boot/mynewt/tinycrypt/src/ecc_dsa.c
new file mode 120000
index 0000000..43f73c1
--- /dev/null
+++ b/boot/mynewt/tinycrypt/src/ecc_dsa.c
@@ -0,0 +1 @@
+../../../../ext/tinycrypt/lib/source/ecc_dsa.c
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/src/hmac.c b/boot/mynewt/tinycrypt/src/hmac.c
new file mode 120000
index 0000000..d8ef08f
--- /dev/null
+++ b/boot/mynewt/tinycrypt/src/hmac.c
@@ -0,0 +1 @@
+../../../../ext/tinycrypt/lib/source/hmac.c
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/src/hmac_prng.c b/boot/mynewt/tinycrypt/src/hmac_prng.c
new file mode 120000
index 0000000..59ac942
--- /dev/null
+++ b/boot/mynewt/tinycrypt/src/hmac_prng.c
@@ -0,0 +1 @@
+../../../../ext/tinycrypt/lib/source/hmac_prng.c
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/src/sha256.c b/boot/mynewt/tinycrypt/src/sha256.c
new file mode 120000
index 0000000..ad2da0a
--- /dev/null
+++ b/boot/mynewt/tinycrypt/src/sha256.c
@@ -0,0 +1 @@
+../../../../ext/tinycrypt/lib/source/sha256.c
\ No newline at end of file
diff --git a/boot/mynewt/tinycrypt/src/utils.c b/boot/mynewt/tinycrypt/src/utils.c
new file mode 120000
index 0000000..e4e74c2
--- /dev/null
+++ b/boot/mynewt/tinycrypt/src/utils.c
@@ -0,0 +1 @@
+../../../../ext/tinycrypt/lib/source/utils.c
\ No newline at end of file