pub struct SecuritySetup {
version: u8,
logical_name: ObisCode,
security_policy: u8,
security_suite: u8,
client_system_title: Vec<u8>,
server_system_title: Vec<u8>,
certificates: Vec<Certificate>,
keys: BTreeMap<u8, Vec<u8>>,
}Expand description
Security setup interface class (class_id = 64) per IEC 62056-6-2 §4.4.7.
Holds the security policy, suite, system titles and certificates, and manages
the server’s symmetric keys.
Both versions are supported:
- version 0 — attributes 1..5, methods
security_activateandglobal_key_transfer; - version 1 — attributes 1..6 (adds
certificates), methods 1..8.
Only the mechanisms required by security suite 0 (AES-GCM-128) are
implemented: security_activate and the key transfer method. The PKI/ECDH
methods (key_agreement, generate_key_pair, certificate handling) belong
to suites 1 and 2 and return an unsupported error here.
Fields§
§version: u8§logical_name: ObisCode§security_policy: u8§security_suite: u8§client_system_title: Vec<u8>§server_system_title: Vec<u8>§certificates: Vec<Certificate>§keys: BTreeMap<u8, Vec<u8>>Installed symmetric keys, indexed by key_id. Transient security
material, not exposed as a COSEM attribute.
Implementations§
Source§impl SecuritySetup
impl SecuritySetup
Sourcepub fn new(config: SecuritySetupConfig) -> Self
pub fn new(config: SecuritySetupConfig) -> Self
Builds a new SecuritySetup from its configuration.
Sourcepub fn key(&self, key_id: u8) -> Option<&Vec<u8>>
pub fn key(&self, key_id: u8) -> Option<&Vec<u8>>
Returns the installed key for key_id, if any.
Sourcefn security_activate(
&mut self,
data: &CosemDataType,
) -> Result<CosemDataType, String>
fn security_activate( &mut self, data: &CosemDataType, ) -> Result<CosemDataType, String>
Method 1: security_activate — activates and strengthens the security
policy (IEC 62056-6-2 §4.4.7.3.1). Strengthening is one-way: a value
weaker than the current policy is rejected.
Sourcefn key_transfer(&mut self, data: CosemDataType) -> Result<CosemDataType, String>
fn key_transfer(&mut self, data: CosemDataType) -> Result<CosemDataType, String>
Method 2: key_transfer — installs one or more symmetric keys
(IEC 62056-6-2 §4.4.7.3.2). The parameter is an array of
key_transfer_data ::= structure { key_id: enum, key_wrapped: octet-string }.
The keys are stored as received. Unwrapping (AES key unwrap with the KEK) is not performed here, since the master key management belongs to the ciphering layer, which is out of scope for this data-model class.
Trait Implementations§
Source§impl Clone for SecuritySetup
impl Clone for SecuritySetup
Source§fn clone(&self) -> SecuritySetup
fn clone(&self) -> SecuritySetup
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SecuritySetup
impl Debug for SecuritySetup
Source§impl<'de> Deserialize<'de> for SecuritySetup
impl<'de> Deserialize<'de> for SecuritySetup
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl InterfaceClass for SecuritySetup
impl InterfaceClass for SecuritySetup
Source§fn logical_name(&self) -> &ObisCode
fn logical_name(&self) -> &ObisCode
Source§fn attributes(&self) -> Vec<(u8, CosemDataType)>
fn attributes(&self) -> Vec<(u8, CosemDataType)>
(attribute_id, value) pairs.