#framework #strobe #protocols #no-std #crypto

no-std strobe-rs

An implementation of the Strobe protocol framework in pure Rust

20 releases

0.8.1 Oct 10, 2022
0.7.1 Feb 13, 2022
0.7.0 Dec 29, 2021
0.6.2 Nov 11, 2020
0.3.4 Jul 7, 2018

#224 in Cryptography

Download history 21929/week @ 2023-12-11 19717/week @ 2023-12-18 6726/week @ 2023-12-25 12766/week @ 2024-01-01 18187/week @ 2024-01-08 25486/week @ 2024-01-15 21971/week @ 2024-01-22 20572/week @ 2024-01-29 20837/week @ 2024-02-05 23777/week @ 2024-02-12 30483/week @ 2024-02-19 27525/week @ 2024-02-26 20242/week @ 2024-03-04 23895/week @ 2024-03-11 26203/week @ 2024-03-18 23889/week @ 2024-03-25

94,903 downloads per month
Used in 23 crates (14 directly)

MIT/Apache

64KB
916 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 - Implements std::error::Error for AuthError.
  • serialize_secret_state - Implements serde's Serialize and Deserialize traits for the Strobe struct. SECURITY NOTE: Serializing Strobe state outputs security sensitive data that MUST be kept private. Treat the data as you would a private encryption/decryption key.

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

MSRV

The current minimum supported Rust version (MSRV) is 1.51.0 (2021-03-25).

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

~0.6–1.2MB
~26K SLoC