pub struct CryptoData {
pub nonce_last_bytes: u16,
pub payload: Vec<u8>,
}
Expand description
Packet used to send data over net_crypto
connection.
Serialized form:
Length | Content |
---|---|
1 | 0x1b |
2 | Last 2 bytes of the Nonce |
variable | Payload |
Fields§
§nonce_last_bytes: u16
Last two bytes of Nonce
for the current encrypted payload in BigEndian
format
payload: Vec<u8>
Encrypted payload
Implementations§
Source§impl CryptoData
impl CryptoData
Sourcepub fn nonce_last_bytes(nonce: Nonce) -> u16
pub fn nonce_last_bytes(nonce: Nonce) -> u16
Get last two bytes of Nonce
considering it as BigEndian number.
Sourcepub fn new(
shared_secret: &PrecomputedKey,
nonce: Nonce,
payload: &CryptoDataPayload,
) -> CryptoData
pub fn new( shared_secret: &PrecomputedKey, nonce: Nonce, payload: &CryptoDataPayload, ) -> CryptoData
Create CryptoData
from CryptoDataPayload
encrypting it with
shared_key
.
Sourcepub fn get_payload(
&self,
shared_secret: &PrecomputedKey,
nonce: &Nonce,
) -> Result<CryptoDataPayload, GetPayloadError>
pub fn get_payload( &self, shared_secret: &PrecomputedKey, nonce: &Nonce, ) -> Result<CryptoDataPayload, GetPayloadError>
Decrypt payload with precomputed key and nonce and try to parse it as CryptoDataPayload
.
Returns Error
in case of failure:
- fails to decrypt
- fails to parse
CryptoDataPayload
Trait Implementations§
Source§impl Clone for CryptoData
impl Clone for CryptoData
Source§fn clone(&self) -> CryptoData
fn clone(&self) -> CryptoData
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CryptoData
impl Debug for CryptoData
Source§impl FromBytes for CryptoData
impl FromBytes for CryptoData
Source§fn from_bytes(i: &[u8]) -> IResult<&[u8], CryptoData, (&[u8], ErrorKind)>
fn from_bytes(i: &[u8]) -> IResult<&[u8], CryptoData, (&[u8], ErrorKind)>
Deserialize struct using
nom
from raw bytesSource§impl PartialEq for CryptoData
impl PartialEq for CryptoData
Source§impl ToBytes for CryptoData
impl ToBytes for CryptoData
impl Eq for CryptoData
impl StructuralPartialEq for CryptoData
Auto Trait Implementations§
impl Freeze for CryptoData
impl RefUnwindSafe for CryptoData
impl Send for CryptoData
impl Sync for CryptoData
impl Unpin for CryptoData
impl UnwindSafe for CryptoData
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