Skip to content

External flash encryption#62

Merged
dgarske merged 22 commits intowolfSSL:masterfrom
danielinux:ext_flash_encryption
Jun 18, 2020
Merged

External flash encryption#62
dgarske merged 22 commits intowolfSSL:masterfrom
danielinux:ext_flash_encryption

Conversation

@danielinux
Copy link
Copy Markdown
Member

@danielinux danielinux commented Jun 18, 2020

External partitions content can now be encrypted using ChaCha20.

Keytools can generate 'signed_and_encrypted.bin' version of the updates to be stored on external devices.

Details in the manual page.

Depends on wolfcrypt-py PR #14 and PR#15.

Comment thread test-app/app_stm32wb.c Outdated
Comment thread tools/keytools/sign.c Outdated
Comment thread tools/test-enc.mk Outdated
Comment thread src/libwolfboot.c
Comment thread tools/uart-flash-server/ufserver.c
Comment thread docs/encrypted_partitions.md Outdated
Comment thread docs/encrypted_partitions.md Outdated
Comment thread docs/encrypted_partitions.md Outdated
Comment thread docs/remote_flash.md Outdated
Copy link
Copy Markdown
Member

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the latest wolfcrypt-py its still not working on the mac. Here are my logs:

make USBTTY=/dev/cu.usbmodem1452203 test-enc-update
	[CC-ARM] hal/stm32wb.o
	[CC-ARM] src/loader.o
	[CC-ARM] src/string.o
	[CC-ARM] src/image.o
	[CC-ARM] src/libwolfboot.o
	[CC-ARM] src/boot_arm.o
	[CC-ARM] src/uart_flash.o
	[CC-ARM] src/ecc256_pub_key.o
	[CC-ARM] src/update_flash.o
	[CC-ARM] src/xmalloc_ecc.o
	[LD] wolfboot.elf
	[BIN] wolfboot.bin

	[SIZE]
   text	   data	    bss	    dec	    hex	filename
  23820	      0	  13908	  37728	   9360	wolfboot.elf

	[CC-ARM] ../src/libwolfboot.o
	[LD] image.elf
	[BIN] image.bin
   text	   data	    bss	    dec	    hex	filename
   4184	     52	   4384	   8620	   21ac	test-app/image.elf
	[SIGN] test-app/image.bin
Update type:          Firmware
Input image:          test-app/image.bin
Selected cipher:      ecc256
Public key:           ecc256.der
Output image:         test-app/image_v1_signed.bin
Not Encrypted
Calculating sha256 digest...
Signing the firmware...
Done.
Output image successfully created.
	[MERGE] factory.bin
gcc -Wall -DWOLFSSL_DEBUG -DTFM_TIMING_RESISTANT -DWOLFBOOT_SIGN_ECC256 -DWOLFBOOT_HASH_SHA256 -g -ggdb -I../../include -I../../hal -Wextra   -c -o ../../src/libwolfboot.o ../../src/libwolfboot.c
gcc -o ufserver ufserver.o ../../src/libwolfboot.o -Wall -DWOLFSSL_DEBUG -DTFM_TIMING_RESISTANT -DWOLFBOOT_SIGN_ECC256 -DWOLFBOOT_HASH_SHA256 -g -ggdb -I../../include -I../../hal -Wextra
Update type:          Firmware
Input image:          test-app/image.bin
Selected cipher:      ecc256
Public key:           ecc256.der
Output image:         test-app/image_v2_signed.bin
Encrypted using:      /tmp/enc_key.der
Calculating sha256 digest...
Signing the firmware...
Done.
Output image successfully created.
Update type:          Firmware
Input image:          test-app/image.bin
Selected cipher:      ecc256
Public key:           ecc256.der
Output image:         test-app/image_v2_signed.bin
Encrypted using:      /tmp/enc_key.der
Calculating sha256 digest...
Signing the firmware...
Done.
Output image successfully created.
st-flash 1.6.0-32-gcda2215
2020-06-18T08:18:36 INFO common.c: Loading device parameters....
2020-06-18T08:18:36 INFO common.c: Device connected is: WB55 device, id 0x20016495
2020-06-18T08:18:36 INFO common.c: SRAM size: 0x40000 bytes (256 KiB), Flash: 0x100000 bytes (1024 KiB) in pages of 4096 bytes
2020-06-18T08:18:36 INFO common.c: Attempting to write 70028 (0x1118c) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08011000 erased
2020-06-18T08:18:37 INFO common.c: Finished erasing 18 pages of 4096 (0x1000) bytes
Writing
Starting  17 page write
2020-06-18T08:18:46 INFO common.c: Starting verification of write complete
2020-06-18T08:18:47 INFO common.c: Flash written and verified! jolly good!
Warning: the binary file provided does not appear to contain a valid firmware partition file.
[|] Fetching update blocks 			st-flash 1.6.0-32-gcda2215
2020-06-18T08:18:54 INFO common.c: Loading device parameters....
2020-06-18T08:18:54 INFO common.c: Device connected is: WB55 device, id 0x20016495
2020-06-18T08:18:54 INFO common.c: SRAM size: 0x40000 bytes (256 KiB), Flash: 0x100000 bytes (1024 KiB) in pages of 4096 bytes

** TARGET REBOOT **
Version running on target: 1
[/] Fetching update blocks 			st-flash 1.6.0-32-gcda2215
2020-06-18T08:19:54 INFO common.c: Loading device parameters....
2020-06-18T08:19:54 INFO common.c: Device connected is: WB55 device, id 0x20016495
2020-06-18T08:19:54 INFO common.c: SRAM size: 0x40000 bytes (256 KiB), Flash: 0x100000 bytes (1024 KiB) in pages of 4096 bytes

** TARGET REBOOT **
Version running on target: 1
[|] Fetching update blocks 			st-flash 1.6.0-32-gcda2215
2020-06-18T08:19:55 INFO common.c: Loading device parameters....
2020-06-18T08:19:55 INFO common.c: Device connected is: WB55 device, id 0x20016495
2020-06-18T08:19:55 INFO common.c: SRAM size: 0x40000 bytes (256 KiB), Flash: 0x100000 bytes (1024 KiB) in pages of 4096 bytes
1+0 records in
1+0 records out
4096 bytes transferred in 0.000042 secs (97612893 bytes/sec)
Binary files boot.bin and boot_compare.bin differ
TEST FAILED
make: *** [test-enc-update] Error 1

Comment thread tools/uart-flash-server/ufserver.c
@danielinux danielinux marked this pull request as ready for review June 18, 2020 16:45
Copy link
Copy Markdown
Member

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Daniele! Awesome work

@dgarske dgarske merged commit 71792e8 into wolfSSL:master Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants