orion Build Status codecov

Warning: There are no guarantees for the security of these implementations. Use at your own risk.

Cryptographic functions implemented in Rust, with a simple API.

Currently contains: * HMAC with SHA2(256, 384, 512). * HKDF with the above HMAC options. * PBKDF2 with the above HMAC options.

Usage

``` extern crate orion use orion::{default, core::util};

// HMAC-SHA512 let key = util::genrandkey(64).unwrap(); let msg = "Some message".as_bytes();

let expectedhmac = default::hmac(&key, msg).unwrap(); assert!(default::hmacverify(&expected_hmac, &key, &msg).unwrap());

// HKDF-HMAC-SHA512 let salt = util::genrandkey(64).unwrap(); let data = "Some data".asbytes(); let info = "Some info".asbytes();

let dk = default::hkdf(&salt, data, info, 64).unwrap(); assert!(default::hkdf_verify(&dk, &salt, data, info, 64).unwrap());

// PBKDF2-HMAC-SHA512 let salt = util::genrandkey(64).unwrap(); let password = "Secret password".as_bytes();

let dk = default::pbkdf2(password, &salt).unwrap(); assert!(default::pbkdf2_verify(&dk, password, &salt).unwrap()); ```

Documentation

To build the most recent: cargo doc --no-deps or view here.

Tests/Fuzzing

Unit tests are located in the same file as what is being tested, apart from implementation verification tests - these are in tests. To run all tests: cargo test.

Fuzzing is done using cargo-fuzz. Fuzzing targets are located in fuzz/fuzz_targets.

Benchmarks

The library can be benchmarked as below. All benchmarking tests are located in benches. cargo +nightly bench

Acknowledgments

Thanks to @defuse for a quick audit of the code.

License

orion is licensed under the MIT license. See the LICENSE file for more information.