Skip to content

Commit

Permalink
Handle error
Browse files Browse the repository at this point in the history
  • Loading branch information
labbott committed Aug 5, 2024
1 parent a2b03be commit d17483a
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions attest-data/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use crate::{SHA3_256_DIGEST_SIZE, NONCE_SIZE};
use hubpack::SerializedSize;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use crate::Ed25519Signature;
use crate::{NONCE_SIZE, SHA3_256_DIGEST_SIZE};
use hubpack::error::Error as HubpackError;
use hubpack::SerializedSize;
use serde::{de::DeserializeOwned, Deserialize, Serialize};

/// Magic value for [`Header::magic`]
pub const ATTEST_MAGIC: u32 = 0xA77E5700;
Expand All @@ -16,9 +16,7 @@ pub const ATTEST_MAGIC: u32 = 0xA77E5700;
/// add a static assertion.
pub const MAX_DATA_LEN: usize = NONCE_SIZE;

static_assertions::const_assert!(
SHA3_256_DIGEST_SIZE == NONCE_SIZE
);
static_assertions::const_assert!(SHA3_256_DIGEST_SIZE == NONCE_SIZE);

pub const MAX_REQUEST_SIZE: usize =
HostRotHeader::MAX_SIZE + HostToRotCommand::MAX_SIZE + MAX_DATA_LEN;
Expand Down Expand Up @@ -231,8 +229,13 @@ pub fn parse_response(
return Err(HostToRotError::VersionMismatch);
}

if command != expected {
return Err(HostToRotError::UnexpectedCommand);
match command {
RotToHost::HostToRotError(e) => return Err(e),
c => {
if c != expected {
return Err(HostToRotError::UnexpectedCommand);
}
}
}
Ok(leftover)
}
Expand Down Expand Up @@ -301,8 +304,6 @@ where
raw_serialize(out, &header, command, |buf| Ok(fill_data(buf)))
}



#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit d17483a

Please sign in to comment.