[][src]Struct tox_packet::dht::CryptoHandshake

pub struct CryptoHandshake {
    pub cookie: EncryptedCookie,
    pub nonce: Nonce,
    pub payload: Vec<u8>,
}

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:

LengthContent
10x1a
24Nonce for the cookie
88Cookie
24Nonce for the payload
248Payload

Fields

cookie: EncryptedCookie

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

impl CryptoHandshake[src]

pub fn new(
    shared_secret: &PrecomputedKey,
    payload: &CryptoHandshakePayload,
    cookie: EncryptedCookie
) -> CryptoHandshake
[src]

Create CryptoHandshake from CryptoHandshakePayload encrypting it with shared_key and from EncryptedCookie.

pub fn get_payload(
    &self,
    shared_secret: &PrecomputedKey
) -> Result<CryptoHandshakePayload, GetPayloadError>
[src]

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

impl Clone for CryptoHandshake[src]

impl Debug for CryptoHandshake[src]

impl Eq for CryptoHandshake[src]

impl FromBytes for CryptoHandshake[src]

impl PartialEq<CryptoHandshake> for CryptoHandshake[src]

impl StructuralEq for CryptoHandshake[src]

impl StructuralPartialEq for CryptoHandshake[src]

impl ToBytes for CryptoHandshake[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.