Commit 0165be8b authored by Carles Cufi's avatar Carles Cufi Committed by Fabio Utzig
Browse files

boot_serial: zephyr: Use new base64 library

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

Signed-off-by: default avatarCarles Cufi <carles.cufi@nordicsemi.no>
parent efd783cf
Loading
Loading
Loading
Loading
−3
Changes for boot/boot_serial/src/CMakeLists.txt: 0 added lines, 3 removed lines.
Original line number Diff line number Diff line
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)
+4 −5
Changes for boot/boot_serial/src/boot_serial.c: 4 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -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 @@ boot_serial_output(void)
    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 @@ boot_serial_in_dec(char *in, int inlen, char *out, int *out_off, int maxout)
    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;
    }
+1
Changes for boot/zephyr/Kconfig: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ menuconfig MCUBOOT_SERIAL
	select REBOOT
	select UART_INTERRUPT_DRIVEN
	select SERIAL
	select BASE64
	select NEWLIB_LIBC
	help
	  Enable serial recovery feature in mcuboot.