#crypto #protocol #framework #no-std #strobe

no-std strobe-rs

An implementation of the Strobe protocol framework in pure Rust

16 releases

0.6.2 Nov 11, 2020
0.5.4 Jul 24, 2020
0.5.3 Mar 25, 2020
0.5.2 Aug 22, 2019
0.3.4 Jul 7, 2018

#86 in Cryptography

Download history 181/week @ 2021-07-04 106/week @ 2021-07-11 140/week @ 2021-07-18 131/week @ 2021-07-25 131/week @ 2021-08-01 100/week @ 2021-08-08 114/week @ 2021-08-15 105/week @ 2021-08-22 51/week @ 2021-08-29 36/week @ 2021-09-05 192/week @ 2021-09-12 82/week @ 2021-09-19 172/week @ 2021-09-26 65/week @ 2021-10-03 206/week @ 2021-10-10 342/week @ 2021-10-17

763 downloads per month
Used in 15 crates (7 directly)

MIT/Apache

67KB
889 lines

strobe-rs

CI Coverage Version Docs

This is a relatively barebones, no_std implementation of the Strobe protocol framework in pure Rust. It is intended to be used as a library to build other protocols and frameworks. This implementation currently only supports Keccak-f[1600] as the internal permutation function, which is the largest possible block size, so big deal.

Example

A simple program that encrypts and decrypts a message:

use strobe_rs::{SecParam, Strobe};

fn main() {
    let mut rx = Strobe::new(b"correctnesstest", SecParam::B256);
    let mut tx = Strobe::new(b"correctnesstest", SecParam::B256);

    rx.key(b"the-combination-on-my-luggage", false);
    tx.key(b"the-combination-on-my-luggage", false);

    let mut msg = b"Attack at dawn".to_vec();
    rx.send_enc(msg.as_mut_slice(), false);

    // Rename for clarity. `msg` has been encrypted in-place.
    let mut ciphertext = msg;

    tx.recv_enc(ciphertext.as_mut_slice(), false);

    // And back again.
    let round_trip_msg = ciphertext;

    assert_eq!(&round_trip_msg, b"Attack at dawn");
}

Features

Default features flags: [none]

Feature flag list:

  • std - Necessary for running known-answer tests. No need to enable unless you're debugging this crate.

For info on how to omit or include feature flags, see the cargo docs on features.

Tests

To run tests, execute

cargo test --all-features

This includes known-answer tests, which test against JSON-encoded test vectors in the kat/ directory. To verify these test vectors against the reference Python implementation, cd into kat/, run python2 verify_test_vector.py and follow the included instructions.

Benchmarks

To benchmark, run

cargo bench

This will produce a summary with plots in target/crieteron/report/index.html. These won't be very interesting, since almost every function in STROBE has the same runtime.

TODO

  • Contribute an asm impelmentation of Keccak-f[1600] to tiny-keccak and expose a feature flag that lets strobe-rs users choose which implementation they prefer.

License

Licensed under either of

at your option.

Warning

This code has not been audited in any sense of the word. Use at your own discretion.

Dependencies

~185KB

!_