[][src]Struct tox_packet::dht::CookieRequest

pub struct CookieRequest {
    pub pk: PublicKey,
    pub nonce: Nonce,
    pub payload: Vec<u8>,
}

CookieRequest packet struct. According to https://zetok.github.io/tox-spec/#net-crypto

CookieRequest packet (145 bytes):

[uint8_t 24] [Sender's DHT Public key (32 bytes)] [Random nonce (24 bytes)] [Encrypted message containing: [Sender's real public key (32 bytes)] [padding (32 bytes)] [uint64_t echo id (must be sent back untouched in cookie response)] ]

Serialized form:

LengthContent
10x18
32DHT Public Key
24Random nonce
88Payload

where Payload is encrypted CookieRequestPayload

Fields

pk: PublicKey

DHT public key

nonce: Nonce

Random nonce

payload: Vec<u8>

Encrypted payload of CookieRequest

Implementations

impl CookieRequest[src]

pub fn new(
    shared_secret: &PrecomputedKey,
    pk: &PublicKey,
    payload: &CookieRequestPayload
) -> CookieRequest
[src]

Create CookieRequest from CookieRequestPayload encrypting it with shared_key

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

Decrypt payload with secret key and try to parse it as CookieRequestPayload.

Returns Error in case of failure:

  • fails to decrypt
  • fails to parse CookieRequestPayload

Trait Implementations

impl Clone for CookieRequest[src]

impl Debug for CookieRequest[src]

impl Eq for CookieRequest[src]

impl FromBytes for CookieRequest[src]

impl PartialEq<CookieRequest> for CookieRequest[src]

impl StructuralEq for CookieRequest[src]

impl StructuralPartialEq for CookieRequest[src]

impl ToBytes for CookieRequest[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.