Fake enough of SGX attestation to make tests pass
The SEV attestation test is currently failing because the SGX
attestation returns ENOSYS. But in the NULL case we can return the
technology, which is enough to make the SEV test happy it should skip
this architecture.
// SPDX-License-Identifier: Apache-2.0
-use sallyport::syscall::{BaseSyscallHandler, EnarxSyscallHandler};
-use sallyport::untrusted::{UntrustedRef, UntrustedRefMut};
+use sallyport::syscall::{BaseSyscallHandler, EnarxSyscallHandler, SGX_QUOTE_SIZE, SGX_TECH};
+use sallyport::untrusted::{UntrustedRef, UntrustedRefMut, ValidateSlice};
+use sallyport::Reply;
impl<'a> EnarxSyscallHandler for super::Handler<'a> {
// NOTE: The 'nonce' field is called 'hash' here, as it is used to pass in
@@ -9,13 +10,19 @@ impl<'a> EnarxSyscallHandler for super::Handler<'a> {
// For more on this syscall, see: https://github.com/enarx/enarx/issues/966
fn get_attestation(
&mut self,
- _hash: UntrustedRef<u8>,
- _hash_len: libc::size_t,
+ hash: UntrustedRef<u8>,
+ hash_len: libc::size_t,
_buf: UntrustedRefMut<u8>,
_buf_len: libc::size_t,
) -> sallyport::Result {
self.trace("get_att", 0);
+ return match hash.validate_slice(hash_len, self) {
+ None => Reply::from(Ok([SGX_QUOTE_SIZE.into(), SGX_TECH.into()])),
+ Some(..) => Reply::from(Err(libc::ENOSYS)),
+ }
+ .into();
+
/*
// If hash is NULL ptr, it is a Quote size request; return expected Quote size
// without proxying to host. Otherwise get hash value.
@@ -109,8 +116,5 @@ impl<'a> EnarxSyscallHandler for super::Handler<'a> {
.or(Err(libc::EFAULT))?;
}
*/
-
- let rep: sallyport::Reply = Err(libc::ENOSYS).into();
- sallyport::Result::from(rep)
}
}
