3 unstable releases

0.2.1 Jul 12, 2024
0.2.0 Jul 8, 2024
0.1.1 Jun 7, 2024

#1044 in Cryptography

Download history 37/week @ 2024-07-22 2/week @ 2024-08-26 18/week @ 2024-09-16 18/week @ 2024-09-23 5/week @ 2024-09-30

146 downloads per month
Used in gday

MIT license

21KB
327 lines

gday_encryption

Crates.io Version docs.rs

A simple encrypted wrapper around an IO stream. Uses a streaming chacha20poly1305 cipher.

See the documentation.

Used by

  • gday - Command line tool for sending files.

lib.rs:

A simple encrypted wrapper around an IO stream.

Uses a streaming chacha20poly1305 cipher.

This library is used by gday_file_transfer, which is used by gday.

In general, I recommend using the well-established rustls for encryption. gday_file_transfer chose this library because rustls didn't support peer-to-peer connections with a shared key.

Example

#
let shared_key: [u8; 32] = [42; 32];

//////// Peer A ////////
let mut encrypted_stream = EncryptedStream::encrypt_connection(&mut tcp_stream, &shared_key)?;
encrypted_stream.write_all(b"Hello!")?;
encrypted_stream.flush()?;

//////// Peer B (on a different computer) ////////
let mut encrypted_stream = EncryptedStream::encrypt_connection(&mut tcp_stream, &shared_key)?;

let mut received = [0u8; 6];
encrypted_stream.read_exact(&mut received)?;

Dependencies

~1MB
~20K SLoC