Let update_len be usize for now
This commit is contained in:
parent
043b3072c4
commit
d8e2f82569
@ -119,13 +119,11 @@ impl FirmwareUpdater {
|
|||||||
_state_and_dfu_flash: &mut F,
|
_state_and_dfu_flash: &mut F,
|
||||||
_public_key: &[u8],
|
_public_key: &[u8],
|
||||||
_signature: &[u8],
|
_signature: &[u8],
|
||||||
_update_len: u32,
|
_update_len: usize,
|
||||||
_aligned: &mut [u8],
|
_aligned: &mut [u8],
|
||||||
) -> Result<(), FirmwareUpdaterError> {
|
) -> Result<(), FirmwareUpdaterError> {
|
||||||
let _read_size = _aligned.len();
|
|
||||||
|
|
||||||
assert_eq!(_aligned.len(), F::WRITE_SIZE);
|
assert_eq!(_aligned.len(), F::WRITE_SIZE);
|
||||||
assert!(_update_len <= self.dfu.len() as u32);
|
assert!(_update_len <= self.dfu.len());
|
||||||
|
|
||||||
#[cfg(feature = "ed25519-dalek")]
|
#[cfg(feature = "ed25519-dalek")]
|
||||||
{
|
{
|
||||||
@ -182,10 +180,11 @@ impl FirmwareUpdater {
|
|||||||
pub async fn hash<F: AsyncNorFlash, D: Digest>(
|
pub async fn hash<F: AsyncNorFlash, D: Digest>(
|
||||||
&mut self,
|
&mut self,
|
||||||
dfu_flash: &mut F,
|
dfu_flash: &mut F,
|
||||||
update_len: u32,
|
update_len: usize,
|
||||||
chunk_buf: &mut [u8],
|
chunk_buf: &mut [u8],
|
||||||
output: &mut [u8],
|
output: &mut [u8],
|
||||||
) -> Result<(), FirmwareUpdaterError> {
|
) -> Result<(), FirmwareUpdaterError> {
|
||||||
|
let update_len = update_len as u32;
|
||||||
let mut digest = D::new();
|
let mut digest = D::new();
|
||||||
for offset in (0..update_len).step_by(chunk_buf.len()) {
|
for offset in (0..update_len).step_by(chunk_buf.len()) {
|
||||||
self.dfu.read(dfu_flash, offset, chunk_buf).await?;
|
self.dfu.read(dfu_flash, offset, chunk_buf).await?;
|
||||||
@ -341,13 +340,11 @@ impl FirmwareUpdater {
|
|||||||
_state_and_dfu_flash: &mut F,
|
_state_and_dfu_flash: &mut F,
|
||||||
_public_key: &[u8],
|
_public_key: &[u8],
|
||||||
_signature: &[u8],
|
_signature: &[u8],
|
||||||
_update_len: u32,
|
_update_len: usize,
|
||||||
_aligned: &mut [u8],
|
_aligned: &mut [u8],
|
||||||
) -> Result<(), FirmwareUpdaterError> {
|
) -> Result<(), FirmwareUpdaterError> {
|
||||||
let _read_size = _aligned.len();
|
|
||||||
|
|
||||||
assert_eq!(_aligned.len(), F::WRITE_SIZE);
|
assert_eq!(_aligned.len(), F::WRITE_SIZE);
|
||||||
assert!(_update_len <= self.dfu.len() as u32);
|
assert!(_update_len <= self.dfu.len());
|
||||||
|
|
||||||
#[cfg(feature = "ed25519-dalek")]
|
#[cfg(feature = "ed25519-dalek")]
|
||||||
{
|
{
|
||||||
@ -402,10 +399,11 @@ impl FirmwareUpdater {
|
|||||||
pub fn hash_blocking<F: NorFlash, D: Digest>(
|
pub fn hash_blocking<F: NorFlash, D: Digest>(
|
||||||
&mut self,
|
&mut self,
|
||||||
dfu_flash: &mut F,
|
dfu_flash: &mut F,
|
||||||
update_len: u32,
|
update_len: usize,
|
||||||
chunk_buf: &mut [u8],
|
chunk_buf: &mut [u8],
|
||||||
output: &mut [u8],
|
output: &mut [u8],
|
||||||
) -> Result<(), FirmwareUpdaterError> {
|
) -> Result<(), FirmwareUpdaterError> {
|
||||||
|
let update_len = update_len as u32;
|
||||||
let mut digest = D::new();
|
let mut digest = D::new();
|
||||||
for offset in (0..update_len).step_by(chunk_buf.len()) {
|
for offset in (0..update_len).step_by(chunk_buf.len()) {
|
||||||
self.dfu.read_blocking(dfu_flash, offset, chunk_buf)?;
|
self.dfu.read_blocking(dfu_flash, offset, chunk_buf)?;
|
||||||
@ -536,7 +534,7 @@ mod tests {
|
|||||||
block_on(updater.write_firmware(0, to_write.as_slice(), &mut flash)).unwrap();
|
block_on(updater.write_firmware(0, to_write.as_slice(), &mut flash)).unwrap();
|
||||||
let mut chunk_buf = [0; 2];
|
let mut chunk_buf = [0; 2];
|
||||||
let mut hash = [0; 20];
|
let mut hash = [0; 20];
|
||||||
block_on(updater.hash::<_, Sha1>(&mut flash, update.len() as u32, &mut chunk_buf, &mut hash)).unwrap();
|
block_on(updater.hash::<_, Sha1>(&mut flash, update.len(), &mut chunk_buf, &mut hash)).unwrap();
|
||||||
|
|
||||||
assert_eq!(Sha1::digest(update).as_slice(), hash);
|
assert_eq!(Sha1::digest(update).as_slice(), hash);
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ mod tests {
|
|||||||
&mut flash,
|
&mut flash,
|
||||||
&public_key.to_bytes(),
|
&public_key.to_bytes(),
|
||||||
&signature.to_bytes(),
|
&signature.to_bytes(),
|
||||||
firmware_len as u32,
|
firmware_len,
|
||||||
&mut aligned,
|
&mut aligned,
|
||||||
))
|
))
|
||||||
.is_ok());
|
.is_ok());
|
||||||
|
Loading…
Reference in New Issue
Block a user