diff options
| author | Gerhard de Clercq <[email protected]> | 2025-04-15 20:16:09 +0200 |
|---|---|---|
| committer | Gerhard de Clercq <[email protected]> | 2025-05-23 12:40:19 +0200 |
| commit | 68a45490fc1675f2171131ccbf01f690c4123f01 (patch) | |
| tree | 42606d9fa51bf50e6d7d84623123616600a70cce /embassy-boot | |
| parent | f7405493c184ce453ac3f7ba97f7f2689f978194 (diff) | |
[embassy-usb-dfu] support ed25519 verification
This commit adds the ability to verify that USB DFU updates are correctly signed using ed25519.
This required adding support to embassy-boot for reading from the DFU partition.
Diffstat (limited to 'embassy-boot')
| -rw-r--r-- | embassy-boot/src/firmware_updater/asynch.rs | 11 | ||||
| -rw-r--r-- | embassy-boot/src/firmware_updater/blocking.rs | 11 |
2 files changed, 22 insertions, 0 deletions
diff --git a/embassy-boot/src/firmware_updater/asynch.rs b/embassy-boot/src/firmware_updater/asynch.rs index 0dc09e18d..66e311e38 100644 --- a/embassy-boot/src/firmware_updater/asynch.rs +++ b/embassy-boot/src/firmware_updater/asynch.rs | |||
| @@ -161,6 +161,17 @@ impl<'d, DFU: NorFlash, STATE: NorFlash> FirmwareUpdater<'d, DFU, STATE> { | |||
| 161 | Ok(()) | 161 | Ok(()) |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | /// Read a slice of data from the DFU storage peripheral, starting the read | ||
| 165 | /// operation at the given address offset, and reading `buf.len()` bytes. | ||
| 166 | /// | ||
| 167 | /// # Errors | ||
| 168 | /// | ||
| 169 | /// Returns an error if the arguments are not aligned or out of bounds. | ||
| 170 | pub async fn read_dfu(&mut self, offset: u32, buf: &mut [u8]) -> Result<(), FirmwareUpdaterError> { | ||
| 171 | self.dfu.read(offset, buf).await?; | ||
| 172 | Ok(()) | ||
| 173 | } | ||
| 174 | |||
| 164 | /// Mark to trigger firmware swap on next boot. | 175 | /// Mark to trigger firmware swap on next boot. |
| 165 | #[cfg(not(feature = "_verify"))] | 176 | #[cfg(not(feature = "_verify"))] |
| 166 | pub async fn mark_updated(&mut self) -> Result<(), FirmwareUpdaterError> { | 177 | pub async fn mark_updated(&mut self) -> Result<(), FirmwareUpdaterError> { |
diff --git a/embassy-boot/src/firmware_updater/blocking.rs b/embassy-boot/src/firmware_updater/blocking.rs index 08062b0d0..0fedac1ea 100644 --- a/embassy-boot/src/firmware_updater/blocking.rs +++ b/embassy-boot/src/firmware_updater/blocking.rs | |||
| @@ -196,6 +196,17 @@ impl<'d, DFU: NorFlash, STATE: NorFlash> BlockingFirmwareUpdater<'d, DFU, STATE> | |||
| 196 | Ok(()) | 196 | Ok(()) |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | /// Read a slice of data from the DFU storage peripheral, starting the read | ||
| 200 | /// operation at the given address offset, and reading `buf.len()` bytes. | ||
| 201 | /// | ||
| 202 | /// # Errors | ||
| 203 | /// | ||
| 204 | /// Returns an error if the arguments are not aligned or out of bounds. | ||
| 205 | pub fn read_dfu(&mut self, offset: u32, buf: &mut [u8]) -> Result<(), FirmwareUpdaterError> { | ||
| 206 | self.dfu.read(offset, buf)?; | ||
| 207 | Ok(()) | ||
| 208 | } | ||
| 209 | |||
| 199 | /// Mark to trigger firmware swap on next boot. | 210 | /// Mark to trigger firmware swap on next boot. |
| 200 | #[cfg(not(feature = "_verify"))] | 211 | #[cfg(not(feature = "_verify"))] |
| 201 | pub fn mark_updated(&mut self) -> Result<(), FirmwareUpdaterError> { | 212 | pub fn mark_updated(&mut self) -> Result<(), FirmwareUpdaterError> { |
