boot_serial: zephyr: Use new base64 library

Instead of relying on mbedTLS' base64 codec, use the new Zephyr base64
library.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
diff --git a/boot/boot_serial/src/CMakeLists.txt b/boot/boot_serial/src/CMakeLists.txt
index 48608e8..9da01c9 100644
--- a/boot/boot_serial/src/CMakeLists.txt
+++ b/boot/boot_serial/src/CMakeLists.txt
@@ -1,6 +1,3 @@
 zephyr_sources(boot_serial.c)
 
-#mbedtls-base64 library header
-zephyr_include_directories($ENV{ZEPHYR_BASE}/ext/lib/crypto/mbedtls/include)
-
 zephyr_include_directories(${BOOT_DIR}/bootutil/include)
diff --git a/boot/boot_serial/src/boot_serial.c b/boot/boot_serial/src/boot_serial.c
index 5a0332a..e893617 100644
--- a/boot/boot_serial/src/boot_serial.c
+++ b/boot/boot_serial/src/boot_serial.c
@@ -34,7 +34,7 @@
 #include <flash.h>
 #include <crc16.h>
 #include <serial_adapter/serial_adapter.h>
-#include "mbedtls/base64.h"
+#include <base64.h>
 #else
 #include <bsp/bsp.h>
 #include <hal/hal_system.h>
@@ -62,7 +62,7 @@
 #define BOOT_SERIAL_OUT_MAX	48
 
 #ifdef __ZEPHYR__
-/* mbedtls-base64 lib encodes data to null-terminated string */
+/* base64 lib encodes data to null-terminated string */
 #define BASE64_ENCODE_SIZE(in_size) ((((((in_size) - 1) / 3) * 4) + 4) + 1)
 
 #define CRC16_INITIAL_CRC       0       /* what to seed crc16 with */
@@ -395,8 +395,7 @@
     totlen += sizeof(crc);
 #ifdef __ZEPHYR__
     size_t enc_len;
-    mbedtls_base64_encode(encoded_buf, sizeof(encoded_buf), &enc_len, buf,
-                          totlen);
+    base64_encode(encoded_buf, sizeof(encoded_buf), &enc_len, buf, totlen);
     totlen = enc_len;
 #else
     totlen = base64_encode(buf, totlen, encoded_buf, 1);
@@ -417,7 +416,7 @@
     uint16_t len;
 #ifdef __ZEPHYR__
     int err;
-    err = mbedtls_base64_decode( &out[*out_off], maxout, &rc, in, inlen - 2);
+    err = base64_decode( &out[*out_off], maxout, &rc, in, inlen - 2);
     if (err) {
         return -1;
     }
diff --git a/boot/zephyr/Kconfig b/boot/zephyr/Kconfig
index 4db769e..33b5b8c 100644
--- a/boot/zephyr/Kconfig
+++ b/boot/zephyr/Kconfig
@@ -33,6 +33,7 @@
 	select REBOOT
 	select UART_INTERRUPT_DRIVEN
 	select SERIAL
+	select BASE64
 	select NEWLIB_LIBC
 	help
 	  Enable serial recovery feature in mcuboot.