Skip to content

Commit

Permalink
[nrf mergeup] merge upstream up to commit ebd0503
Browse files Browse the repository at this point in the history
Signed-off-by: Andrzej Puzdrowski <[email protected]>
  • Loading branch information
nvlsianpu committed Mar 25, 2019
2 parents 7214d66 + ebd0503 commit 936c7a5
Show file tree
Hide file tree
Showing 112 changed files with 2,378 additions and 881 deletions.
39 changes: 23 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,63 @@

language: rust

cache: cargo
cache:
directories:
- $HOME/TOOLCHAIN
- cargo

matrix:
include:
# Runs each value defined in $SINGLE_FEATURES by itself in the order
# the were defined.
- os: linux
env: SINGLE_FEATURES="sig-ecdsa enc-kw bootstrap"
env: SINGLE_FEATURES="sig-ecdsa enc-kw bootstrap" TEST=sim
- os: linux
env: SINGLE_FEATURES="none sig-rsa overwrite-only validate-slot0"
env: SINGLE_FEATURES="none sig-rsa overwrite-only validate-primary-slot" TEST=sim
- os: linux
env: SINGLE_FEATURES="enc-rsa"
env: SINGLE_FEATURES="enc-rsa" TEST=sim

# Values defined in $MULTI_FEATURES consist of any number of features
# to be enabled at the same time. The list of multi-values should be
# separated by ',' and each list of values is run sequentially in the
# defined order.
- os: linux
env: MULTI_FEATURES="sig-rsa overwrite-only,sig-ecdsa overwrite-only"
env: MULTI_FEATURES="sig-rsa overwrite-only,sig-ecdsa overwrite-only" TEST=sim
- os: linux
env: MULTI_FEATURES="sig-rsa validate-slot0,sig-ecdsa validate-slot0"
env: MULTI_FEATURES="sig-rsa validate-primary-slot,sig-ecdsa validate-primary-slot" TEST=sim
- os: linux
env: MULTI_FEATURES="enc-kw overwrite-only,enc-rsa overwrite-only"
env: MULTI_FEATURES="enc-kw overwrite-only,enc-rsa overwrite-only" TEST=sim
- os: linux
env: MULTI_FEATURES="sig-rsa enc-rsa validate-slot0"
env: MULTI_FEATURES="sig-rsa enc-rsa validate-primary-slot" TEST=sim
- os: linux
env: MULTI_FEATURES="sig-rsa enc-kw validate-slot0 bootstrap"
env: MULTI_FEATURES="sig-rsa enc-kw validate-primary-slot bootstrap" TEST=sim
- os: linux
env: MULTI_FEATURES="sig-ecdsa enc-kw validate-slot0"
env: MULTI_FEATURES="sig-ecdsa enc-kw validate-primary-slot" TEST=sim

# FIXME: this test actually fails and must be fixed
#- os: linux
# env: MULTI_FEATURES="sig-rsa validate-slot0 overwrite-only"
# env: MULTI_FEATURES="sig-rsa validate-primary-slot overwrite-only"

- os: linux
language: go
env: TEST=mynewt
go:
- "1.10"

before_install:
- |
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
./scripts/check-signed-off-by.sh
./ci/check-signed-off-by.sh
if [ $? -ne 0 ]; then
exit 1
fi
fi
install:
- pushd sim
- cargo fetch
- popd
- ./ci/${TEST}_install.sh

script:
- ./scripts/run_tests.sh
- ./ci/${TEST}_run.sh

notifications:
slack:
Expand Down
3 changes: 3 additions & 0 deletions boot/boot_serial/test/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ pkg.deps:

pkg.deps.SELFTEST:
- "@apache-mynewt-core/sys/console/stub"

pkg.cflags:
- '-DMCUBOOT_MYNEWT'
3 changes: 2 additions & 1 deletion boot/boot_serial/test/src/boot_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@
#include "testutil/testutil.h"
#include "hal/hal_flash.h"
#include "flash_map_backend/flash_map_backend.h"
#include "bootutil/bootutil.h"

#include "boot_serial_priv.h"

#ifdef __cplusplus
#extern "C" {
extern "C" {
#endif

void tx_msg(void *src, int len);
Expand Down
4 changes: 2 additions & 2 deletions boot/boot_serial/test/src/testcases/boot_serial_img_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ TEST_CASE(boot_serial_img_msg)
tx_msg(buf, len);

/*
* Validate contents inside image 0 slot
* Validate contents inside the primary slot
*/
rc = flash_area_open(FLASH_AREA_IMAGE_0, &fap);
rc = flash_area_open(FLASH_AREA_IMAGE_PRIMARY, &fap);
assert(rc == 0);

rc = flash_area_read(fap, 0, enc_img, sizeof(img));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ TEST_CASE(boot_serial_upload_bigger_image)
}

/*
* Validate contents inside image 0 slot
* Validate contents inside the primary slot
*/
rc = flash_area_open(FLASH_AREA_IMAGE_0, &fap);
rc = flash_area_open(FLASH_AREA_IMAGE_PRIMARY, &fap);
assert(rc == 0);

for (off = 0; off < sizeof(img); off += sizeof(enc_img)) {
Expand Down
17 changes: 14 additions & 3 deletions boot/bootutil/include/bootutil/bootutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,24 @@
extern "C" {
#endif

/** Attempt to boot the contents of slot 0. */
#if defined(MCUBOOT_MYNEWT)
#define FLASH_AREA_IMAGE_PRIMARY FLASH_AREA_IMAGE_0
#define FLASH_AREA_IMAGE_SECONDARY FLASH_AREA_IMAGE_1
#endif

/** Attempt to boot the contents of the primary slot. */
#define BOOT_SWAP_TYPE_NONE 1

/** Swap to slot 1. Absent a confirm command, revert back on next boot. */
/**
* Swap to the secondary slot.
* Absent a confirm command, revert back on next boot.
*/
#define BOOT_SWAP_TYPE_TEST 2

/** Swap to slot 1, and permanently switch to booting its contents. */
/**
* Swap to the secondary slot,
* and permanently switch to booting its contents.
*/
#define BOOT_SWAP_TYPE_PERM 3

/** Swap back to alternate slot. A confirm changes this state to NONE. */
Expand Down
16 changes: 8 additions & 8 deletions boot/bootutil/include/bootutil/caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ extern "C" {
*/
uint32_t bootutil_get_caps(void);

#define BOOTUTIL_CAP_RSA2048 (1<<0)
#define BOOTUTIL_CAP_ECDSA_P224 (1<<1)
#define BOOTUTIL_CAP_ECDSA_P256 (1<<2)
#define BOOTUTIL_CAP_SWAP_UPGRADE (1<<3)
#define BOOTUTIL_CAP_OVERWRITE_UPGRADE (1<<4)
#define BOOTUTIL_CAP_ENC_RSA (1<<5)
#define BOOTUTIL_CAP_ENC_KW (1<<6)
#define BOOTUTIL_CAP_VALIDATE_SLOT0 (1<<7)
#define BOOTUTIL_CAP_RSA2048 (1<<0)
#define BOOTUTIL_CAP_ECDSA_P224 (1<<1)
#define BOOTUTIL_CAP_ECDSA_P256 (1<<2)
#define BOOTUTIL_CAP_SWAP_UPGRADE (1<<3)
#define BOOTUTIL_CAP_OVERWRITE_UPGRADE (1<<4)
#define BOOTUTIL_CAP_ENC_RSA (1<<5)
#define BOOTUTIL_CAP_ENC_KW (1<<6)
#define BOOTUTIL_CAP_VALIDATE_PRIMARY_SLOT (1<<7)

#ifdef __cplusplus
}
Expand Down
3 changes: 2 additions & 1 deletion boot/bootutil/include/bootutil/enc_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifndef BOOTUTIL_ENC_KEY_H
#define BOOTUTIL_ENC_KEY_H

#include <stdbool.h>
#include <flash_map_backend/flash_map_backend.h>
#include "mcuboot_config/mcuboot_config.h"
#include "bootutil/image.h"
Expand Down Expand Up @@ -51,7 +52,7 @@ extern const struct bootutil_key bootutil_enc_key;
int boot_enc_set_key(uint8_t slot, uint8_t *enckey);
int boot_enc_load(const struct image_header *hdr, const struct flash_area *fap,
uint8_t *enckey);
int boot_enc_valid(const struct flash_area *fap);
bool boot_enc_valid(const struct flash_area *fap);
void boot_encrypt(const struct flash_area *fap, uint32_t off, uint32_t sz,
uint32_t blk_off, uint8_t *buf);
void boot_enc_zeroize(void);
Expand Down
34 changes: 30 additions & 4 deletions boot/bootutil/include/bootutil/sha256.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@

#include "mcuboot_config/mcuboot_config.h"

#if defined(MCUBOOT_USE_MBED_TLS) && defined(MCUBOOT_USE_TINYCRYPT)
#error "Cannot define both MBED_TLS and TINYCRYPT"
#if (defined(MCUBOOT_USE_MBED_TLS) && defined(MCUBOOT_USE_TINYCRYPT))\
||(defined MCUBOOT_USE_MBED_TLS) && defined(MCUBOOT_USE_CC310)\
||(defined(MCUBOOT_USE_TINYCRYPT) && defined(MCUBOOT_USE_CC310))
#error "Cannot define CC310, MBED_TLS and TINYCRYPT"
#endif

#if !defined(MCUBOOT_USE_MBED_TLS) && !defined(MCUBOOT_USE_TINYCRYPT)
#error "One of MBED_TLS or TINYCRYPT must be defined"
#if !defined(MCUBOOT_USE_MBED_TLS) && !defined(MCUBOOT_USE_TINYCRYPT) && !defined(MCUBOOT_USE_CC310)
#error "One of CC310, MBED_TLS or TINYCRYPT must be defined"
#endif

#ifdef MCUBOOT_USE_MBED_TLS
Expand All @@ -47,6 +49,10 @@
#include <tinycrypt/sha256.h>
#endif /* MCUBOOT_USE_TINYCRYPT */

#ifdef MCUBOOT_USE_CC310
#include <cc310_glue.h>
#endif /* MCUBOOT_USE_CC310 */

#include <stdint.h>

#ifdef __cplusplus
Expand Down Expand Up @@ -97,6 +103,26 @@ static inline void bootutil_sha256_finish(bootutil_sha256_context *ctx,
}
#endif /* MCUBOOT_USE_TINYCRYPT */

#ifdef MCUBOOT_USE_CC310
static inline void bootutil_sha256_init(bootutil_sha256_context *ctx)
{
cc310_sha256_init(ctx);
}

static inline void bootutil_sha256_update(bootutil_sha256_context *ctx,
const void *data,
uint32_t data_len)
{
cc310_sha256_update(ctx, data, data_len);
}

static inline void bootutil_sha256_finish(bootutil_sha256_context *ctx,
uint8_t *output)
{
cc310_sha256_finalize(ctx, output);
}
#endif /* MCUBOOT_USE_CC310 */

#ifdef __cplusplus
}
#endif
Expand Down
3 changes: 3 additions & 0 deletions boot/bootutil/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ pkg.apis:
pkg.cflags:
- "-DMCUBOOT_MYNEWT"

pkg.cflags.BOOTUTIL_USE_MBED_TLS:
- '-DMBEDTLS_USER_CONFIG_FILE="mbedtls/config_mynewt.h"'

pkg.deps:
- "@mcuboot/boot/mynewt/mcuboot_config"
- "@apache-mynewt-core/hw/hal"
Expand Down
Loading

0 comments on commit 936c7a5

Please sign in to comment.