Skip to content

joejacobs/stream-ciphers

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RustCrypto: stream ciphers

Build Status dependency status

Collection of stream cipher algorithms written in pure Rust.

Warnings

Crates in this repository do not provide any authentification! Thus ciphertext integrity is not verified, which can lead to serious vulnerabilities!

Crates have not yet received any formal cryptographic and security reviews.

USE AT YOUR OWN RISK.

Crates

Name Crates.io Documentation
aes-ctr crates.io Documentation
cfb-mode crates.io Documentation
cfb8 crates.io Documentation
chacha20 crates.io Documentation
ctr crates.io Documentation
ofb crates.io Documentation
salsa20 crates.io Documentation
salsa20-core crates.io Documentation

Minimum Rust version

All crates in this repository support Rust 1.27 or higher. In future minimum supported Rust version can be changed, but it will be done with the minor version bump.

Usage

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

Let's use AES-128-OFB to demonstrate usage of synchronous stream cipher:

extern crate aes;
extern crate ofb;

use aes::Aes128;
use ofb::Ofb;
// import relevant traits
use ofb::stream_cipher::{NewStreamCipher, SyncStreamCipher};

// OFB mode implementation is generic over block ciphers
// we will create a type alias for convenience
type AesOfb = Ofb<Aes128>;

let key = b"very secret key.";
let iv = b"unique init vect";
let plaintext = b"The quick brown fox jumps over the lazy dog.";

let mut buffer = plaintext.to_vec();
// create cipher instance
let mut cipher = AesOfb::new_var(key, iv)?;
// apply keystream (encrypt)
cipher.apply_keystream(&mut buffer);
// and decrypt it back
AesOfb::new_var(key, iv)?.apply_keystream(&mut buffer);
// stream ciphers can be used with streaming messages
let mut cipher = AesOfb::new_var(key, iv).unwrap();
for chunk in buffer.chunks_mut(3) {
    cipher.apply_keystream(chunk);
}

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.

About

Collection of stream cipher algorithms

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 99.9%
  • Shell 0.1%