zephyr: Reconfigure to use local tinycrypt

Disable the Zephyr-provided Tinycrypt, and use our local copy.  This
avoids problems with changing version across different Zephyr releases.

Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/Makefile b/Makefile
index ca6b4ce..def6b51 100644
--- a/Makefile
+++ b/Makefile
@@ -15,6 +15,8 @@
 # ECDSA P-256
 #CONF_FILE = boot/zephyr/prj-p256.conf
 #CFLAGS += -DMCUBOOT_SIGN_EC256 -DMCUBOOT_USE_TINYCRYPT
+#NEED_TINYCRYPT = y
+#export NEED_TINYCRYPT
 
 # Enable this option to have the bootloader verify the signature of
 # the primary image upon every boot.  Without it, signature
diff --git a/boot/zephyr/Makefile b/boot/zephyr/Makefile
index b3f79f3..4789268 100644
--- a/boot/zephyr/Makefile
+++ b/boot/zephyr/Makefile
@@ -8,3 +8,6 @@
 obj-y += keys.o
 
 obj-y += ../bootutil/src/
+
+obj-$(NEED_TINYCRYPT) += ../../ext/tinycrypt/lib/source/
+include $(PROJECT)/ext/tinycrypt/lib/source/Makefile.inc
diff --git a/boot/zephyr/prj-p256.conf b/boot/zephyr/prj-p256.conf
index d4209cf..66aa66d 100644
--- a/boot/zephyr/prj-p256.conf
+++ b/boot/zephyr/prj-p256.conf
@@ -7,9 +7,9 @@
 CONFIG_MBEDTLS=y
 CONFIG_MBEDTLS_BUILTIN=y
 CONFIG_MBEDTLS_CFG_FILE="config-asn1.h"
-CONFIG_TINYCRYPT=y
-CONFIG_TINYCRYPT_ECC_DSA=y
-CONFIG_TINYCRYPT_SHA256=y
+# CONFIG_TINYCRYPT is not set
+# CONFIG_TINYCRYPT_ECC_DSA is not set
+# CONFIG_TINYCRYPT_SHA256 is not set
 
 ### mbedTLS wants a heap
 CONFIG_HEAP_MEM_POOL_SIZE=16384
diff --git a/ext/tinycrypt/lib/source/Makefile b/ext/tinycrypt/lib/source/Makefile
new file mode 100644
index 0000000..b61b05c
--- /dev/null
+++ b/ext/tinycrypt/lib/source/Makefile
@@ -0,0 +1,4 @@
+# Zephyr makefile.
+# subdir-ccflags-y += -I$(PROJECT)/ext/tinycrypt/lib/include
+
+obj-y += ecc.o ecc_dsa.o sha256.o utils.o
diff --git a/ext/tinycrypt/lib/source/Makefile.inc b/ext/tinycrypt/lib/source/Makefile.inc
new file mode 100644
index 0000000..ebb101a
--- /dev/null
+++ b/ext/tinycrypt/lib/source/Makefile.inc
@@ -0,0 +1,3 @@
+# vim: ft=make
+
+subdir-ccflags-$(NEED_TINYCRYPT) += -I$(PROJECT)/ext/tinycrypt/lib/include