ext: nrf: Add nrf cc310 glue layer

Add glue layer for using the nrf cc310 to keep the cc310 interface more generic.
Add readme on how to build mcuboot with nrf cc310 support.

Signed-off-by: Sigvart Hovland <sigvart.m@gmail.com>
diff --git a/ext/nrf/cc310_glue.c b/ext/nrf/cc310_glue.c
new file mode 100644
index 0000000..14b9ac6
--- /dev/null
+++ b/ext/nrf/cc310_glue.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2019 Nordic Semiconductor ASA
+ *
+ * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
+ */
+
+#include "cc310_glue.h"
+
+int cc310_init(void)
+{
+    /* Only initialize once */
+    static bool initialized;
+
+    if (!initialized) {
+        nrf_cc310_enable();
+        if (nrf_cc310_bl_init() != 0) {
+            return -1;
+        }
+        initialized = true;
+        nrf_cc310_disable();
+    }
+
+    return 0;
+}
+
+void cc310_sha256_update(nrf_cc310_bl_hash_context_sha256_t *ctx,
+                         const void *data,
+                         uint32_t data_len)
+{
+    /*
+     * NRF Cryptocell can only read from RAM this allocates a buffer on the stack
+     * if the data provided is not located in RAM.
+     */
+
+    if ((uint32_t) data < CONFIG_SRAM_BASE_ADDRESS) {
+        uint8_t stack_buffer[data_len];
+        uint32_t block_len = data_len;
+        memcpy(stack_buffer, data, block_len);
+        nrf_cc310_bl_hash_sha256_update(ctx, stack_buffer, block_len);
+    } else {
+        nrf_cc310_bl_hash_sha256_update(ctx, data, data_len);
+    }
+};
+
+int cc310_ecdsa_verify_secp256r1(uint8_t *hash,
+                                 uint8_t *public_key,
+                                 uint8_t *signature,
+                                 size_t hash_len)
+{
+        int rc;
+        nrf_cc310_bl_ecdsa_verify_context_secp256r1_t ctx;
+        cc310_init();
+        nrf_cc310_enable();
+        rc = nrf_cc310_bl_ecdsa_verify_secp256r1(&ctx,
+                                                 (nrf_cc310_bl_ecc_public_key_secp256r1_t *) public_key,
+                                                 (nrf_cc310_bl_ecc_signature_secp256r1_t  *) signature,
+                                                 hash,
+                                                 hash_len);
+        nrf_cc310_disable();
+        return rc;
+}
+