[][src]Module ciph::salsa

Salsa20 symmetric cypher stream.

Secure an AsyncWrite + AsyncRead type by layering over it two

Structs

Accept

Future to accept a SalsaStream connection.

Acceptor

Counterpart to Connector. Take a Psk and Randomness and apply over an S: AsyncRead + AsyncWrite type producing a ServerStream.

Connector

Take a Psk and Randomness and apply over an S: AsyncRead + AsyncWrite type prodcuing a SalsaStream.

Psk

Pre-shared Key consisting of a WrapKey and a custom sequence of check bytes. These check bytes are used in the handshake by the server to ensure that decryption of the the transmitted key occurred properly.

SalsaStream

An encryption layer over an async read/write stream. Uses two salsa20 ciphers, one for reading and the other for writing. There is usually a counterpart SalsaStream with mirrored Salsa20 ciphers in sync. Generally SalsaStream is not instantiated directly but through Connector and Acceptor.

StreamAcceptor

Generic convenience type for waiting for new Salsa20 stream connection requests.

TcpListenAcceptor

Variant of StreamAcceptor for tokio::net::TcpListener because it doesn't impl Stream trait which can frustrate use inside some servers that require Stream. Use this if you want hyper (or similar) to listen for Salsa20 encrypted streams.

WrapKey

A wrapped Key for convenience and to ensure bytes are erased when dropped.

Enums

Randomness

Source of randomness. Currently two choices, use Entropy which uses the getrandom library to fetch random numbers from the OS or ChaCha20 which is a crypto secure pseudorandom number generator from the rand_chacha crate. Seeding is left to the user.

Functions

erase_bytes

To ensure keys and other valuable bits of info don't linger in memory, this function is called when possible to zero out the memory referred to in slice.

load_psk

Load a Psk from a text file. The format of the file is two base64 encoded numbers separated by a newline. The first number is the salsa20 key and the second number is a check value.