GithubHelp home page GithubHelp logo

stream-ciphers's Introduction

RustCrypto: stream ciphers Rust Version Project Chat dependency status HAZMAT

Collection of stream cipher algorithms 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 Crates.io Documentation Build Status
cfb-mode crates.io Documentation build
cfb8 crates.io Documentation build
chacha20 crates.io Documentation build
ctr crates.io Documentation build
hc-256 crates.io Documentation build
ofb crates.io Documentation build
rabbit crates.io Documentation build
salsa20 crates.io Documentation build

Minimum Supported Rust Version

Rust 1.41 or higher.

Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump.

Usage

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

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

use aes::Aes128;
use ofb::Ofb;

// import relevant traits
use ofb::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.

stream-ciphers's People

Contributors

blackbeam avatar dependabot[bot] avatar dhardy avatar emc2 avatar froydnj avatar joejacobs avatar jpdoyle avatar koivunej avatar newpavlov avatar paulgrandperrin avatar srijs avatar sseemayer avatar tarcieri avatar wassasin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.