diff --git a/src/tpm2.rs b/src/tpm2.rs index 993f027..ef79bef 100644 --- a/src/tpm2.rs +++ b/src/tpm2.rs @@ -5,7 +5,7 @@ pub use crate::common::{PacketType, PACKET_END_BYTE}; #[derive(PartialEq)] #[non_exhaustive] pub enum Tpm2Error { - InvalidPacket, + PayloadTooLarge, } pub struct Packet<'a> { @@ -23,7 +23,7 @@ impl<'a> Packet<'a> { pub fn with_payload(packet_type: PacketType, payload: &'a [u8]) -> Result { if payload.len() > u16::MAX.into() { - return Err(Tpm2Error::InvalidPacket); + return Err(Tpm2Error::PayloadTooLarge); } Ok(Packet { @@ -63,6 +63,6 @@ mod tests { let payload = [0u8; u16::MAX as usize + 1]; let result = Packet::with_payload(PacketType::Response, &payload); assert!(result.is_err()); - assert!(result.err().unwrap() == Tpm2Error::InvalidPacket); + assert!(result.err().unwrap() == Tpm2Error::PayloadTooLarge); } }