rust/pvattest: Add check command

Add a new command: check. This allows users to perform policy checks on
the Attestation result.
The host-key hashes, and the user-data can be tested for certain values.

While at it fix some typos and enable CSV parsing for the Additional-data flags.

Example:
```
pvattest check attestresp checkresult -k hkd0.crt,hkd1.crt
--host-key-check AttKeyCheck
```
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
Steffen Eiden
2024-11-18 14:50:15 +01:00
parent ac7f866237
commit 697dcc0f6b
8 changed files with 467 additions and 56 deletions
+13
View File
@@ -139,6 +139,19 @@ impl<'a, T: Serialize + From<&'a [u8]> + Sized> AdditionalData<T> {
unrecognized: unrecognized.map(|i| i.into()),
}
}
/// Create from a slice of additional-data
///
/// `data`: Unstructured additional-data
/// `flags`: Flags indicating which additional-data field is present.
///
/// # Error
///
/// Fails if there is a mismatch between the data and the flags. Should not happen after a
/// successful attestation verification.
pub fn from_slice_sized(data: &'a [u8], flags: &AttestationFlags) -> Result<Self> {
AdditionalData::<&'a [u8]>::from_slice(data, flags).map(Self::from_other)
}
}
impl<'a> AdditionalData<&'a [u8]> {