Skip to main content

SecurityPolicy

Struct SecurityPolicy 

Source
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: SecuritySuite

The suite in use.

§authenticated: bool

Whether outgoing APDUs are authenticated.

§encrypted: bool

Whether outgoing APDUs are encrypted.

§key_set: KeySet

Which 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

Source

pub const NONE: Self

No protection at all.

Source

pub const fn authenticated_encrypted(suite: SecuritySuite) -> Self

Authenticated and encrypted with the given suite — what a ciphered association normally uses.

Source

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.

Source

pub const fn with_dedicated(self, dedicated: bool) -> Self

The same protection with the dedicated key set, or back on the unicast one.

Source

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.

Source

pub const fn dedicated(self) -> bool

True when this association uses the key it negotiated for itself.

Source

pub const fn broadcast(self) -> bool

True when this association uses the broadcast key set.

Source

pub const fn key_usage(self) -> KeyUsage

Which key this policy’s key set resolves to.

Source

pub const fn control(self) -> SecurityControl

The security control byte this policy produces.

Source

pub const fn is_none(self) -> bool

True when nothing is applied.

Source

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.

Trait Implementations§

Source§

impl Clone for SecurityPolicy

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SecurityPolicy

Source§

impl Debug for SecurityPolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SecurityPolicy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for SecurityPolicy

Source§

impl PartialEq for SecurityPolicy

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SecurityPolicy

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.