[][src]Struct tox_packet::onion::OnionReturn

pub struct OnionReturn {
    pub nonce: Nonce,
    pub payload: Vec<u8>,
}

Encrypted onion return addresses. Payload contains encrypted with symmetric key IpPort and possibly inner OnionReturn.

When DHT node receives OnionRequest packet it appends OnionReturn to the end of the next request packet it will send. So when DHT node receives OnionResponse packet it will know where to send the next response packet by decrypting OnionReturn from received packet. If node can't decrypt OnionReturn that means that onion path is expired and packet should be dropped.

Serialized form:

LengthContent
24Nonce
35 or 94 or 153Payload

where payload is encrypted inner OnionReturn

Fields

nonce: Nonce

Nonce for the current encrypted payload

payload: Vec<u8>

Encrypted payload

Implementations

impl OnionReturn[src]

pub fn new(
    symmetric_key: &Key,
    ip_port: &IpPort,
    inner: Option<&OnionReturn>
) -> OnionReturn
[src]

Create new OnionReturn object using symmetric key for encryption.

pub fn get_payload(
    &self,
    symmetric_key: &Key
) -> Result<(IpPort, Option<OnionReturn>), Error>
[src]

Decrypt payload with symmetric key and try to parse it as IpPort with possibly inner OnionReturn.

Returns Error in case of failure:

  • fails to decrypt
  • fails to parse as IpPort with possibly inner OnionReturn

Trait Implementations

impl Clone for OnionReturn[src]

impl Debug for OnionReturn[src]

impl Eq for OnionReturn[src]

impl FromBytes for OnionReturn[src]

impl PartialEq<OnionReturn> for OnionReturn[src]

impl StructuralEq for OnionReturn[src]

impl StructuralPartialEq for OnionReturn[src]

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