-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zephyr: Support RSA, and ECDSA P-256 signing
Make it clear in the top-level Makefile how to configure mcuboot for Zephyr for a particular signing algorithm. Currently supported, are the RSA signatures, and ECDSA with the P-256 curve. These configuration lines will select the code built in the bootloader, as well as which public key gets included with the image. This also adds a demo public key for the P-256 signatures.
- Loading branch information
Showing
8 changed files
with
159 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
# Makefile for Zephyr build | ||
|
||
ccflags-y += -DBOOTUTIL_SIGN_RSA | ||
|
||
obj-y += loader.o bootutil_misc.o image_validate.o image_rsa.o | ||
obj-y += loader.o bootutil_misc.o image_validate.o image_rsa.o image_ec256.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Configuration of mbedTLS containing only the ASN.1 parser. | ||
* | ||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved | ||
* Copyright (C) 2016, Linaro Ltd | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* This file is part of mbed TLS (https://tls.mbed.org) | ||
*/ | ||
|
||
/* | ||
* Minimal configuration for using TLS in the bootloader | ||
* | ||
* - RSA or ECDSA signature verification | ||
*/ | ||
|
||
#ifndef MBEDTLS_CONFIG_H | ||
#define MBEDTLS_CONFIG_H | ||
|
||
#define MBEDTLS_PLATFORM_C | ||
#define MBEDTLS_PLATFORM_MEMORY | ||
#define MBEDTLS_MEMORY_BUFFER_ALLOC_C | ||
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS | ||
|
||
/* mbed TLS modules */ | ||
#define MBEDTLS_ASN1_PARSE_C | ||
// #define MBEDTLS_ASN1_WRITE_C | ||
// #define MBEDTLS_BIGNUM_C | ||
// #define MBEDTLS_MD_C | ||
// #define MBEDTLS_OID_C | ||
#define MBEDTLS_SHA256_C | ||
|
||
#include "mbedtls/check_config.h" | ||
|
||
#endif /* MBEDTLS_CONFIG_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CONFIG_CONSOLE_HANDLER=y | ||
CONFIG_SYS_LOG=y | ||
CONFIG_DEBUG=y | ||
|
||
CONFIG_MAIN_STACK_SIZE=10240 | ||
CONFIG_MBEDTLS=y | ||
CONFIG_MBEDTLS_BUILTIN=y | ||
CONFIG_MBEDTLS_CFG_FILE="config-asn1.h" | ||
CONFIG_TINYCRYPT=y | ||
CONFIG_TINYCRYPT_ECC_DSA=y | ||
|
||
### mbedTLS wants a heap | ||
CONFIG_HEAP_MEM_POOL_SIZE=16384 | ||
|
||
CONFIG_FLASH=y | ||
|
||
### Disable Bluetooth by default | ||
# CONFIG_BLUETOOTH is not set |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-----BEGIN EC PRIVATE KEY----- | ||
MHcCAQEEINeY1S+DASQ701QrflXtTHRhGQCw+VBagk/h6OwGO8/xoAoGCCqGSM49 | ||
AwEHoUQDQgAEKstAPOj+7VukSZWhqR2u6Nu+GTfNFPsvJFc35ZU5iNmUudZa69fN | ||
1TCK1v5IskpqgQ7l8H2LaDTMOmr8U476wQ== | ||
-----END EC PRIVATE KEY----- |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,48 @@ | ||
#! /bin/sh | ||
|
||
# This script can be used as an example of how to sign images. | ||
|
||
source $(dirname $0)/target.sh | ||
|
||
./scripts/zep2newt.py \ | ||
--bin ../zephyr/samples/shell/outdir/$BOARD/zephyr.bin \ | ||
--key root.pem \ | ||
--sig RSA \ | ||
--out shell.signed.bin \ | ||
--vtoff 0x200 \ | ||
--word-size 8 \ | ||
--image-version 3 \ | ||
--bit --pad 0x20000 | ||
# RSA signatures can be made with the signing script in the scripts | ||
# directory. | ||
if true; then | ||
./scripts/zep2newt.py \ | ||
--bin ../zephyr/samples/shell/outdir/$BOARD/zephyr.bin \ | ||
--key root.pem \ | ||
--sig RSA \ | ||
--out shell.signed.bin \ | ||
--vtoff 0x200 \ | ||
--word-size 8 \ | ||
--image-version 3 \ | ||
--bit --pad 0x20000 | ||
|
||
./scripts/zep2newt.py \ | ||
--bin ../zephyr/samples/hello_world/outdir/$BOARD/zephyr.bin \ | ||
--key root.pem \ | ||
--sig RSA \ | ||
--vtoff 0x200 \ | ||
--word-size 8 \ | ||
--image-version 2 \ | ||
--out hello.signed.bin | ||
fi | ||
|
||
# Currently, ECDSA signatures need to be made with the imgtool. See | ||
# 'imgtool' for instructions on building the tool. | ||
if false; then | ||
imgtool sign \ | ||
--key root_ec.pem \ | ||
--header-size 0x200 \ | ||
--version 3.0 \ | ||
--align 8 \ | ||
--pad 0x20000 \ | ||
../zephyr/samples/shell/outdir/$BOARD/zephyr.bin \ | ||
shell.signed.bin | ||
|
||
./scripts/zep2newt.py \ | ||
--bin ../zephyr/samples/hello_world/outdir/$BOARD/zephyr.bin \ | ||
--key root.pem \ | ||
--sig RSA \ | ||
--vtoff 0x200 \ | ||
--word-size 8 \ | ||
--image-version 2 \ | ||
--out hello.signed.bin | ||
imgtool sign \ | ||
--key root_ec.pem \ | ||
--header-size 0x200 \ | ||
--version 3.0 \ | ||
../zephyr/samples/hello_world/outdir/$BOARD/zephyr.bin \ | ||
hello.signed.bin | ||
fi |