Commit Graph

703 Commits

Author SHA1 Message Date
Fabio Utzig 04fd63e6ba Add build section for mbedTLS config
This makes it easier to choose the mbedTLS config file when multiple
features share files.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-12-17 14:41:02 -02:00
Fabio Utzig 754438dfd5 Fix TLV sizes for signed images
TLV types don't need to list KEYHASH because it's already added by any
signature TLV.

Total sizes were missing the KEYHASH amount.

Add a new TLV for images signed with RSA and encrypted with RSA-OAEP.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-12-17 14:41:02 -02:00
Fabio Utzig cd28406e9a Fix image creation without sign/encryption
Generating images with no signature or encryption was broken by commit
06b77b8353

This allows generating images with just sha256 again, and fixes a few
leftovers from the imghash TLV change.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-12-17 10:51:46 -02:00
Fabio Utzig 71a697a4ea Add minimum size validation for header parameter
Throw exception on values that are less than the minimum acceptable size
of 32 bytes.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-12-17 09:45:55 -02:00
Fabio Utzig 9b7a25833b Fix overwrite-only encrypted images in sim
Also add overwrite-only + encrypted tests to travis-ci.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-12-04 14:21:52 -02:00
Fabio Utzig e641ea5ee5 Fix overwrite only encrypted to not use local var
Use existing global var instead of using locally declared variable,
reducing RAM usage.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-12-04 14:21:52 -02:00
Fabio Utzig 1c7d959eeb Fix rebase issue
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-12-04 14:21:52 -02:00
Fabio Utzig 38609e0c9c Fix typo in signed-off-by check error message
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-11-27 13:47:14 -03:00
Fabio Utzig 0e12f6ce98 Travis speed ups
Because the amount of features that the simulator is testing is growing,
the test time is taking a long time. This distributes simulator's tests
over three travis machines to decrease test time.

Add options to defined tests that run one-by-one in a sequential fashion
by defining them in $SINGLE_FEATURES, and allow defining features that
should run together by providing a string of ',' separated list of
multiple tests in $MULTI_FEATURES.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-11-27 13:47:14 -03:00
Fabio Utzig a3c2f05754 Fix main github repo links in docs
This updates all references from github.com/runtimeco to
github.com/JuulLabs-OSS in docs and yml files.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-11-16 15:10:52 -03:00
Andrzej Puzdrowski f50054d998 fix zephyr target: corrupted build after zephyr PR #11180
zephyrproject-rtos/zephyr#11180: Zephyr target was corrupted as
recently zephyr's device tree started adding DT_ prefix in
generated labels.

This path aligns flash name macro used.


Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-11-14 14:56:35 +01:00
Emanuele Di Santo 865777ddc9 boot: zephyr: add MCUBOOT config
Add a hidden MCUBOOT config entry to mark a project as MCUBOOT.
It is useful when other parts of the system need to be aware
that they are, in fact, the bootloader.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2018-11-09 14:08:56 +01:00
Yiping Peng 3393992943 Fixed an issue that supported later versions of mbedtls than mbedtls-2.6.1
Signed-off-by: Yiping Peng <836885645@qq.com>
Signed-off-by: Yiping Peng <yibingp@internal.synopsys.com>
2018-11-09 08:12:29 -03:00
Emanuele Di Santo 4d20525195 boot: zephyr: cleanup nrf52840_pca10059 configuration
Cleanup board configuration.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2018-11-03 12:07:51 +01:00
Emanuele Di Santo fcfff58417 boot: zephyr: add missing sys_clock_disable declaration
Add missing declaration of sys_clock_disable() to fix compiler warning.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2018-11-03 12:07:51 +01:00
Emanuele Di Santo 4a60ee7c76 zephyr: add support for pca10059
This commit adds a project configuration for the upcoming
nrf52840_pca10059 board.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-10-30 18:17:23 +01:00
Emanuele Di Santo c4bf78009c zephyr: selectable serial device for recovery
This commit adds a choice for the device to use for serial recovery.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>

fixup
2018-10-30 18:17:23 +01:00
Sigvart M. Hovland 68b3053694 Add deprecated warning to Jira and Confluence links
This will fix #336 by adding deprecation warning to Jira and
Confluence links as these are not used by the project anymore.

Signed-off-by: Sigvart M. Hovland <sigvart.m@gmail.com>
2018-10-22 15:30:47 -03:00
Christopher Collins e6e130b5ca Mynewt: Add `version.yml` file
This file lets newt determine the version of the mcuboot repo.  Without
this file, newt reports this annoying warning on each operation:

    WARNING: Could not detect version of installed repo "mcuboot"; assuming 0.0.0/178be54bd6e5f035cc60e98205535682acd26e64

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-10-17 16:35:03 -07:00
Fabio Utzig e3937255d7 Fix imgtool encrypt rebase issue
Avoid passing invalid `encrypt` param to image constructor.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-14 06:00:15 -07:00
Fabio Utzig cdfa11a7a9 Add encrypt images design/usage documentation
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-12 13:36:13 -03:00
Fabio Utzig 459c3a3106 Enable encrypted image tests to run on travis-ci
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-12 13:36:13 -03:00
Fabio Utzig 1e48b914a9 Add encrypted image support on sim
This adds new cargo features to allow running tests of encrypted
images with both RSA-OAEP and AES-128-KW.

When installing images on the simulated flash, both a plain and an
encrypted images are created. When encrypted image support is enabled,
verification of images in slot1 match against the encrypted image,
otherwise plain images are used.

PS: Also fixes ImageHeader to match bootutil definition.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-12 13:36:13 -03:00
Fabio Utzig 0d16482be8 Add mbedtls config with nist_kw enabled
This adds a mbedtls config that will enable the simulator to run tests
for the kw based encrypted images.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-12 13:36:13 -03:00
Fabio Utzig 5fe874c34e Add Zephyr support for encrypted images
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-12 13:36:13 -03:00
Fabio Utzig 0170f26de1 Add Mynewt config for encrypted images
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-12 13:36:13 -03:00
Fabio Utzig 06b77b8353 Add imgtool support for encrypted image creation
Adds a new flag to imgtool, -E/--encrypt which accepts a public rsa-2048
key file that will be used to encrypt the image.

The encryption method uses AES-128-CTR to encrypt the image data (ignores
the header and TLVs), using a random key that is itself encrypted using
RSA-2048-OAEP and added to the generated image as a new TLV.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-12 13:36:13 -03:00
Fabio Utzig ba829049ea Add bootutil support for encrypted images
This allows storing encrypted images in slot1, that are automatically
decrypted when copying to slot0 and re-encrypted when copying from slot0
to slot1.

The encryption works by applying AES-CTR-128 on the image blocks
(excluding the header and TLVs) using a random key. This random key
is itself encrypted using either RSA-OAEP-2048 or AES-KW-128 (AES keywrap
as defined by RFC3394), and appended to the image as newly defined TLVs.

AES-CTR-128 was chosen primarily for having stream cipher proporties,
which basically means that any block being encrypted/decrypted does not
depend on any other previous blocks results.

The TLV adds about 256 bytes to the image in RSA-OAEP-2048 mode, and 24
bytes in AES-KW-128 mode. Resulting sizes for a Mynewt generated mcuboot
(frdm-k64f):

- swap mode and no signing: 12KB
- adding encryption with RSA-OAEP-2048: 28KB
- adding encryption with AES-KW-128: 20KB

Some extra comments:

- AES-KW-128 requires a fairly new mbedtls with nist_kw support.
- An alternative methods which could be added later are ECIES.
- Key-wrapping seems easy enough to implement using just standard
  AES-ECB mode that it should be straight-forward to also add support to
  tinycrypt.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-12 13:36:13 -03:00
Fabio Utzig 9d306d20dc Add sample encryption keys
This adds both RSA (pub + private) keys and a base64 encoded AES-128
secret key, which should be used as sample keys in encrypted image tests.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-12 13:36:13 -03:00
Fabio Utzig 73d8b03312 Remove redundant text in SoB error message
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-12 12:35:29 -03:00
Fabio Utzig d8f84bcc39 Print missing Signed-off-by line info
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-11 10:06:27 -03:00
Andrzej Puzdrowski 5f81b127e1 zephyr: fix flash_area_read_is_empty
Implementation of flash_area_read_is_empty introduced recently
uses deprecated hal_flash_read API which caused build failure.

This patch uses zephyr's native flash_area_read() API which
solves the bug.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-10-09 12:45:09 +02:00
Fabio Utzig 178be54bd6 Test erased flash with "flash_area_read_is_empty()"
Mynewt has recently added an encrypted flash layer driver, that runs
transparently on any flash, handling reads and writes, and bypassing
other flash operations to the HW driver. As a result of this change,
checking for erased data cannot be done by read + compare to erased_val
but need to be routed to an empty check on the lower level. To do this
Mynewt added a new flash_map function called "flash_area_read_is_empty"
which checks for erased blocks (and reads/decrypts the data as well).

This commit uses `flash_area_read_is_empty` to determine if magic,
flags and swap status are erased. For Zephyr/sim commits were added
previously that mimic this functionality by simply doing the
read/compare.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-01 21:42:20 -03:00
Fabio Utzig cea90f970f Add flash_area_read_is_empty to Zephyr port
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-01 21:42:20 -03:00
Fabio Utzig 35d31b4023 Add flash_area_read_is_empty to sim
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-01 21:42:20 -03:00
Marti Bolivar 08b8058b5c zephyr: hello-world: remove BUILD_TIMESTAMP from prj.conf
This feature has been deleted in Zephyr upstream. The project won't
build with this line in anymore due to Kconfig errors.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-10-01 21:41:40 -03:00
Marti Bolivar 5f15fe87e9 zephyr: hello-world: add cmake_minimum_required
The sample fails to build without it now due to changes in the
boilerplate file.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-10-01 21:41:40 -03:00
Mark Schulte a66c68732e [imgtool] Add big endian support
Add big endian support to imgtool so that it can be used on big endian
targets.

Signed-off-by: Mark Schulte <mschulte@lyft.com>
2018-09-27 13:55:58 -03:00
Fabio Utzig 08fa267260 Fix copy_done setting
This compliments the previous change on `image_ok` and also removes
`flash_area_erased_val` call that is not needed anymore.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-09-27 10:52:33 -03:00
Łukasz Rymanowski a1927f4d6b Fix setting confirm flag
It was impossible to set confirm flag due to incorrect comparison.
In this point of time state->image_ok is already decoded and contains
one of following values:

If BOOT_FLAG_UNSET then we are ok to set a confirm flag.

Signed-off-by: Łukasz Rymanowski <lukasz.rymanowski@codecoup.pl>
2018-09-26 12:20:17 -03:00
Hovland, Sigvart 1d96f36d01 Fix the wrong size of array of magic word in bootutil_misc
This will fix #335 by defining the array size of the magic word and
give it to the relevant functions.

Signed-off-by: Hovland, Sigvart <sigvart.hovland@nordicsemi.no>
2018-09-26 13:22:03 +02:00
Fabio Utzig 42ad446fb0 Add `flash_area_erased_val` "mock" for Zephyr
For Zephyr assume flash is always erased to 0xff. This allows backward
compatibility of the new flash erased to 0 support.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-09-17 12:42:49 -03:00
Fabio Utzig 3900001c87 Add support for flash devices erased at 0
This extends mcuboot to allow use on devices which don't follow the
typical erased at 0xff. This was tested on some previously supported
devices (erased at 0xff) and STM32L1/L0 which are erased at 0.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-09-17 12:42:49 -03:00
Fabio Utzig ea0290b88b Add sim support for flash erased at 0
This extends the simulator to be able to test the bootloader in devices
which use flash technologies that erase flash at 0 instead of 0xff.
Two MCU devices that have this "property" are the STM32L0x and STM32L1x
lines from ST.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-09-17 12:42:49 -03:00
Fabio Utzig fc711e3de9 Remove usage of hal_flash_align
`hal_flash_*` functions were replaced by `flash_area_*` with similar
functionality.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-09-17 12:42:49 -03:00
Fabio Utzig eb1e8d465f Update jekyll dependencies to fix CVE-2018-1000201
https://nvd.nist.gov/vuln/detail/CVE-2018-1000201

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-09-13 08:40:46 -03:00
Fabio Utzig b04afa9cb3 Update mbedtls submodule to 2.12.0
This also updates the RSA test to add extra build files for zeroize, and
updates to new calloc/free configuration style.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-09-13 06:54:30 -03:00
Marti Bolivar 5de83b1e47 zephyr: config-rsa.h: remove copypasta
MCUboot doesn't need mbedTLS's entropy code (you don't need random
numbers to check a digital signature), but it enables it. This causes
really scary warnings when building entropy.c, since the test entropy
source is enabled:

    [113/197] Building C object zephyr/ext/lib/crypto/mbedtls/CMakeFiles/ext__lib__crypto__mbedtls.dir/library/entropy.c.obj
    /home/mbolivar/src/zephyr/ext/lib/crypto/mbedtls/library/entropy.c:31:2: warning: #warning "**** WARNING!  MBEDTLS_TEST_NULL_ENTROPY defined! " [-Wcpp]
     #warning "**** WARNING!  MBEDTLS_TEST_NULL_ENTROPY defined! "
      ^~~~~~~
    /home/mbolivar/src/zephyr/ext/lib/crypto/mbedtls/library/entropy.c:32:2: warning: #warning "**** THIS BUILD HAS NO DEFINED ENTROPY SOURCES " [-Wcpp]
     #warning "**** THIS BUILD HAS NO DEFINED ENTROPY SOURCES "
      ^~~~~~~
    /home/mbolivar/src/zephyr/ext/lib/crypto/mbedtls/library/entropy.c:33:2: warning: #warning "**** THIS BUILD IS *NOT* SUITABLE FOR PRODUCTION USE " [-Wcpp]
     #warning "**** THIS BUILD IS *NOT* SUITABLE FOR PRODUCTION USE "
      ^~~~~~~

Delete the bits of the mbedTLS configuration that compile this
file (along with some testing code we don't care about either) to
clean up the warning. This looks like copy/paste code from the initial
mbedTLS config import into MCUboot.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-09-05 20:30:01 -03:00
Marti Bolivar 0e259097fb zephyr: prj.conf: disable CONFIG_BT_CTLR too
Various Zephyr boards (I'm looking at you, every-single-nRF-board)
set CONFIG_BT_CTLR=y as well as CONFIG_BT. Make sure it's disabled for
MCUboot's default prj.conf, where it's not needed and has been causing
very verbose Kconfiglib warnings:

    warning: BT_CTLR (defined at subsys/bluetooth/controller/Kconfig:10) was assigned the value 'y' but
    got the value 'n'. You can check symbol information (including dependencies) in the 'menuconfig'
    interface (see the Application Development Primer section of the manual), or in the Kconfig
    reference at http://docs.zephyrproject.org/reference/kconfig/CONFIG_BT_CTLR.html (which is updated
    regularly from the master branch). See the 'Setting configuration values' section of the Board
    Porting Guide as well.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-09-05 20:30:01 -03:00
Piotr Mienkowski 8a474ff082 docs: zephyr: add "Installing Requirements and Dependencies"
This patch documents requirements and dependencies necessary to build
mcuboot on Zephyr.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2018-08-08 07:02:50 -03:00