Skip to content

Commit

Permalink
Add some getters to ChallengeResponseSession, VeraisonApiEndpoint
Browse files Browse the repository at this point in the history
… and `VeraisonVerificationApi` (#13)

Signed-off-by: Guilhem Bryant <[email protected]>
  • Loading branch information
gbryant-arm authored Nov 2, 2023
1 parent fc54c19 commit e34784d
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions c-wrapper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ pub struct ChallengeResponseSession {
session_wrapper: *mut c_void,
}

impl ChallengeResponseSession {
pub fn get_attestation_result(&self) -> *const libc::c_char {
self.attestation_result
}

pub fn get_nonce(&self) -> *const u8 {
self.nonce
}

pub fn get_nonce_size(&self) -> libc::size_t {
self.nonce_size
}
}

/// C-compatible enum representation of the error enum from the Rust client.
#[repr(C)]
#[derive(Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -125,6 +139,16 @@ pub struct VeraisonApiEndpoint {
path: *const libc::c_char,
}

impl VeraisonApiEndpoint {
pub fn get_name(&self) -> *const libc::c_char {
self.name
}

pub fn get_path(&self) -> *const libc::c_char {
self.path
}
}

/// This structure describes the characteristics of the Veraison verification API.
///
/// An instance of this structure can be obtained from the [`veraison_get_verification_api`] function,
Expand Down Expand Up @@ -183,6 +207,24 @@ pub struct VeraisonVerificationApi {
verification_api_wrapper: *mut c_void,
}

impl VeraisonVerificationApi {
pub fn get_algorithm(&self) -> *const libc::c_char {
self.algorithm
}

pub fn get_endpoint_count(&self) -> libc::size_t {
self.endpoint_count
}

pub fn get_endpoint_list(&self) -> *const VeraisonApiEndpoint {
self.endpoint_list
}

pub fn get_public_key_pem(&self) -> *const libc::c_char {
self.public_key_pem
}
}

/// This structure contains the Rust-managed objects that are behind the raw pointers sent back to C
/// world. This structure is not visible to C other than as an opaque (void*) pointer. Think of it as
/// being like the private part of a public/private interface.
Expand Down

0 comments on commit e34784d

Please sign in to comment.