• Stars
    star
    234
  • Rank 165,312 (Top 4 %)
  • Language
    Rust
  • Created about 7 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Collection of stream cipher algorithms

RustCrypto: stream ciphers

Project Chat dependency status Apache2/MIT licensed HAZMAT

Collection of stream ciphers written in pure Rust.

โš ๏ธ Security Warning: Hazmat!

Crates in this repository do not ensure ciphertexts are authentic (i.e. by using a MAC to verify ciphertext integrity), which can lead to serious vulnerabilities if used incorrectly!

Aside from the chacha20 crate, no crates in this repository have yet received any formal cryptographic and security reviews/audits.

USE AT YOUR OWN RISK!

Crates

Name Crate name Crates.io Docs MSRV Security
ChaCha chacha20 crates.io Documentation MSRV 1.65 ๐Ÿ’š
HC-256 hc-256 crates.io Documentation MSRV 1.65 ๐Ÿ’›
Rabbit rabbit crates.io Documentation MSRV 1.65 ๐Ÿ’›
RC4 rc4 crates.io Documentation MSRV 1.65 ๐Ÿ’”
Salsa20 salsa20 crates.io Documentation MSRV 1.65 ๐Ÿ’š

Security Level Legend

The following describes the security level ratings associated with each hash function (i.e. algorithms, not the specific implementation):

Heart Description
๐Ÿ’š No known successful attacks
๐Ÿ’› Theoretical break: security lower than claimed
๐Ÿ’” Attack demonstrated in practice: avoid if at all possible

Minimum Supported Rust Version (MSRV) Policy

MSRV bump is considered a breaking change and will be performed only with a minor version bump.

Example

Crates functionality is expressed in terms of traits defined in the cipher crate.

Let's use ChaCha20 to demonstrate usage of synchronous stream cipher:

use chacha20::ChaCha20;
// Import relevant traits
use chacha20::cipher::{KeyIvInit, StreamCipher, StreamCipherSeek};
use hex_literal::hex;

let key = [0x42; 32];
let nonce = [0x24; 12];
let plaintext = hex!("00010203 04050607 08090a0b 0c0d0e0f");
let ciphertext = hex!("e405626e 4f1236b3 670ee428 332ea20e");

// Key and IV must be references to the `GenericArray` type.
// Here we use the `Into` trait to convert arrays into it.
let mut cipher = ChaCha20::new(&key.into(), &nonce.into());

let mut buffer = plaintext.clone();

// apply keystream (encrypt)
cipher.apply_keystream(&mut buffer);
assert_eq!(buffer, ciphertext);

let ciphertext = buffer.clone();

// ChaCha ciphers support seeking
cipher.seek(0u32);

// decrypt ciphertext by applying keystream again
cipher.apply_keystream(&mut buffer);
assert_eq!(buffer, plaintext);

// stream ciphers can be used with streaming messages
cipher.seek(0u32);
for chunk in buffer.chunks_mut(3) {
    cipher.apply_keystream(chunk);
}
assert_eq!(buffer, ciphertext);

License

All crates licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

More Repositories

1

hashes

Collection of cryptographic hash functions written in pure Rust
Rust
1,617
star
2

AEADs

Authenticated Encryption with Associated Data Algorithms: high-level encryption ciphers
Rust
623
star
3

block-ciphers

Collection of block cipher algorithms written in pure Rust
Rust
617
star
4

elliptic-curves

Collection of pure Rust elliptic curve implementations: NIST P-224, P-256, P-384, P-521, secp256k1, SM2
Rust
573
star
5

password-hashes

Password hashing functions / KDFs
Rust
556
star
6

traits

Collection of cryptography-related traits
Rust
526
star
7

RSA

RSA implementation in pure Rust
Rust
482
star
8

signatures

Cryptographic signature algorithms: DSA, ECDSA, Ed25519
Rust
407
star
9

utils

Utility crates used in RustCrypto
Rust
388
star
10

MACs

Message authentication code algorithms written in pure Rust
Rust
227
star
11

formats

Cryptography-related format encoders/decoders: DER, PEM, PKCS, PKIX
Rust
200
star
12

crypto-bigint

Cryptography-oriented big integer library with constant-time, stack-allocated (no_std-friendly) implementations of modern formulas
Rust
154
star
13

PAKEs

Password-Authenticated Key Agreement protocols
Rust
96
star
14

SSH

Pure Rust implementation of components of the Secure Shell (SSH) protocol
Rust
93
star
15

KDFs

Collection of Key Derivation Functions written in pure Rust
Rust
62
star
16

nacl-compat

Pure Rust compatibility layer for NaCl-family libraries
Rust
48
star
17

JOSE

Pure Rust implementation of Javascript Object Signing and Encryption (JOSE)
Rust
43
star
18

block-modes

Collection of generic block mode algorithms written in pure Rust
Rust
42
star
19

asm-hashes

Assembly implementations of cryptographic hash functions
Assembly
41
star
20

sponges

Collection of sponge functions written in pure Rust
Rust
34
star
21

ring-compat

Compatibility library for using *ring* as a backend for RustCrypto's traits
Rust
29
star
22

universal-hashes

Collection of universal hashing functions
Rust
24
star
23

book

Reference manual for the RustCrypto project, implemented as an MDBook [WIP]
Rust
15
star
24

rustls-rustcrypto

Rustls cryptography provider built on the pure Rust crates from the RustCrypto organization
Rust
15
star
25

CSRNGs

Collection of Cryptographically Secure PseudoRandom Number Generators written in pure Rust
11
star
26

meta

Meta-crates of the RustCrypto project
Rust
10
star
27

key-wraps

Symmetric key-wrapping algorithms
Rust
7
star
28

KEMs

Collection of Key Encapsulation Mechanisms written in pure Rust
5
star
29

actions

GitHub Actions configs: composite actions and shared workflow configuration
4
star
30

.github

RustCrypto's profile README.md
4
star
31

rust-crypto-decoupled

Experiment on dividing rust-crypto into several small crates
Rust
3
star
32

hybrid-array

Hybrid typenum/const generic arrays
Rust
2
star
33

media

Media files of the RustCrypto project
2
star