[vm_payload] Adjust NDK API struct and function names
According to the comments in b/325093658
Bug: 325093658
Test: atest VmAttestationTestApp
Change-Id: I8aadd1553ef72d07e61f5cc0a7880e8fec12fd2f
diff --git a/vm_payload/src/lib.rs b/vm_payload/src/lib.rs
index 6188b21..5cc4431 100644
--- a/vm_payload/src/lib.rs
+++ b/vm_payload/src/lib.rs
@@ -37,7 +37,7 @@
atomic::{AtomicBool, Ordering},
Mutex,
};
-use vm_payload_status_bindgen::attestation_status_t;
+use vm_payload_status_bindgen::AVmAttestationStatus;
/// Maximum size of an ECDSA signature for EC P-256 key is 72 bytes.
const MAX_ECDSA_P256_SIGNATURE_SIZE: usize = 72;
@@ -283,7 +283,7 @@
challenge: *const u8,
challenge_size: usize,
res: &mut *mut AttestationResult,
-) -> attestation_status_t {
+) -> AVmAttestationStatus {
// SAFETY: The caller guarantees that `challenge` is valid for reads and `res` is valid
// for writes.
unsafe {
@@ -310,7 +310,7 @@
challenge: *const u8,
challenge_size: usize,
res: &mut *mut AttestationResult,
-) -> attestation_status_t {
+) -> AVmAttestationStatus {
// SAFETY: The caller guarantees that `challenge` is valid for reads and `res` is valid
// for writes.
unsafe {
@@ -337,11 +337,11 @@
challenge_size: usize,
test_mode: bool,
res: &mut *mut AttestationResult,
-) -> attestation_status_t {
+) -> AVmAttestationStatus {
initialize_logging();
const MAX_CHALLENGE_SIZE: usize = 64;
if challenge_size > MAX_CHALLENGE_SIZE {
- return attestation_status_t::ATTESTATION_ERROR_INVALID_CHALLENGE;
+ return AVmAttestationStatus::ATTESTATION_ERROR_INVALID_CHALLENGE;
}
let challenge = if challenge_size == 0 {
&[]
@@ -354,7 +354,7 @@
match service.requestAttestation(challenge, test_mode) {
Ok(attestation_res) => {
*res = Box::into_raw(Box::new(attestation_res));
- attestation_status_t::ATTESTATION_OK
+ AVmAttestationStatus::ATTESTATION_OK
}
Err(e) => {
error!("Remote attestation failed: {e:?}");
@@ -363,31 +363,29 @@
}
}
-fn binder_status_to_attestation_status(status: binder::Status) -> attestation_status_t {
+fn binder_status_to_attestation_status(status: binder::Status) -> AVmAttestationStatus {
match status.exception_code() {
- ExceptionCode::UNSUPPORTED_OPERATION => attestation_status_t::ATTESTATION_ERROR_UNSUPPORTED,
- _ => attestation_status_t::ATTESTATION_ERROR_ATTESTATION_FAILED,
+ ExceptionCode::UNSUPPORTED_OPERATION => AVmAttestationStatus::ATTESTATION_ERROR_UNSUPPORTED,
+ _ => AVmAttestationStatus::ATTESTATION_ERROR_ATTESTATION_FAILED,
}
}
/// Converts the return value from `AVmPayload_requestAttestation` to a text string
/// representing the error code.
#[no_mangle]
-pub extern "C" fn AVmAttestationResult_resultToString(
- status: attestation_status_t,
-) -> *const c_char {
+pub extern "C" fn AVmAttestationStatus_toString(status: AVmAttestationStatus) -> *const c_char {
let message = match status {
- attestation_status_t::ATTESTATION_OK => {
+ AVmAttestationStatus::ATTESTATION_OK => {
CStr::from_bytes_with_nul(b"The remote attestation completes successfully.\0").unwrap()
}
- attestation_status_t::ATTESTATION_ERROR_INVALID_CHALLENGE => {
+ AVmAttestationStatus::ATTESTATION_ERROR_INVALID_CHALLENGE => {
CStr::from_bytes_with_nul(b"The challenge size is not between 0 and 64.\0").unwrap()
}
- attestation_status_t::ATTESTATION_ERROR_ATTESTATION_FAILED => {
+ AVmAttestationStatus::ATTESTATION_ERROR_ATTESTATION_FAILED => {
CStr::from_bytes_with_nul(b"Failed to attest the VM. Please retry at a later time.\0")
.unwrap()
}
- attestation_status_t::ATTESTATION_ERROR_UNSUPPORTED => CStr::from_bytes_with_nul(
+ AVmAttestationStatus::ATTESTATION_ERROR_UNSUPPORTED => CStr::from_bytes_with_nul(
b"Remote attestation is not supported in the current environment.\0",
)
.unwrap(),