pub struct CryptoHandshake {
pub cookie: EncryptedCookie,
pub nonce: Nonce,
pub payload: Vec<u8>,
}
Expand description
Packet used to establish net_crypto
connection between two peers.
When Alice establishes net_crypto
connection with Bob she should get valid
Cookie
from him and send CryptoHandshake
packet. Connection considered
established when both Alice and Bob received CryptoHandshake
packet from each
other with valid cookies.
Serialized form:
Length | Content |
---|---|
1 | 0x1a |
24 | Nonce for the cookie |
88 | Cookie |
24 | Nonce for the payload |
248 | Payload |
Fields§
Encrypted cookie used to check that the sender of this packet received a cookie response
nonce: Nonce
Nonce for the current encrypted payload
payload: Vec<u8>
Encrypted payload
Implementations§
Source§impl CryptoHandshake
impl CryptoHandshake
Sourcepub fn new(
shared_secret: &PrecomputedKey,
payload: &CryptoHandshakePayload,
cookie: EncryptedCookie,
) -> CryptoHandshake
pub fn new( shared_secret: &PrecomputedKey, payload: &CryptoHandshakePayload, cookie: EncryptedCookie, ) -> CryptoHandshake
Create CryptoHandshake
from CryptoHandshakePayload
encrypting it
with shared_key
and from EncryptedCookie
.
Sourcepub fn get_payload(
&self,
shared_secret: &PrecomputedKey,
) -> Result<CryptoHandshakePayload, GetPayloadError>
pub fn get_payload( &self, shared_secret: &PrecomputedKey, ) -> Result<CryptoHandshakePayload, GetPayloadError>
Decrypt payload with precomputed key and try to parse it as CryptoHandshakePayload
.
Returns Error
in case of failure:
- fails to decrypt
- fails to parse
CryptoHandshakePayload
Trait Implementations§
Source§impl Clone for CryptoHandshake
impl Clone for CryptoHandshake
Source§fn clone(&self) -> CryptoHandshake
fn clone(&self) -> CryptoHandshake
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 CryptoHandshake
impl Debug for CryptoHandshake
Source§impl FromBytes for CryptoHandshake
impl FromBytes for CryptoHandshake
Source§fn from_bytes(i: &[u8]) -> IResult<&[u8], CryptoHandshake, (&[u8], ErrorKind)>
fn from_bytes(i: &[u8]) -> IResult<&[u8], CryptoHandshake, (&[u8], ErrorKind)>
Deserialize struct using
nom
from raw bytesSource§impl PartialEq for CryptoHandshake
impl PartialEq for CryptoHandshake
Source§impl ToBytes for CryptoHandshake
impl ToBytes for CryptoHandshake
impl Eq for CryptoHandshake
impl StructuralPartialEq for CryptoHandshake
Auto Trait Implementations§
impl Freeze for CryptoHandshake
impl RefUnwindSafe for CryptoHandshake
impl Send for CryptoHandshake
impl Sync for CryptoHandshake
impl Unpin for CryptoHandshake
impl UnwindSafe for CryptoHandshake
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