Commit Graph

122 Commits (a0e61f3a58d3be5f6701c320ea9d66ba91c35145)

Author SHA1 Message Date
David Garske a37a816693
Merge pull request #433 from danielinux/gpl3
Update license GPL2 -> GPL3
2024-04-16 10:36:10 -07:00
Daniele Lacamera 32b5b9e4ec Replaced uint32_t with uintptr_t 2024-04-16 19:10:26 +02:00
Daniele Lacamera d8c651c091 Added explicit cast to silence warning
Explicit cast to silence warning about negative array index
2024-04-16 18:50:39 +02:00
Daniele Lacamera fce6149cf8 Update license GPL2 -> GPL3 2024-04-16 16:46:15 +02:00
David Garske 83283c6cf7 Fixes for NXP T1024 and booting Integrity OS:
* Fixed PPC spin table based on ePAPR 1.1.
* Added flattened device tree (FDT) support. Setting required FDT fields per ePAPR 1.1.
* Added Frame Manager microcode upload.
* Fixed CPLD and setting QE clock.
* Added support for setting logical device numbers and updated device tree.
* Fixed QUICC Engine base address (was incorrect, should be 0x140000).
* Fixed "cpu-release-addr" to use 64-bit value.
* Added secondary cached boot page.
* Added L2 cache support to multi-core.
* Added flattened device tree parser tool for testing (`make fdt-parser` and `tools/fdt-parser/fdt-parser`).
* Added checks for FDT header.
* Added automated test case for NXP T1024 FDT.
2024-01-17 14:16:15 +01:00
Daniele Lacamera 10b2b290d3 wolfBoot_get_blob_type: fix return type 2023-11-16 09:21:56 +01:00
Daniele Lacamera 90ecd9f5d5 Decryption with delta updates: align to encryption block 2023-11-04 18:53:08 +01:00
Daniele Lacamera da43c99993 Added more unit tests. Added 'make cov'.
Fixed checks for invalid partition id
2023-10-13 14:30:45 +02:00
John Bland 6c2a37bdea remove complicated key saving process and instead
leave the encryption key for wolfBoot_success to erase.
FINAL_SWAP was also stopping the case where the partition was put into testing before the update sector status flags could be erased. now, don't erase the update sector flags. instead put the update partition in IMG_STATE_FINAL_FLAGS state before putting the boot partition in IMG_STATE_TESTING. Then only erase the update sector flags on wolfBoot_update_trigger. under this scheme, the sector flags are intact if the power failed before we could set IMG_STATE_TESTING but are wiped if we do need to swap over after after wolfBoot_success fails to be called
2023-10-13 14:30:04 +02:00
John Bland 87761e84e4 make aes_init and chacha_init read the backup key 2023-10-13 14:30:04 +02:00
John Bland 00a9572b94 change the final steps of wolfBoot_update into
repeatable steps so that power failure wont erase the encryption key and wont cause skipping the testing phase of boot. this is done by marking the update partition as final swap when erasing the final sector and backing up the key in boot sector 0 after swaping the real boot sector 0 to swap. then when a power failure occurs the encryption key will be available in either boot sector 0 or the normal location. the intermediate phase also prevents skipping the testing phase since the last sector, which holds the boot state, is erased and then set repeatably, since the final swap state is set on the update partition
2023-10-13 14:30:04 +02:00
David Garske 389e12faf1 Fixes to get TPM working with T1024 and MMU enabled. 2023-10-06 15:28:16 +02:00
Daniele Lacamera 66109b9f11 Delta updates: 32-bit fields for patch size 2023-09-01 13:36:21 +02:00
David Garske ee628f1078
Merge pull request #351 from jpbland1/bad-last-sector-address-fix
handle case where PART_UPDATE_ENDFLAGS % WOLFBOOT_SECTOR_SIZE == 0
2023-08-22 09:31:08 -07:00
John Bland ed68b4688b gate wolfBoot_update_trigger address offset on FLAGS_HOME 2023-08-22 12:08:27 -04:00
Tesfa Mael a29b78d680 Add function headers 2023-08-22 07:18:15 +02:00
John Bland e58126097d switch to runtime check 2023-08-21 17:20:20 -04:00
John Bland 5e9b2a253d handle case where PART_UPDATE_ENDFLAGS % WOLFBOOT_SECTOR_SIZE == 0 2023-08-21 17:06:02 -04:00
John Bland 131df548e6 Merge branch 'master' into nvm-encrypt-configs 2023-08-21 10:13:46 -04:00
David Garske b33da11d7d Improve the array-bounds logic for the NVM write once. Tell GCC 12 its okay. 2023-08-21 11:08:48 +02:00
John Bland 4a9973ce06 fix powerfail problems with NVM_FLASH_WRITEONCE combinations
simplify the erase address logic within nvm_select_fresh_sector
add several checks to nvm_select_fresh_sector:
    when FLAGS_HOME is enabled, add a check for both the boot and update partition flags
    when EXT_ENCRYPTED is enabled, add a check for the encryption key, always perform this check when FLAGS_HOME is enabled
update aes_init and chacha_init to properly account for NVM_FLASH_WRITEONCE
2023-08-21 01:30:49 -04:00
John Bland d63316fd7f erase the sector flags when wolfBoot_update_trigger
is called for NVM_FLASH_WRITEONCE and WOLFBOOT_FLAGS_INVERT since NVM_FLASH_WRITEONCE relies on finding non-erased flags to determine which sector is fresh and since WOLFBOOT_FLAGS_INVERT may use a different fill byte than what bin-assemble was compiled with
2023-08-17 01:22:47 -04:00
John Bland cbccccb3fa remove the FLAGS_HOME section since it will erase
the encryption key
2023-08-15 17:30:38 -04:00
David Garske 98cbde707a
Merge pull request #339 from jpbland1/address-fix
fix bad address copy if base is not the same as addr_read
2023-08-15 10:19:53 -07:00
John Bland d08ed5c473 only call nvm_select_fresh_sector on internal partitions 2023-08-15 11:57:22 -04:00
John Bland 171d19b6ee fix bad address copy if base is not the same as addr_read 2023-08-15 02:34:05 -04:00
David Garske 7190392245 Simulator fixes and support for using MacOS:
* Added simulator support for Mac.
* Fix for simulator to properly assemble wolfboot.bin + signedtestapp + update + swap.
* Fixes for handling 64-bit assigned mmap virtual addresses. Added hal_flash_write and hal_flash_erase support for 64-bit address using uintptr_t. Enabled if platform is 64-bit and `FORCE_32BIT` is not defined
* Fix simulator conflict with src/libwolfboot.o object in test-app.
* Cleanup test-app linker flags.
2023-08-07 20:54:18 +02:00
Marco Oliverio 93b7281d12 x86: support MMU paging on x86 architecture 2023-07-24 18:12:14 +00:00
David Garske db15f9b0f1 Further NXP P1021 fixes and improvements:
* Added ELF32 and ELF64 loader support (config `ELF=1` or build option `WOLFBOOT_ELF`).
* Add ELF support to `update_ram.c` loader.
* Add support for loading entire flash image to RAM when `EXT_FLASH=1` and `NO_XIP=1` (or `WOLFBOOT_USE_RAMBOOT`).
* Added QUICC Engine support to load microcode and enable.
* Add multiple core support for NXP P1021.
* Fixes to resolve first stage boot ROM relocation.
  - Implemented temporary workaround to resolve stack traps.
* Added PPC GOT relocation support.
* Fix for the PPC `isr_empty` handler address.
* Fix to allow stack to use DDR by having assembly setup DDR TLB. After relocating wolfBoot use stack on DDR.
* Cleanup wolfBoot output.
  - Only remove extra .bin/.elf created unless `make distclean` is used.
  - Don't output the key grep test (only check result).
  - Adjust build order (first stage, wolfboot, test app, key, sign test app and factory).
  - Fix to make sure linker script is rebuilt before objects.

Sample NXP P1021 Output:

```
Relocating BOOT ROM to DDR
Loading wolfBoot to DDR
Jumping to full wolfBoot
wolfBoot HAL Init
Flash Init: Ret 0, ID 0x76207620
QE: Length 63732, Count 1
QE: uploading 'Microcode for P1021 r1.0' version 0.0.1
QE: Traps 0
MP: Starting core 2 (spin table 0xFFFFF240)
Versions: Boot 1, Update 0
Trying Boot partition at 0x200000
Loading header 512 bytes to 0x1DFFFE00
Loading image 3170724 bytes to 0x1E000000
Image size 3170724
Firmware Valid
Loading elf at 0x1E000000
Found valid elf32 (big endian)
Booting at 0x6000
```
2023-07-05 17:03:57 +02:00
David Garske a56e2252c1 Revert the TPM based key store (root of trust). This feature is not ready for next release. 2023-07-04 08:36:41 +02:00
Dimitri Papadopoulos be037ca04d Fix typos found by codespell 2023-07-04 07:43:02 +02:00
Hideki Miyazaki 170bb9a585 Support Renesas RA6M4 with SCE use 2023-05-17 14:15:18 +02:00
Daniele Lacamera c897362031 NVM_FLASH_WRITEONCE Fixed wrong partition erase
When using NVM_FLASH_WRITEONCE, before writing to the active trailer sector,
we check that the sector has been previously erased. This check was
erasing the wrong partition trailer, leaving the system without a
trailer for a few lines of code, but potentially vulnerable to
powerfailure events.
2023-05-16 09:33:48 +02:00
David Garske 0b7603f7bf
Merge pull request #303 from jpbland1/preseal
add script for preseal a public key to tpm
2023-05-05 15:02:55 -07:00
John Bland bf3ebee8bb use correct digest when getting unsealing the pubkey
add deinit call when wolfboot exits so the TPM doesn't have a hanging session
2023-05-05 16:27:22 -04:00
David Garske ef35f473c9
Merge pull request #296 from jpbland1/tpm-root-trust
wolfTPM pubkey storage with policy based access restriction
2023-05-04 15:09:06 -07:00
John Bland eb30566bba add encryption key unsealing from the tpm
make the config/examples/stm32f4-tpm-keystore.config config use ecc256
2023-04-24 13:23:09 -04:00
Daniele Lacamera 48496c3568 Fix bug in get_trailer_at() 2023-04-13 19:17:21 +02:00
billphipps 27c079b04c Correct spacing. 2023-03-23 06:04:35 +01:00
billphipps 310efc468c Update to check if the initial bytes are erased, then no update is
present.
2023-03-23 06:04:35 +01:00
Daniele Lacamera 96bf93838f Allow NVM_FLASH_WRITEONCE code to run in 64bit sim 2023-03-21 18:03:38 +01:00
Daniele Lacamera c36819ad0b Run 4 unit tests made out of unit-extflash.c
- clear text test of ext_flash_check r/w/erase
- Aes128
- Aes256
- ChaCha
2023-03-14 08:57:15 +01:00
Daniele Lacamera e9ad9e3080 Fixes to encrypted updates functions
- use correct buffer size for the NONCE
- ext_flash_encrypt_write: do not encrypt when writing to last sector of
  update partition
2023-03-14 08:57:15 +01:00
Daniele Lacamera 0b06efd347 Added unit test for encrypted external flash 2023-03-14 08:57:14 +01:00
Daniele Lacamera b401dae331 Fix NVM_FLASH_WRITEONCE redundancy
Address of non-selected block to erase was shifted by one block
2023-03-13 10:37:48 +01:00
Daniele Lacamera 2f2a6d416d Support encrypted images in MMU targets 2023-03-09 16:31:29 +01:00
Daniele Lacamera d4cd79e678 Fixed cosmetics after code reviews 2023-01-27 08:35:08 +01:00
Daniele Lacamera 42822cd1d8 Fix build error 2023-01-26 18:46:51 +01:00
Daniele Lacamera b48b35a498 Fixed selection of the cached sector before write 2023-01-26 18:31:36 +01:00
Daniele Lacamera 6e61b54a20 Fix compile errors with ENCRYPT=1 2023-01-26 14:32:55 +01:00