-
Notifications
You must be signed in to change notification settings - Fork 8
remove #[derive(Default)] in bitflags data structure #89
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,17 @@ use crate::{common, error::SpdmStatus}; | |
use codec::{Codec, Reader, Writer}; | ||
|
||
bitflags! { | ||
#[derive(Default)] | ||
pub struct SpdmEndSessionRequestAttributes: u8 { | ||
const PRESERVE_NEGOTIATED_STATE = 0b00000001; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0 should be supported. |
||
} | ||
} | ||
|
||
impl Default for SpdmEndSessionRequestAttributes { | ||
fn default() -> Self { | ||
Self::PRESERVE_NEGOTIATED_STATE | ||
} | ||
} | ||
|
||
impl Codec for SpdmEndSessionRequestAttributes { | ||
fn encode(&self, bytes: &mut Writer) -> Result<usize, codec::EncodeErr> { | ||
self.bits().encode(bytes) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,17 @@ use crate::protocol::{ | |
use codec::{Codec, Reader, Writer}; | ||
|
||
bitflags! { | ||
#[derive(Default)] | ||
pub struct SpdmFinishRequestAttributes: u8 { | ||
const SIGNATURE_INCLUDED = 0b00000001; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0 should be supported |
||
} | ||
} | ||
|
||
impl Default for SpdmFinishRequestAttributes { | ||
fn default() -> Self { | ||
Self::SIGNATURE_INCLUDED | ||
} | ||
} | ||
|
||
impl Codec for SpdmFinishRequestAttributes { | ||
fn encode(&self, bytes: &mut Writer) -> Result<usize, codec::EncodeErr> { | ||
self.bits().encode(bytes) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,13 +18,18 @@ pub const MEASUREMENT_RESPONDER_PARAM2_SLOT_ID_MASK: u8 = 0b0000_1111; | |
pub const MEASUREMENT_RESPONDER_PARAM2_CONTENT_CHANGED_MASK: u8 = 0b0011_0000; | ||
|
||
bitflags! { | ||
#[derive(Default)] | ||
pub struct SpdmMeasurementAttributes: u8 { | ||
const SIGNATURE_REQUESTED = 0b00000001; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0 should be supported. |
||
const RAW_BIT_STREAM_REQUESTED = 0b0000_0010; | ||
} | ||
} | ||
|
||
impl Default for SpdmMeasurementAttributes { | ||
fn default() -> Self { | ||
Self::SIGNATURE_REQUESTED | ||
} | ||
} | ||
|
||
impl Codec for SpdmMeasurementAttributes { | ||
fn encode(&self, bytes: &mut Writer) -> Result<usize, codec::EncodeErr> { | ||
self.bits().encode(bytes) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,13 +54,18 @@ pub const SPDM_MAX_AEAD_IV_SIZE: usize = 12; | |
pub const SPDM_MAX_HKDF_OKM_SIZE: usize = SPDM_MAX_HASH_SIZE; | ||
|
||
bitflags! { | ||
#[derive(Default)] | ||
pub struct SpdmMeasurementSpecification: u8 { | ||
const DMTF = 0b0000_0001; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0 is supported. |
||
const VALID_MASK = Self::DMTF.bits; | ||
} | ||
} | ||
|
||
impl Default for SpdmMeasurementSpecification { | ||
fn default() -> Self { | ||
Self::DMTF | ||
} | ||
} | ||
|
||
impl Codec for SpdmMeasurementSpecification { | ||
fn encode(&self, bytes: &mut Writer) -> Result<usize, codec::EncodeErr> { | ||
self.bits().encode(bytes) | ||
|
@@ -103,7 +108,6 @@ impl SpdmMeasurementSpecification { | |
} | ||
|
||
bitflags! { | ||
#[derive(Default)] | ||
pub struct SpdmMeasurementHashAlgo: u32 { | ||
const RAW_BIT_STREAM = 0b0000_0001; | ||
const TPM_ALG_SHA_256 = 0b0000_0010; | ||
|
@@ -124,6 +128,12 @@ bitflags! { | |
} | ||
} | ||
|
||
impl Default for SpdmMeasurementHashAlgo { | ||
fn default() -> Self { | ||
Self::TPM_ALG_SHA_384 | ||
} | ||
} | ||
|
||
impl SpdmMeasurementHashAlgo { | ||
pub fn get_size(&self) -> u16 { | ||
match *self { | ||
|
@@ -168,7 +178,6 @@ impl Codec for SpdmMeasurementHashAlgo { | |
} | ||
|
||
bitflags! { | ||
#[derive(Default)] | ||
pub struct SpdmBaseAsymAlgo: u32 { | ||
const TPM_ALG_RSASSA_2048 = 0b0000_0001; | ||
const TPM_ALG_RSAPSS_2048 = 0b0000_0010; | ||
|
@@ -189,6 +198,12 @@ bitflags! { | |
} | ||
} | ||
|
||
impl Default for SpdmBaseAsymAlgo { | ||
fn default() -> Self { | ||
Self::TPM_ALG_ECDSA_ECC_NIST_P384 | ||
} | ||
} | ||
|
||
impl SpdmBaseAsymAlgo { | ||
pub fn prioritize(&mut self, peer: SpdmBaseAsymAlgo) { | ||
let prio_table = [ | ||
|
@@ -255,7 +270,6 @@ impl Codec for SpdmBaseAsymAlgo { | |
} | ||
|
||
bitflags! { | ||
#[derive(Default)] | ||
pub struct SpdmBaseHashAlgo: u32 { | ||
const TPM_ALG_SHA_256 = 0b0000_0001; | ||
const TPM_ALG_SHA_384 = 0b0000_0010; | ||
|
@@ -266,6 +280,12 @@ bitflags! { | |
} | ||
} | ||
|
||
impl Default for SpdmBaseHashAlgo { | ||
fn default() -> Self { | ||
Self::TPM_ALG_SHA_256 | ||
} | ||
} | ||
|
||
impl SpdmBaseHashAlgo { | ||
pub fn prioritize(&mut self, peer: SpdmBaseHashAlgo) { | ||
let prio_table = [ | ||
|
@@ -338,7 +358,6 @@ enum_builder! { | |
} | ||
|
||
bitflags! { | ||
#[derive(Default)] | ||
pub struct SpdmDheAlgo: u16 { | ||
const SECP_256_R1 = 0b0000_1000; | ||
const SECP_384_R1 = 0b0001_0000; | ||
|
@@ -347,6 +366,12 @@ bitflags! { | |
} | ||
} | ||
|
||
impl Default for SpdmDheAlgo { | ||
fn default() -> Self { | ||
Self::SECP_384_R1 | ||
} | ||
} | ||
|
||
impl SpdmDheAlgo { | ||
pub fn prioritize(&mut self, peer: SpdmDheAlgo) { | ||
let prio_table = [SpdmDheAlgo::SECP_384_R1, SpdmDheAlgo::SECP_256_R1]; | ||
|
@@ -398,7 +423,6 @@ impl Codec for SpdmDheAlgo { | |
} | ||
|
||
bitflags! { | ||
#[derive(Default)] | ||
pub struct SpdmAeadAlgo: u16 { | ||
const AES_128_GCM = 0b0000_0001; | ||
const AES_256_GCM = 0b0000_0010; | ||
|
@@ -409,6 +433,12 @@ bitflags! { | |
} | ||
} | ||
|
||
impl Default for SpdmAeadAlgo { | ||
fn default() -> Self { | ||
Self::AES_256_GCM | ||
} | ||
} | ||
|
||
impl SpdmAeadAlgo { | ||
pub fn prioritize(&mut self, peer: SpdmAeadAlgo) { | ||
let prio_table = [ | ||
|
@@ -485,7 +515,6 @@ impl Codec for SpdmAeadAlgo { | |
} | ||
|
||
bitflags! { | ||
#[derive(Default)] | ||
pub struct SpdmReqAsymAlgo: u16 { | ||
const TPM_ALG_RSASSA_2048 = 0b0000_0001; | ||
const TPM_ALG_RSAPSS_2048 = 0b0000_0010; | ||
|
@@ -506,6 +535,12 @@ bitflags! { | |
} | ||
} | ||
|
||
impl Default for SpdmReqAsymAlgo { | ||
fn default() -> Self { | ||
Self::TPM_ALG_ECDSA_ECC_NIST_P384 | ||
} | ||
} | ||
|
||
impl SpdmReqAsymAlgo { | ||
pub fn prioritize(&mut self, peer: SpdmReqAsymAlgo) { | ||
let prio_table = [ | ||
|
@@ -572,13 +607,18 @@ impl Codec for SpdmReqAsymAlgo { | |
} | ||
|
||
bitflags! { | ||
#[derive(Default)] | ||
pub struct SpdmKeyScheduleAlgo: u16 { | ||
const SPDM_KEY_SCHEDULE = 0b0000_0001; | ||
const VALID_MASK = Self::SPDM_KEY_SCHEDULE.bits; | ||
} | ||
} | ||
|
||
impl Default for SpdmKeyScheduleAlgo { | ||
fn default() -> Self { | ||
Self::SPDM_KEY_SCHEDULE | ||
} | ||
} | ||
|
||
impl SpdmKeyScheduleAlgo { | ||
pub fn prioritize(&mut self, peer: SpdmKeyScheduleAlgo) { | ||
let prio_table = [SpdmKeyScheduleAlgo::SPDM_KEY_SCHEDULE]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
use codec::{Codec, Reader, Writer}; | ||
|
||
bitflags! { | ||
#[derive(Default)] | ||
pub struct SpdmRequestCapabilityFlags: u32 { | ||
const CERT_CAP = 0b0000_0010; | ||
const CHAL_CAP = 0b0000_0100; | ||
|
@@ -38,6 +37,12 @@ bitflags! { | |
} | ||
} | ||
|
||
impl Default for SpdmRequestCapabilityFlags { | ||
fn default() -> Self { | ||
Self::VALID_MASK | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont think MASK should be default. |
||
} | ||
} | ||
|
||
impl Codec for SpdmRequestCapabilityFlags { | ||
fn encode(&self, bytes: &mut Writer) -> Result<usize, codec::EncodeErr> { | ||
self.bits().encode(bytes) | ||
|
@@ -51,7 +56,6 @@ impl Codec for SpdmRequestCapabilityFlags { | |
} | ||
|
||
bitflags! { | ||
#[derive(Default)] | ||
pub struct SpdmResponseCapabilityFlags: u32 { | ||
const CACHE_CAP = 0b0000_0001; | ||
const CERT_CAP = 0b0000_0010; | ||
|
@@ -100,6 +104,12 @@ bitflags! { | |
} | ||
} | ||
|
||
impl Default for SpdmResponseCapabilityFlags { | ||
fn default() -> Self { | ||
Self::VALID_MASK | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont think MASK should be default. |
||
} | ||
} | ||
|
||
impl Codec for SpdmResponseCapabilityFlags { | ||
fn encode(&self, bytes: &mut Writer) -> Result<usize, codec::EncodeErr> { | ||
self.bits().encode(bytes) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be 1.