pub struct KeyBlockHeader { /* private fields */ }Expand description
Represents a TR-31 key block header.
Implementations§
Source§impl KeyBlockHeader
impl KeyBlockHeader
Sourcepub fn new_with_values(
version_id: &str,
key_usage: &str,
algorithm: &str,
mode_of_use: &str,
key_version_number: &str,
exportability: &str,
) -> Result<Self, KeyBlockHeaderError>
pub fn new_with_values( version_id: &str, key_usage: &str, algorithm: &str, mode_of_use: &str, key_version_number: &str, exportability: &str, ) -> Result<Self, KeyBlockHeaderError>
Create a new key block header from individual header values.
Sourcepub fn new_from_str(header_str: &str) -> Result<Self, KeyBlockHeaderError>
pub fn new_from_str(header_str: &str) -> Result<Self, KeyBlockHeaderError>
Parse a key block header from its string representation.
The input may contain additional key block data after the header. Optional blocks are parsed according to the number declared in the fixed header.
Sourcepub fn export_str(&self) -> Result<String, KeyBlockHeaderError>
pub fn export_str(&self) -> Result<String, KeyBlockHeaderError>
Export the key block header to its ASCII representation.
Sourcepub fn set_version_id(&mut self, value: &str) -> Result<(), KeyBlockHeaderError>
pub fn set_version_id(&mut self, value: &str) -> Result<(), KeyBlockHeaderError>
Set the key block version identifier.
Sourcepub fn version_id(&self) -> &str
pub fn version_id(&self) -> &str
Return the key block version identifier.
Sourcepub fn set_kb_length(&mut self, value: u16) -> Result<(), KeyBlockHeaderError>
pub fn set_kb_length(&mut self, value: u16) -> Result<(), KeyBlockHeaderError>
Set the complete key block length.
Sourcepub fn set_key_usage(&mut self, value: &str) -> Result<(), KeyBlockHeaderError>
pub fn set_key_usage(&mut self, value: &str) -> Result<(), KeyBlockHeaderError>
Set the key usage.
Sourcepub fn set_algorithm(&mut self, value: &str) -> Result<(), KeyBlockHeaderError>
pub fn set_algorithm(&mut self, value: &str) -> Result<(), KeyBlockHeaderError>
Set the protected-key algorithm.
Sourcepub fn set_mode_of_use(
&mut self,
value: &str,
) -> Result<(), KeyBlockHeaderError>
pub fn set_mode_of_use( &mut self, value: &str, ) -> Result<(), KeyBlockHeaderError>
Set the key mode of use.
Sourcepub fn mode_of_use(&self) -> &str
pub fn mode_of_use(&self) -> &str
Return the key mode of use.
Sourcepub fn set_key_version_number(
&mut self,
value: &str,
) -> Result<(), KeyBlockHeaderError>
pub fn set_key_version_number( &mut self, value: &str, ) -> Result<(), KeyBlockHeaderError>
Set the key version number.
Sourcepub fn key_version_number(&self) -> &str
pub fn key_version_number(&self) -> &str
Return the key version number.
Sourcepub fn set_exportability(
&mut self,
value: &str,
) -> Result<(), KeyBlockHeaderError>
pub fn set_exportability( &mut self, value: &str, ) -> Result<(), KeyBlockHeaderError>
Set the exportability attribute.
Sourcepub fn exportability(&self) -> &str
pub fn exportability(&self) -> &str
Return the exportability attribute.
Sourcepub fn set_num_optional_blocks(
&mut self,
value: u8,
) -> Result<(), KeyBlockHeaderError>
pub fn set_num_optional_blocks( &mut self, value: u8, ) -> Result<(), KeyBlockHeaderError>
Set the number of optional blocks declared in the header.
Sourcepub fn num_optional_blocks(&self) -> u8
pub fn num_optional_blocks(&self) -> u8
Return the number of optional blocks declared in the header.
Sourcepub fn set_reserved_field(
&mut self,
value: &str,
) -> Result<(), KeyBlockHeaderError>
pub fn set_reserved_field( &mut self, value: &str, ) -> Result<(), KeyBlockHeaderError>
Set the TR-31 reserved header field.
Sourcepub fn reserved_field(&self) -> &str
pub fn reserved_field(&self) -> &str
Return the reserved header field.
Sourcepub fn set_opt_blocks(&mut self, opt_blocks: Option<Box<OptBlock>>)
pub fn set_opt_blocks(&mut self, opt_blocks: Option<Box<OptBlock>>)
Replace the linked optional blocks and update their count.
Sourcepub fn append_opt_blocks(&mut self, opt_block_to_append: OptBlock)
pub fn append_opt_blocks(&mut self, opt_block_to_append: OptBlock)
Append one or more optional blocks to the existing optional-block chain.
Sourcepub fn opt_blocks(&self) -> &Option<Box<OptBlock>>
pub fn opt_blocks(&self) -> &Option<Box<OptBlock>>
Return the optional-block chain.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Return the complete encoded header length, including optional blocks.
Sourcepub fn finalize(&mut self) -> Result<(), KeyBlockHeaderError>
pub fn finalize(&mut self) -> Result<(), KeyBlockHeaderError>
Finalize the header by padding optional blocks to the cipher block boundary when required.