pub struct Encrypted<'a> {
pub security: Security,
pub data: &'a [u8],
pub encrypted_len: usize,
pub meter: Option<Address>,
/* private fields */
}Expand description
An encrypted layer and everything needed to open it.
Fields§
§security: SecurityHow it is protected.
data: &'a [u8]The encrypted bytes, and any plain bytes after them.
encrypted_len: usizeHow many leading bytes of data are encrypted.
meter: Option<Address>The meter whose key opens it, if known.
Implementations§
Source§impl Encrypted<'_>
impl Encrypted<'_>
Sourcepub fn decrypt<'o, K: Keys + ?Sized>(
&self,
keys: &K,
out: &'o mut [u8],
) -> Result<Application<'o>>
Available on crate feature oms only.
pub fn decrypt<'o, K: Keys + ?Sized>( &self, keys: &K, out: &'o mut [u8], ) -> Result<Application<'o>>
oms only.Decrypt (and, for mode 7 with an AFL MAC and mode 10, authenticate) this layer into out,
and parse what is inside.
| Security | Key | Verified by | Authenticity |
|---|---|---|---|
| mode 5 | the meter’s | 2F 2F | Authenticity::Encrypted |
| mode 7 | derived from the meter’s and the AFL counter | AFL CMAC, then 2F 2F | Authenticity::Authenticated (without a MAC: Encrypted) |
| mode 10 | derived from the meter’s and the TPL counter | CCM tag | Authenticity::Authenticated |
| ELL | the meter’s | payload CRC | Encrypted; the inner layers may add more |
out needs self.data.len() bytes. On any failed check the result is an error
naming the check (Check), never partial records and never key material. A
transport layer that is not data records (alarm, error, compact) is
Error::UnsupportedCi. An ELL may contain a TPL that is itself encrypted: the
result’s body is then Body::Encrypted again (wireless::open
opens both).
Trait Implementations§
Auto Trait Implementations§
impl<'a> Forget for Encrypted<'a>
impl<'a> Freeze for Encrypted<'a>
impl<'a> Move for Encrypted<'a>
impl<'a> RefUnwindSafe for Encrypted<'a>
impl<'a> Send for Encrypted<'a>
impl<'a> Sync for Encrypted<'a>
impl<'a> Unpin for Encrypted<'a>
impl<'a> UnsafeUnpin for Encrypted<'a>where
&'a [u8]: UnsafeUnpin,
impl<'a> UnwindSafe for Encrypted<'a>where
&'a [u8]: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more