Commit Graph

714 Commits

Author SHA1 Message Date
Carles Cufi 6168f427ee doc: Document support for .hex files in imgtool
Specify in the documentation that .hex files are supported by imgtool
when signing.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-03-27 10:09:48 -03:00
Carles Cufi b791138c0c samples: zephyr: Use BOOTLOADER_MCUBOOT
Instead of manually setting the text section offset and the overlay
file, use the now readily available BOOTLOADER_MCUBOOT Kconfig option to
provide that automatically.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-03-27 10:09:18 -03:00
Marti Bolivar 58b321a89f zephyr: CMakeLists: allow users to specify DTC_OVERLAY_FILE fragments
Allow the user to add additional device tree overlays onto the default
one that sets up the code partition.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-03-26 12:46:40 -03:00
David Brown 57837b98e6 zephyr: arm: Use proper macro to set MSP
The macro _MspSet has gone away in Zephyr.  Change to use the __set_MSP
macro from the CMSIS code that has always been present.  This allows
mcuboot to build with Zephyr after:

    commit c028f88b37d2a033d6a85c8d365ef048e1e4d621
    Author: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
    Date:   Mon Mar 12 10:45:02 2018 +0100

        arch: arm: remove redundant asm inline headers

Fixes #246.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-03-14 10:09:55 -06:00
David Brown d9d28a78d4 zephyr: Fix overlay dir for Zephyr build
The Zephyr CMakeLists.txt uses its own logic to have board-specific
overlays, named boards/${BOARD}.prj.  However, the only overlay file we
have, arduino_101.conf, isn't in this boards directory, and this target
doesn't build.

Fix this by moving the target into the right directory.  Fixes #188.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-03-13 16:39:14 -06:00
Christopher Collins db974f2fc2 Mynewt app: Remove .OVERWITE suffix from pkg.deps
The boot loader app needs all the base dependencies, whether or not
`BOOT_SERIAL` is enabled.  Therefore, it makes sense for the serial boot
loader to add to, rather than replace, the dependency list.

This bug in the pkg.yml file went unnoticed ealier because of an issue
in newt: it used to effectively ignore the `.OVERWRITE` suffix when it
was applied to `pkg.deps`.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-02-23 20:50:37 -03:00
David Brown 3f9ec900c4 zephyr: Configure mbed TLS for PSS instead of V1.5
Although MCUboot has used PKCS#1 v2.1 (PSS) for some time now, the mbed
TLS config file was calling out v1.5.  This compiled because MCUboot
implements its own specialized version of the signature check, and only
needs the underlying primitives from mbed TLS.  (The general code in
mbed TLS is quite a bit larger).

To make it clear that we are always using PSS, change the mbed TLS
configuration to call this out explicitly.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-02-23 09:38:47 -07:00
Fabio Utzig 9f7c3d2096 Initialize "uart" only when boot_serial is enabled
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-02-22 15:51:39 -07:00
Andrzej Kaczmarek c49099c284 Make boot serial work on Mynewt
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-02-22 15:51:39 -07:00
Fabio Utzig 1a2e41ae44 Fix serial boot functionality for Mynewt
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-02-22 15:51:39 -07:00
Fabio Utzig fe9dd965f5 Fix with correct release numbers
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-02-16 16:45:03 -07:00
Johann Fischer ed8461b604 bootutil: loader: fix BOOT_STATUS_ASSERT macro
BOOT_STATUS_ASSERT increments the variable if the macro argument
is evaluated as true, which is incorrect behavior compared to the
ASSERT macro.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-02-16 16:44:17 -07:00
Fabio Utzig 84ed794d14 Fix configuration when RSA signature is used
This defines the correct "mbedtls" config files in both ECDSA256 and RSA
modes.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-02-16 16:31:38 -07:00
Fabio Utzig b519ed03dc Use relative links for docs
- Also fix imgtool script link

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-02-16 16:23:09 -07:00
Ding Tao b664a082aa zephyr: mbedtls: Fix compile error no such file or directory
Upstream zephyr will automatically link mbedtls when CONFIG_MBEDTLS is
enabled.

If user chose to use ECDSA_P256 as signature type, will get a compile
error message in file ${ZEPHYR_BASE}/ext/lib/crypto/mbedtls/zephyr_init.c:
    fatal error: config-asn1.h: No such file or directory

Fix this by disable CONFIG_MBEDTLS  when ECDSA_P256 signature type is
selected.

Signed-off-by: Ding Tao <miyatsu@qq.com>
2018-02-14 13:55:23 -02:00
David Brown b77262e18d Bump internal mbedtls to 2.7.0
2.7.0 fixes a security issue but breaks MCU boot.  Bump to this version
so that the simulator will verify that this version works properly.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-02-13 15:10:36 -07:00
David Brown 785dc4c9b3 Fix RSA sigs for mbed TLS 2.7.0
In 2f8f06aa25

    commit 2f8f06aa25e9d5ee4fc9fe217543c872b39e4d05
    Author: Hanno Becker <hanno.becker@arm.com>
    Date:   Fri Sep 29 11:47:26 2017 +0100

        Don't always recompute context length in mbedtls_rsa_get_len

mbed TLS begins assuming that the 'len' field of the context has been
set properly.  Previously, we relied on this not being true, and various
tests fail for all keys without setting this.

The fix is to simply set the length based on the value we read.

fixes #235.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-02-13 15:10:36 -07:00
Fabio Utzig 4dce6aac8b Change all doc links to use relative names
Github pages assumes that links to files using relative
names point to the same location so this should work both
when accessing through the github browser and mcuboot.com

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-02-12 15:53:07 -02:00
Carles Cufi 37d052fff1 imgtool: Add support for Intel Hex images
Some platforms prefer images in the Intel Hex (.hex) format. Implement
support for signing images in this format in imgtool.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-01 16:00:21 -07:00
Carles Cufi f242901a85 imgtool: Use a requirements file for dependencies
Instead of relying on distro packages standardize the imgtool
dependencies into a requirements.txt.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-02-01 16:00:21 -07:00
Marti Bolivar 6f2857c2a7 zephyr: add compatibility shim for flash driver name
The upstream Zephyr project is renaming FLASH_DRIVER_NAME to
FLASH_DEV_NAME as part of some changes related to device tree.

Work around this for now by keeping the MCUboot name the same if
FLASH_DRIVER_NAME is not provided by Zephyr, but FLASH_DEV_NAME is.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-02-01 15:59:18 -07:00
Marti Bolivar aefbd46631 zephyr: try to mass erase when flashing
It's recommended practice to mass erase the flash chip before
reflashing mcuboot. Add a configuration option for Zephyr which does
this by default on some Zephyr runner backends which can support
this (pyOCD and dfu-util). Additional runners can be added as needed.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-01-30 16:17:52 -07:00
Marti Bolivar 388454880f zephyr: fix MCUBOOT_TARGET_CONFIG definition
When the target doesn't have good enough generic support for MCUBoot,
you can specify the flash layout etc on a per-board basis by creating
a header, boot/zephyr/targets/BOARD.h.

The build system tries to pick this up, but isn't doing it
correctly. Fix it.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-01-29 14:35:38 -07:00
David Brown 8e0016eb14 zephyr: Create a test runner for the samples
Enhance the test runner so that it can verify the output of the tests by
itself.  This needs the console to be logged to a file, but otherwise
works the same as the current test runner.

Also, the build results are placed in a log file, so that it is easier
to see what is happening.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-01-29 14:29:48 -07:00
Marti Bolivar dde1b1c481 zephyr: fix the build
Since the Kconfig file was moved in 51a0921006 ("zephyr: Move Kconfig
file to boot/zephyr"), the CMakeLists.txt reference to it needs updating.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-01-29 14:04:13 -07:00
Carles Cufi 67c792efbb zephyr: Enable flash page layout if available
Since not all ICs default to enabling flash page layout, enable it from
the MCUboot Kconfig options whenever it is available.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-29 12:22:48 -07:00
Carles Cufi 84ede5893f kconfig: Add new MCUboot device settings
Add a new MCUboot device settings option that enables or configures
features that are specific to a particular device.
Additionally enable software vector relay in Cortex-M0 CPUs that do not
have a hardware mechanism to relay or forward interrupts.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-29 12:22:48 -07:00
Carles Cufi 51a0921006 zephyr: Move Kconfig file to boot/zephyr
Since the Kconfig file is only relevant to Zephyr, move it from the root
folder into boot/zephyr, in order to keep all Zephyr-related files
together.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-29 12:22:48 -07:00
Sebastian Bøe 9c38d76677 zephyr: hello-world: Samples should not define default boards
hello-world is serving as a sample application and should therefore
not define a default board as Zephyr samples do not either.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-29 16:19:37 -02:00
Sebastian Bøe 688a216a1a zephyr: hello-world: Remove documentaiton for non-existant feature
The documentation claims that one can place per-board overlay files in
the boards/ directory. But no such support has been implemented.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-29 16:19:37 -02:00
Sebastian Bøe 8680b90374 zephyr: boot: Use abs. path instead of rel. path for dts overlay
When a relative path was used the build would fail when CMake was
invoked with the -B -H flags. Using an absolute path for the
dts.overlay flags fixes #187.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-29 16:19:05 -02:00
Carles Cufi 90eda80838 doc: Fix MCUboot capitalization
The correct spelling is "MCUboot", so replace the instances that differ
from this.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-29 15:49:04 -02:00
Fabio Utzig ecc7e14e55 Update nokogiri due to security vulnerability
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-9050

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-01-24 07:07:36 -02:00
Carles Cufi 3b61e70b8b docs: Link to instructions from landing pages
Link to usage instructions from the main README file and from
docs/index.md so that the usage is visible from the root documentation
files.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-23 14:08:14 -02:00
Carles Cufi ecc34bb787 doc: Convert rst to md and move to docs/
To avoid having multiple documentation standards, transition all
documentation files to the Markdown (md) format and move them to the
docs/ folder.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-23 14:08:14 -02:00
Fabio Utzig f70e302617 Fix warn in overwrite-only with slot0 validation
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-01-10 10:35:10 -07:00
Fabio Utzig 891f4fb023 Fix EC API usage due to change in mbed-TLS
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-01-10 10:34:45 -07:00
Fabio Utzig 476fd99d82 Bump to version 1.1.0
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-01-09 16:36:52 -02:00
Fabio Utzig 07d65c9a73 Update Mynewt version numbers
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-01-09 11:32:45 -07:00
Fabio Utzig 49045cc9e8 Update with 1.1.0 release notes
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-01-09 10:58:29 -07:00
David Brown f88d9f95d4 imgtool: Add password support to ECDSA
Signed-off-by: David Brown <david.brown@linaro.org>
2018-01-09 09:41:30 -07:00
David Brown 31d29c8edb imgtool: Update docs for new key format
Update the dependencies needed, as well as adding a blurb about how to
password protect the private key.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-01-09 09:41:30 -07:00
David Brown 2c9153a268 imgtool: ECDSA pad signature
Until we fix the padding problem, pad the ecdsa signatures with zeros to
always be 72 bytes long.  Add a 'raw_sign' method so that the unit test
can use the real signature.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-01-09 09:41:30 -07:00
David Brown b6e0ae695c fix: Add back ECDSA signature support
Replace the (now broken) ECDSA code with code using the python
'cryptography' library.

Similar to the change to RSA, this changes the format that private keys
are stored, again using PKCS#8.  This supports the stronger password
protection as well.

Again, this code will still support reading the older style of public
keys, but other tools that use keys generated by this change will need
to be updated to work with the new format.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-01-09 09:41:30 -07:00
David Brown 20462a7179 fix: RSA: Use 32-byte salt with PSS
The verification code requires a fixed 32-byte salt, which seems is what
the old crypto library did.  Use this same value to avoid having to
modify the code.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-01-09 09:41:30 -07:00
David Brown 1d5bea1cf7 imgtool: Add support for password protected RSA keys
The keygen command allows the `-p` argument which will prompt for a
password, and protect the private key with this password.  When loading
keys, it will prompt for a password if it detects a password protected
key.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-01-09 09:41:30 -07:00
David Brown 47b77c521a imgtool: Fix signing payload type
The 'cryptography' library is pickier about the data it is asked to
sign.  Get the bytes value out of the bytearray for doing the actual
signature.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-01-09 09:41:30 -07:00
David Brown 5e7c6dd58a imgtool: Update RSA code
Replace RSA code with one using the python 'cryptography' library.  This
library is much more complete, and will make adding support for password
protected keys, and separate public keys easier.

There is, however, a significant change brought about by this change:
the private keys are stored in PKCS#8 format, instead of the raw format
that was used previously.  This is a more modern format that has a few
advantages, including: supporting stronger password protection, and
allowing the key type to be determined upon read.

This tool will still support reading the old style public keys, but
other tools that use these keys will need to be updated in order to work
with the new format.

This new code has some unit tests to go along with it for some basic
sanity testing of the code.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-01-09 09:41:30 -07:00
David Brown d4022576e4 imgtool: Remove PKCS1.5 support
Support for PKCS1.5 has been removed from the bootloader for a while
now, remove it as well from the tool.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-01-09 09:41:30 -07:00
David Brown 244547346e imgtool: Move keys to submodule
Move this code into a submodule to prepare to cleanup and enhance the
key management code.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-01-09 09:41:30 -07:00