Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove MigTd prefix in AttestLibError to avoid confusing #195

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/attestation/src/attest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn get_quote(td_report: &[u8]) -> Result<Vec<u8>, Error> {
quote.as_mut_ptr() as *mut c_void,
&mut quote_size as *mut u32,
);
if result != AttestLibError::MigtdAttestSuccess {
if result != AttestLibError::AttestSuccess {
return Err(Error::GetQuote);
}
}
Expand Down Expand Up @@ -68,7 +68,7 @@ pub fn verify_quote(quote: &[u8]) -> Result<Vec<u8>, Error> {
td_report_verify.as_mut_ptr() as *mut c_void,
&mut report_verify_size as *mut u32,
);
if result != AttestLibError::MigtdAttestSuccess {
if result != AttestLibError::AttestSuccess {
return Err(Error::VerifyQuote);
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/attestation/src/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@
#[derive(Debug, PartialEq)]
pub(crate) enum AttestLibError {
/// Success
MigtdAttestSuccess = 0x0000,
AttestSuccess = 0x0000,
/// Unexpected error
MigtdAttestErrorUnexpected = 0x0001,
AttestErrorUnexpected = 0x0001,
/// The parameter is incorrect
MigtdAttestErrorInvalidParameter = 0x0002,
AttestErrorInvalidParameter = 0x0002,
/// Not enough memory is available to complete this operation
MigtdAttestErrorOutOfMemory = 0x0003,
AttestErrorOutOfMemory = 0x0003,
/// vsock related failure
MigtdAttestErrorVsockFailure = 0x0004,
AttestErrorVsockFailure = 0x0004,
/// Failed to get the TD Report
MigtdAttestErrorReportFailure = 0x0005,
AttestErrorReportFailure = 0x0005,
/// Failed to extend rtmr
MigtdAttestErrorExtendFailure = 0x0006,
AttestErrorExtendFailure = 0x0006,
/// Request feature is not supported
MigtdAttestErrorNotSupported = 0x0007,
AttestErrorNotSupported = 0x0007,
/// Failed to get the TD Quote
MigtdAttestErrorQuoteFailure = 0x0008,
AttestErrorQuoteFailure = 0x0008,
/// The device driver return busy
MigtdAttestErrorBusy = 0x0009,
AttestErrorBusy = 0x0009,
/// Failed to acess tdx attest device
MigtdAttestErrorDeviceFailure = 0x000a,
AttestErrorDeviceFailure = 0x000a,
/// Only supported RTMR index is 2 and 3
MigtdAttestErrorInvalidRtmrIndex = 0x000b,
AttestErrorInvalidRtmrIndex = 0x000b,
}

extern "C" {
Expand Down
6 changes: 3 additions & 3 deletions src/attestation/src/ghci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ pub static NOTIFIER: AtomicU8 = AtomicU8::new(0);
#[no_mangle]
pub extern "C" fn migtd_get_quote(tdquote_req_buf: *mut c_void, len: u64) -> i32 {
if tdquote_req_buf == null_mut() || len > GET_QUOTE_MAX_SIZE {
return AttestLibError::MigtdAttestErrorInvalidParameter as i32;
return AttestLibError::AttestErrorInvalidParameter as i32;
}

let input = unsafe { from_raw_parts_mut(tdquote_req_buf as *mut u8, len as usize) };

let mut shared = if let Some(shared) = SharedMemory::new(len as usize / 0x1000) {
shared
} else {
return AttestLibError::MigtdAttestErrorOutOfMemory as i32;
return AttestLibError::AttestErrorOutOfMemory as i32;
};
shared.as_mut_bytes()[..len as usize].copy_from_slice(input);

set_vmm_notification();

if tdvmcall_get_quote(shared.as_mut_bytes()).is_err() {
return AttestLibError::MigtdAttestErrorQuoteFailure as i32;
return AttestLibError::AttestErrorQuoteFailure as i32;
}

wait_for_vmm_notification();
Expand Down
Loading