makefiles/suit: store public keys, make it easier to work with multiple keys#20858
makefiles/suit: store public keys, make it easier to work with multiple keys#20858benpicco merged 3 commits intoRIOT-OS:masterfrom
Conversation
3f839d4 to
db70fa0
Compare
|
Cool feature. Maybe this is simply a case of bad usage but was still kind of unexpected to me. |
db70fa0 to
1e49e23
Compare
|
heh, good catch! We might also just replace that call to the 'custom' Python script with another OpenSSL invocation. |
7b67d77 to
2a18905
Compare
This makes it easier to work with encrypted keys and multiple keys. The firmware binary can contain multiple public keys that are used to verify the manifest. The use case is that we want to include the production public key in the debug build, so we can seamlessly update to the production version without re-flashing the device. If the public keys is always generated on the fly, this would still require the production key password even for the debug build. Instead if we store the (unencrypted) public key, we can always include it in the debug build.
2a18905 to
5c8f6ad
Compare
5c8f6ad to
99285d3
Compare
a197a0f to
c40262e
Compare
fabian18
left a comment
There was a problem hiding this comment.
make -C examples/suit_update clean suit/publish SUIT_KEY="default prod" SUIT_KEY_SIGN=prod SUIT_SEC_PASSWORD=123456789
make: Entering directory '/home/[email protected]/RIOT/examples/suit_update'
rm -rf /home/[email protected]/RIOT/bootloaders/riotboot/bin/samr21-xpro/pkg-build/cmsis
# Reset package to checkout state.
rm -rf /home/[email protected]/RIOT/build/pkg/c25519
rm -rf /home/[email protected]/RIOT/examples/suit_update/bin/samr21-xpro/pkg-build/cmsis
rm -rf /home/[email protected]/RIOT/examples/suit_update/bin/samr21-xpro/pkg-build/libcose
rm -rf /home/[email protected]/RIOT/examples/suit_update/bin/samr21-xpro/pkg-build/nanocbor
compiling /home/[email protected]/RIOT/dist/tools/riotboot_gen_hdr/bin/genhdr...
make: Nothing to be done for 'all'.
suit: generating key in /home/[email protected]/.local/share/RIOT/keys
0) none
1) aes-256-cbc
Choose encryption for key file /home/[email protected]/.local/share/RIOT/keys/prod.pem: 1
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
read EC key
Enter pass phrase for /home/[email protected]/.local/share/RIOT/keys/prod.pem:
writing EC key
read EC key
writing EC key
read EC key
writing EC key
test "dbfb4285837ab2ea3d99c448b22877cc7a139ccbaebb1de367e2bec1fd562fe629b389d86603915448078b8fd7e631c8fc9a7d126eb889a1ba0c17611369b190 /home/[email protected]/RIOT/build/pkg/c25519-2017-10-05.zip" = "$(sha512sum "/home/[email protected]/RIOT/build/pkg/c25519-2017-10-05.zip")"
"make" -C /home/[email protected]/RIOT/pkg/c25519/
"make" -C /home/[email protected]/RIOT/build/pkg/c25519/src -f /home/[email protected]/RIOT/Makefile.base MODULE=c25519
"make" -C /home/[email protected]/RIOT/pkg/cmsis/
"make" -C /home/[email protected]/RIOT/pkg/libcose/
"make" -C /home/[email protected]/RIOT/build/pkg/libcose/src -f /home/[email protected]/RIOT/Makefile.base MODULE=libcose
"make" -C /home/[email protected]/RIOT/build/pkg/libcose/src/crypt -f /home/[email protected]/RIOT/pkg/libcose/Makefile.libcose_crypt
"make" -C /home/[email protected]/RIOT/pkg/nanocbor/
"make" -C /home/[email protected]/RIOT/build/pkg/nanocbor/src -f /home/[email protected]/RIOT/Makefile.base MODULE=nanocbor
"make" -C /home/[email protected]/RIOT/boards/common/init
"make" -C /home/[email protected]/RIOT/boards/samr21-xpro
"make" -C /home/[email protected]/RIOT/core
"make" -C /home/[email protected]/RIOT/core/lib
"make" -C /home/[email protected]/RIOT/cpu/samd21
"make" -C /home/[email protected]/RIOT/cpu/cortexm_common
"make" -C /home/[email protected]/RIOT/cpu/cortexm_common/periph
"make" -C /home/[email protected]/RIOT/cpu/sam0_common
"make" -C /home/[email protected]/RIOT/cpu/sam0_common/periph
"make" -C /home/[email protected]/RIOT/cpu/samd21/periph
"make" -C /home/[email protected]/RIOT/cpu/samd21/vectors
"make" -C /home/[email protected]/RIOT/drivers
"make" -C /home/[email protected]/RIOT/drivers/edbg_eui
"make" -C /home/[email protected]/RIOT/drivers/ethos
"make" -C /home/[email protected]/RIOT/drivers/netdev
"make" -C /home/[email protected]/RIOT/drivers/periph_common
"make" -C /home/[email protected]/RIOT/pkg/libcose/init
"make" -C /home/[email protected]/RIOT/sys
"make" -C /home/[email protected]/RIOT/sys/auto_init
"make" -C /home/[email protected]/RIOT/sys/checksum
"make" -C /home/[email protected]/RIOT/sys/crypto
"make" -C /home/[email protected]/RIOT/sys/div
"make" -C /home/[email protected]/RIOT/sys/event
"make" -C /home/[email protected]/RIOT/sys/evtimer
"make" -C /home/[email protected]/RIOT/sys/fmt
"make" -C /home/[email protected]/RIOT/sys/frac
"make" -C /home/[email protected]/RIOT/sys/hashes
"make" -C /home/[email protected]/RIOT/sys/iolist
"make" -C /home/[email protected]/RIOT/sys/isrpipe
"make" -C /home/[email protected]/RIOT/sys/libc
"make" -C /home/[email protected]/RIOT/sys/luid
"make" -C /home/[email protected]/RIOT/sys/malloc_thread_safe
"make" -C /home/[email protected]/RIOT/sys/net/application_layer/nanocoap
"make" -C /home/[email protected]/RIOT/sys/net/application_layer/uhcp
"make" -C /home/[email protected]/RIOT/sys/net/crosslayer/inet_csum
"make" -C /home/[email protected]/RIOT/sys/net/gnrc
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/netapi
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/netif
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/netif/ethernet
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/netif/hdr
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/netif/init_devs
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/netreg
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/network_layer/icmpv6
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/network_layer/icmpv6/echo
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/network_layer/ipv6
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/network_layer/ipv6/hdr
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/network_layer/ipv6/nib
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/network_layer/ndp
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/pkt
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/pktbuf
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/pktbuf_static
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/sock
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/sock/udp
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/transport_layer/udp
"make" -C /home/[email protected]/RIOT/sys/net/gnrc/application_layer/uhcpc
"make" -C /home/[email protected]/RIOT/sys/net/link_layer/eui_provider
"make" -C /home/[email protected]/RIOT/sys/net/link_layer/l2util
"make" -C /home/[email protected]/RIOT/sys/net/netif
"make" -C /home/[email protected]/RIOT/sys/net/netutils
"make" -C /home/[email protected]/RIOT/sys/net/network_layer/icmpv6
"make" -C /home/[email protected]/RIOT/sys/net/network_layer/ipv6/addr
"make" -C /home/[email protected]/RIOT/sys/net/network_layer/ipv6/hdr
"make" -C /home/[email protected]/RIOT/sys/net/sock
"make" -C /home/[email protected]/RIOT/sys/net/transport_layer/udp
"make" -C /home/[email protected]/RIOT/sys/newlib_syscalls_default
"make" -C /home/[email protected]/RIOT/sys/pm_layered
"make" -C /home/[email protected]/RIOT/sys/posix/inet
"make" -C /home/[email protected]/RIOT/sys/preprocessor
"make" -C /home/[email protected]/RIOT/sys/progress_bar
"make" -C /home/[email protected]/RIOT/sys/random
"make" -C /home/[email protected]/RIOT/sys/riotboot
"make" -C /home/[email protected]/RIOT/sys/shell
"make" -C /home/[email protected]/RIOT/sys/shell/cmds
"make" -C /home/[email protected]/RIOT/sys/suit
"make" -C /home/[email protected]/RIOT/sys/suit/storage
"make" -C /home/[email protected]/RIOT/sys/suit/transport
"make" -C /home/[email protected]/RIOT/sys/test_utils/interactive_sync
"make" -C /home/[email protected]/RIOT/sys/tiny_strerror
"make" -C /home/[email protected]/RIOT/sys/tsrb
"make" -C /home/[email protected]/RIOT/sys/uuid
"make" -C /home/[email protected]/RIOT/sys/vfs
"make" -C /home/[email protected]/RIOT/sys/vfs_util
"make" -C /home/[email protected]/RIOT/sys/ztimer
creating /home/[email protected]/RIOT/examples/suit_update/bin/samr21-xpro/riotboot_files/slot0.1726166621.bin...
creating /home/[email protected]/RIOT/examples/suit_update/bin/samr21-xpro/riotboot_files/slot1.1726166621.bin...
published "/home/[email protected]/RIOT/examples/suit_update/bin/samr21-xpro/suit_files/riot.suit.1726166621.bin"
as "coap://localhost/fw/suit_update/samr21-xpro/riot.suit.1726166621.bin"
published "/home/[email protected]/RIOT/examples/suit_update/bin/samr21-xpro/suit_files/riot.suit.latest.bin"
as "coap://localhost/fw/suit_update/samr21-xpro/riot.suit.latest.bin"
published "/home/[email protected]/RIOT/examples/suit_update/bin/samr21-xpro/riotboot_files/slot0.1726166621.bin"
as "coap://localhost/fw/suit_update/samr21-xpro/slot0.1726166621.bin"
published "/home/[email protected]/RIOT/examples/suit_update/bin/samr21-xpro/riotboot_files/slot1.1726166621.bin"
as "coap://localhost/fw/suit_update/samr21-xpro/slot1.1726166621.bin"
make: Leaving directory '/home/[email protected]/RIOT/examples/suit_update'
const uint8_t public_key[][32] = {
{
0xad, 0x7f, 0x4e, 0xc2, 0xd5, 0x0b, 0xa3, 0xb3, 0xef, 0x8f, 0x7a, 0xc5,
0xa6, 0x73, 0xcc, 0x4a, 0xf5, 0x01, 0x30, 0xae, 0x6a, 0x58, 0xf8, 0xce,
0xd4, 0xcf, 0x8e, 0xf9, 0x3f, 0xc6, 0xc8, 0x92
},
{
0x18, 0xcb, 0x23, 0x9f, 0x6c, 0xd6, 0x82, 0xae, 0x7f, 0xbd, 0x77, 0xc1,
0x4a, 0x9b, 0x04, 0x33, 0xa4, 0xce, 0x99, 0xb6, 0x12, 0x92, 0x38, 0x5b,
0x1d, 0xdf, 0xd4, 0x87, 0x67, 0x2c, 0x4d, 0xed
},
};Co-authored-by: Fabian Hüßler <[email protected]>
c40262e to
765dd68
Compare
|
Thank you for the review! |
Contribution description
This makes it easier to work with encrypted keys and multiple keys. The firmware binary can contain multiple public keys that are used to verify the manifest.
The use case is that we want to include the production public key in the debug build, so we can seamlessly update to the production version without re-flashing the device.
If the public keys is always generated on the fly, this would still require the production key password even for the debug build.
Instead if we store the (unencrypted) public key, we can always include it in the debug build.
Testing procedure
prod.pemexamples/suit_updatewithmake SUIT_KEY="default prod"OpenSSL only asks for the passwort to create the public key once, then the firmware can be build without needing to decrypt the production key.
contents of generated
riotbuild/public_key.hOnly when the firmware is published (signed) the password for the production key needs to be entered.
Issues/PRs references