[−][src]Struct tox_packet::dht::CryptoHandshake
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
impl CryptoHandshake
[src]
pub fn new(
shared_secret: &PrecomputedKey,
payload: &CryptoHandshakePayload,
cookie: EncryptedCookie
) -> CryptoHandshake
[src]
shared_secret: &PrecomputedKey,
payload: &CryptoHandshakePayload,
cookie: EncryptedCookie
) -> CryptoHandshake
Create CryptoHandshake
from CryptoHandshakePayload
encrypting it
with shared_key
and from EncryptedCookie
.
pub fn get_payload(
&self,
shared_secret: &PrecomputedKey
) -> Result<CryptoHandshakePayload, GetPayloadError>
[src]
&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
impl Clone for CryptoHandshake
[src]
pub fn clone(&self) -> CryptoHandshake
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for CryptoHandshake
[src]
impl Eq for CryptoHandshake
[src]
impl FromBytes for CryptoHandshake
[src]
impl PartialEq<CryptoHandshake> for CryptoHandshake
[src]
pub fn eq(&self, other: &CryptoHandshake) -> bool
[src]
pub fn ne(&self, other: &CryptoHandshake) -> bool
[src]
impl StructuralEq for CryptoHandshake
[src]
impl StructuralPartialEq for CryptoHandshake
[src]
impl ToBytes for CryptoHandshake
[src]
Auto Trait Implementations
impl RefUnwindSafe for CryptoHandshake
[src]
impl Send for CryptoHandshake
[src]
impl Sync for CryptoHandshake
[src]
impl Unpin for CryptoHandshake
[src]
impl UnwindSafe for CryptoHandshake
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,