pub struct SecurityPolicy {
pub suite: SecuritySuite,
pub authenticated: bool,
pub encrypted: bool,
pub key_set: KeySet,
}Expand description
What protection an association applies and demands.
Fields§
§suite: SecuritySuiteThe suite in use.
authenticated: boolWhether outgoing APDUs are authenticated.
encrypted: boolWhether outgoing APDUs are encrypted.
key_set: KeySetWhich key set protects an APDU — and, on the receiving side, which one this end will accept.
The security control byte’s broadcast bit is the sender’s claim. Letting it choose the key would hand an attacker that choice, and a broadcast key is shared with a whole fleet: a unicast exchange accepted under one lets any fleet member speak as the head-end, with a tag that verifies. So this states what is demanded, and a frame whose bit disagrees is refused before a key is touched.
Implementations§
Source§impl SecurityPolicy
impl SecurityPolicy
Sourcepub const fn authenticated_encrypted(suite: SecuritySuite) -> Self
pub const fn authenticated_encrypted(suite: SecuritySuite) -> Self
Authenticated and encrypted with the given suite — what a ciphered association normally uses.
Sourcepub const fn global(self) -> Self
pub const fn global(self) -> Self
The same protection on the global unicast key set.
The InitiateRequest and InitiateResponse are always protected this way, even
in an association that will use a dedicated key for everything afterwards: the
dedicated key is delivered inside the ciphered InitiateRequest, so nothing
can be protected with it before that message has been opened. The same holds for
HLS, which runs before the association is open.
Sourcepub const fn with_dedicated(self, dedicated: bool) -> Self
pub const fn with_dedicated(self, dedicated: bool) -> Self
The same protection with the dedicated key set, or back on the unicast one.
Sourcepub const fn with_broadcast(self, broadcast: bool) -> Self
pub const fn with_broadcast(self, broadcast: bool) -> Self
The same protection on the broadcast key set, or back on the unicast one.
For a receiver this says which key set it will accept; see
SecurityPolicy::key_set.
Sourcepub const fn dedicated(self) -> bool
pub const fn dedicated(self) -> bool
True when this association uses the key it negotiated for itself.
Sourcepub const fn control(self) -> SecurityControl
pub const fn control(self) -> SecurityControl
The security control byte this policy produces.
Sourcepub fn check_received(self, control: SecurityControl) -> Result<()>
pub fn check_received(self, control: SecurityControl) -> Result<()>
Check that a received security control byte is at least as strong as this policy demands.
This is the downgrade check. A peer that stops encrypting, or drops to a weaker suite, is refused here rather than quietly accepted — which is the whole point of negotiating a policy in the first place.
§Errors
ErrorKind::UnexpectedMessage when the received protection is weaker, the
suite differs, or the frame names a key set this policy did not ask for;
ErrorKind::Unsupported when compression is claimed.