Skip to content

Commit

Permalink
feat(sgx_types): add manual debug impl for align*
Browse files Browse the repository at this point in the history
  • Loading branch information
longtomjr committed Apr 19, 2021
1 parent 170f238 commit 715d3e7
Showing 1 changed file with 55 additions and 6 deletions.
61 changes: 55 additions & 6 deletions sgx_types/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,6 @@ pub type sgx_mac_256bit_t = [uint8_t; 32];

#[repr(C, align(32))]
#[derive(Copy, Clone, Default)]
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub struct sgx_align_key_128bit_t {
_pad: [uint8_t; 16],
pub key: sgx_key_128bit_t,
Expand All @@ -1497,9 +1496,17 @@ impl PartialEq for sgx_align_key_128bit_t {
#[cfg(feature = "extra_traits")]
impl Eq for sgx_align_key_128bit_t {}

#[cfg(feature = "extra_traits")]
impl core::fmt::Debug for sgx_align_key_128bit_t {
fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
fmt.debug_struct("sgx_align_key_128bit_t")
.field("key", &self.key)
.finish()
}
}

#[repr(C, align(32))]
#[derive(Copy, Clone, Default)]
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub struct sgx_align_mac_128bit_t {
_pad: [uint8_t; 16],
pub mac: sgx_mac_128bit_t,
Expand All @@ -1516,9 +1523,17 @@ impl PartialEq for sgx_align_mac_128bit_t {
#[cfg(feature = "extra_traits")]
impl Eq for sgx_align_mac_128bit_t {}

#[cfg(feature = "extra_traits")]
impl core::fmt::Debug for sgx_align_mac_128bit_t {
fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
fmt.debug_struct("sgx_align_mac_128bit_t")
.field("mac", &self.mac)
.finish()
}
}

#[repr(C, align(64))]
#[derive(Copy, Clone, Default)]
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub struct sgx_align_key_256bit_t {
_pad: [uint8_t; 8],
pub key: sgx_key_256bit_t,
Expand All @@ -1535,9 +1550,18 @@ impl PartialEq for sgx_align_key_256bit_t {
#[cfg(feature = "extra_traits")]
impl Eq for sgx_align_key_256bit_t {}

#[cfg(feature = "extra_traits")]
impl core::fmt::Debug for sgx_align_key_256bit_t {
fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
fmt.debug_struct("sgx_align_key_256bit_t")
.field("key", &self.key)
.finish()
}
}


#[repr(C, align(64))]
#[derive(Copy, Clone, Default)]
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub struct sgx_align_mac_256bit_t {
_pad: [uint8_t; 8],
pub mac: sgx_mac_256bit_t,
Expand All @@ -1554,9 +1578,17 @@ impl PartialEq for sgx_align_mac_256bit_t {
#[cfg(feature = "extra_traits")]
impl Eq for sgx_align_mac_256bit_t {}

#[cfg(feature = "extra_traits")]
impl core::fmt::Debug for sgx_align_mac_256bit_t {
fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
fmt.debug_struct("sgx_align_mac_256bit_t")
.field("mac", &self.mac)
.finish()
}
}

#[repr(C, align(64))]
#[derive(Copy, Clone, Default)]
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub struct sgx_align_ec256_dh_shared_t {
_pad: [uint8_t; 8],
pub key: sgx_ec256_dh_shared_t,
Expand All @@ -1573,9 +1605,17 @@ impl PartialEq for sgx_align_ec256_dh_shared_t {
#[cfg(feature = "extra_traits")]
impl Eq for sgx_align_ec256_dh_shared_t {}

#[cfg(feature = "extra_traits")]
impl core::fmt::Debug for sgx_align_ec256_dh_shared_t {
fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
fmt.debug_struct("sgx_align_ec256_dh_shared_t")
.field("key", &self.key)
.finish()
}
}

#[repr(C, align(64))]
#[derive(Copy, Clone, Default)]
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub struct sgx_align_ec256_private_t {
_pad: [uint8_t; 8],
pub key: sgx_ec256_private_t,
Expand All @@ -1592,6 +1632,15 @@ impl PartialEq for sgx_align_ec256_private_t {
#[cfg(feature = "extra_traits")]
impl Eq for sgx_align_ec256_private_t {}

#[cfg(feature = "extra_traits")]
impl core::fmt::Debug for sgx_align_ec256_private_t {
fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
fmt.debug_struct("sgx_align_ec256_private_t")
.field("key", &self.key)
.finish()
}
}

unsafe impl ContiguousMemory for sgx_align_key_128bit_t {}
unsafe impl ContiguousMemory for sgx_align_mac_128bit_t {}
unsafe impl ContiguousMemory for sgx_align_key_256bit_t {}
Expand Down

0 comments on commit 715d3e7

Please sign in to comment.