pub struct Wormhole {
    pub verifier: Box<Key>,
    pub our_version: Box<dyn Any + Send + Sync>,
    pub peer_version: Value,
    /* private fields */
}
Expand description

Establishing Wormhole connection

You can send and receive arbitrary messages in form of byte slices over it, using Wormhole::send and Wormhole::receive. Everything else (including encryption) will be handled for you.

To create a wormhole, use the Wormhole::connect_without_code, Wormhole::connect_with_code etc. methods, depending on which values you have. Typically, the sender side connects without a code (which will create one), and the receiver side has one (the user entered it, who got it from the sender).

Clean shutdown

TODO

Fields

verifier: Box<Key>

If you’re paranoid, let both sides check that they calculated the same verifier.

PAKE hardens a standard key exchange with a password (“password authenticated”) in order to mitigate potential man in the middle attacks that would otherwise be possible. Since the passwords usually are not of hight entropy, there is a low-probability possible of an attacker guessing the password correctly, enabling them to MitM the connection.

Not only is that probability low, but they also have only one try per connection and a failed attempts will be noticed by both sides. Nevertheless, comparing the verifier mitigates that attack vector.

our_version: Box<dyn Any + Send + Sync>

Our “app version” information that we sent. See the [peer_version] for more information.

peer_version: Value

Protocol version information from the other side. This is bound by the AppID’s protocol and thus shall be handled on a higher level (e.g. by the file transfer API).

Implementations

Generate a code and connect to the rendezvous server.

Returns

A tuple with a WormholeWelcome and a std::future::Future that will do the rest of the client-client handshake and yield the Wormhole object on success.

Connect to a peer with a code.

TODO

Do only the client-client part of the connection setup

The rendezvous server must already have an opened mailbox.

Panics

If the RendezvousServer is not properly initialized, i.e. if the mailbox is not open.

Send an encrypted message to peer

Serialize and send an encrypted message to peer

This will serialize the message as json string, which is most commonly used by upper layer protocols. The serialization may not fail

Panics

If the serialization fails

Receive an encrypted message from peer

Receive an encrypted message from peer

This will deserialize the message as json string, which is most commonly used by upper layer protocols. We distinguish between the different layers on which a serialization error happened, hence the double Result.

The AppID this wormhole is bound to. This determines the upper-layer protocol. Only wormholes with the same value can talk to each other.

The symmetric encryption key used by this connection. Can be used to derive sub-keys for different purposes.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.