Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
48fa276
initial sketches, help from hdevalence
warner May 6, 2017
57a3842
more sketches, help from manishearth
warner May 17, 2017
441f2da
more
warner May 23, 2017
63c7a72
update, make it compile (but not work, of course)
warner May 24, 2017
e0c3108
more progress, make some dummy implementations pass tests
warner May 24, 2017
3542bec
fix blinding factors, implement full algorithm
warner May 24, 2017
4c9c23b
add github-provided boilerplate: LICENSE, README, .gitignore
warner May 24, 2017
241652b
README: warn people away from thinking this is ready for use
warner May 24, 2017
c7c16d7
add support for symmetric mode
warner May 24, 2017
609ec7f
add travis-CI
warner May 24, 2017
ae52187
README: add travis badge
warner May 24, 2017
2c07920
improvements for tests, which of course fail
warner May 25, 2017
f490a79
change the nature of the failure. still wrong, but better wrong!
warner May 25, 2017
6d76b86
slow progress, got password-to-scalar working
warner May 25, 2017
c87a7ca
fix test_sizes: needed to strip side-byte before transcript hash
warner May 25, 2017
161f822
fix incorrect tests
warner May 25, 2017
33522ac
fix all tests, refactor some code for easier testing
warner May 30, 2017
25820c4
prep for preliminary 0.0.1 release
warner Aug 1, 2017
90824a5
Cargo.toml: fix the travis badge URL
warner Aug 1, 2017
663f4c8
Link to https://docs.rs/spake2 for doc builds.
isislovecruft Aug 1, 2017
c1a8990
Add badges for crates.io and docs.rs to the README.
isislovecruft Aug 1, 2017
9f02b99
Merge PR1: update docs
warner Aug 1, 2017
a0f653c
fix several clippy lints
warner Sep 4, 2017
332e28b
hush remaining lints, thanks clippy for the suggestions
warner Sep 4, 2017
861ece4
move from (unmaintained) rust-crypto to RustCrypto ('sha2' crate)
warner Aug 2, 2017
df09f92
comment out debug messages
warner Sep 21, 2017
b9ef2ee
add benchmarks: run 'cargo bench'
warner Sep 21, 2017
f4f23fb
release 0.0.2, still preliminary
warner Sep 21, 2017
adf7129
add test coverage (cargo-tarpaulin) and codecov.io reporting
warner Oct 8, 2017
48e41a6
update to the curve25519-dalek 0.12 API
warner Oct 12, 2017
8512188
update to hex-0.3
warner Nov 15, 2017
bf3d3ab
README: add badge for codecov.io
warner Nov 15, 2017
7c4155e
travis: add OS-X
warner Nov 25, 2017
acd58c7
travis: fix test invocation
warner Nov 25, 2017
5c5ee64
update to curve25519-dalek 0.13
warner Nov 25, 2017
b0d898f
update to hkdf-0.3 and sha2-0.7 (new Digest API)
warner Nov 29, 2017
e014de2
(cargo-release) version 0.0.3
warner Nov 29, 2017
4448ccf
(cargo-release) start next development iteration 0.0.4-alpha.0
warner Nov 29, 2017
3e322cb
update to curve25519-dalek-0.14
warner Dec 6, 2017
1eaedab
format everything with rustfmt
warner Dec 19, 2017
54eb6ca
update to rand-0.4, since dalek-0.14.4 uses it
warner Jan 25, 2018
9b3b99f
(cargo-release) version 0.0.4
warner Jan 28, 2018
e350b76
(cargo-release) start next development iteration 0.0.5-alpha.0
warner Jan 28, 2018
06fe110
spake2.rs: remove unnecessary ref, thanks clippy
warner Feb 11, 2018
c0c286c
remove redundant field names, thanks clippy
warner Feb 27, 2018
c715bf4
update to curve25519-dalek-0.15
warner Mar 6, 2018
7978338
update to hkdf-0.4
warner Mar 24, 2018
bff1b1f
update to curve25519-dalek-0.16
warner Mar 24, 2018
2a9fd36
(cargo-release) version 0.0.5
warner Apr 29, 2018
3705d53
(cargo-release) start next development iteration 0.0.6-alpha.0
warner Apr 29, 2018
ec98460
Cargo.toml: update to latest rand and curve25519-dalek
warner May 22, 2018
52326a6
Cargo.toml: update to latest hkdf
warner May 22, 2018
0c500f3
cargo fmt
warner May 23, 2018
2da29cf
(cargo-release) version 0.0.6
warner May 23, 2018
2c1f68d
(cargo-release) start next development iteration 0.0.7-alpha.0
warner May 23, 2018
2e0fbf2
implement Debug for SPAKE2, to help downstream applications derive it
warner May 25, 2018
6b8be3f
Cargo.toml: remove redundant dev-dep on hex
warner May 25, 2018
f9d4a22
derive Eq and PartialEq too
warner May 25, 2018
db65799
travis: add rustfmt, ignore WIP-* branches
warner May 25, 2018
71baf98
(cargo-release) version 0.0.7
warner May 25, 2018
1b4418d
(cargo-release) start next development iteration 0.0.8-alpha.0
warner May 25, 2018
4df7100
update deps: num-bigint=0.2
warner May 26, 2018
2958035
(cargo-release) version 0.0.8
warner May 26, 2018
9bd2021
(cargo-release) start next development iteration 0.0.9-alpha.0
warner May 26, 2018
0869881
use newtypes for Password and Identity to avoid usage errors
warner Jun 3, 2018
4770291
update deps: curve25519-dalek=0.18
warner Jun 26, 2018
475d722
forbid unsafe_code, and warnings durings tests
warner Jul 19, 2018
3d29e39
update deps: curve25519-dalek=0.19
warner Jul 27, 2018
e0bc109
update deps: hkdf-0.6
warner Aug 21, 2018
4119bda
cargo fmt
warner Aug 21, 2018
891ac99
README: soften the disclaimer by roughly 24%
warner Aug 21, 2018
3627086
(cargo-release) version 0.0.9
warner Aug 21, 2018
033cd4c
(cargo-release) start next development iteration 0.0.10-alpha.0
warner Aug 21, 2018
c1621a7
README: oops, I was supposed to bump the minor version for this release
warner Aug 21, 2018
2fe67eb
(cargo-release) version 0.1.0
warner Aug 21, 2018
76dd73f
(cargo-release) start next development iteration 0.1.1-alpha.0
warner Aug 21, 2018
f6e9d07
README/Cargo.toml: add more badges
warner Sep 24, 2018
a23222c
Add 'spake2/' from commit 'f6e9d07dffa9a9b39f203c23043f93337ebe1ab6'
warner Oct 16, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions spake2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Generated by Cargo
# will have compiled files and executables
/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
/cobertura.xml
40 changes: 40 additions & 0 deletions spake2/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
language: rust

rust:
- stable
- beta
- nightly

os:
- linux
- osx

branches:
except:
- /^WIP-.*$/

matrix:
include:
- rust: 1.26.0 # lock down for consistent rustfmt behavior
env: RUSTFMT
install:
- rustup component add rustfmt-preview
script:
- cargo fmt -- --write-mode=diff
allow_failures:
- rust: nightly

script:
- cargo clean
- cargo build --verbose --all
# - cargo run --verbose --example XYZ
# - cargo test --verbose --features "test" --all
- cargo test --verbose --all

after_success: |
if [[ "$TRAVIS_RUST_VERSION" == stable ]]; then
bash <(curl https://raw.githubusercontent.com/xd009642/tarpaulin/master/travis-install.sh)
# Uncomment the following two lines create and upload a report for codecov.io
cargo tarpaulin --out Xml
bash <(curl -s https://codecov.io/bash)
fi
33 changes: 33 additions & 0 deletions spake2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "spake2"
version = "0.1.1-alpha.0"
authors = ["Brian Warner <warner@lothar.com>"]
description = "The SPAKE2 password-authenticated key-exchange algorithm, in Rust."
documentation = "https://docs.rs/spake2"
homepage = "https://github.com/warner/spake2.rs"
repository = "https://github.com/warner/spake2.rs"
license = "MIT"
categories = ["cryptography"]
exclude = [
".gitignore"
]

[badges]
travis-ci = { repository = "warner/spake2.rs" }
is-it-maintained-issue-resolution = { repository = "warner/spake2.rs" }
is-it-maintained-open-issues = { repository = "warner/spake2.rs" }

[dependencies]
curve25519-dalek = "0.19"
rand = "0.5"
sha2 = "0.7"
hkdf = "0.6"
num-bigint = "0.2"
hex = "0.3"

[dev-dependencies]
bencher = "0.1"

[[bench]]
name = "spake2"
harness = false
21 changes: 21 additions & 0 deletions spake2/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Brian Warner

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
29 changes: 29 additions & 0 deletions spake2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# spake2.rs
The SPAKE2 password-authenticated key-exchange algorithm, in Rust.

[![Build Status][build-status-image]][build-status-url]
[![Codecov][codecov-image]][codecov-url]
[![Is-It-Maintained-Resolution-Time][iim-resolution-image]][iim-resolution-url]
[![Is-It-Maintained-Open-Issues][iim-open-image]][iim-open-url]
[![Crates.io][crates-io-image]][crates-io-url]
[![Docs.rs][docs-image]][docs-url]
[![License][license-image]][license-url]

This is still pretty early, but seems to do the job. It needs a proper security review before you should consider using it for anything serious.

Note that the API has changed since 0.0.8 . I released 0.0.9 by mistake.

[build-status-image]: https://travis-ci.org/warner/spake2.rs.svg?branch=master
[build-status-url]: https://travis-ci.org/warner/spake2.rs
[codecov-image]: https://codecov.io/gh/warner/spake2.rs/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/warner/spake2.rs
[crates-io-image]: https://img.shields.io/crates/v/spake2.svg
[crates-io-url]: https://crates.io/crates/spake2
[docs-image]: https://docs.rs/spake2/badge.svg
[docs-url]: https://docs.rs/spake2
[license-image]: https://img.shields.io/badge/License-MIT-blue.svg
[license-url]: LICENSE
[iim-resolution-image]: http://isitmaintained.com/badge/resolution/warner/spake2.rs.svg
[iim-resolution-url]: http://isitmaintained.com/project/warner/spake2.rs
[iim-open-image]: http://isitmaintained.com/badge/open/warner/spake2.rs.svg
[iim-open-url]: http://isitmaintained.com/project/warner/spake2.rs
60 changes: 60 additions & 0 deletions spake2/benches/spake2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#[macro_use]
extern crate bencher;

extern crate spake2;

use bencher::Bencher;
use spake2::{Ed25519Group, Identity, Password, SPAKE2};

fn spake2_start(bench: &mut Bencher) {
bench.iter(|| {
let (_, _) = SPAKE2::<Ed25519Group>::start_a(
&Password::new(b"password"),
&Identity::new(b"idA"),
&Identity::new(b"idB"),
);
})
}

/*
fn spake2_finish(bench: &mut Bencher) {
// this doesn't work, because s1 is consumed by doing finish()
let (s1, msg1) = SPAKE2::<Ed25519Group>::start_a(
&Password::new(b"password"),
&Identity::new(b"idA"),
&Identity::new(b"idB"),
);
let (s2, msg2) = SPAKE2::<Ed25519Group>::start_b(
&Password::new(b"password"),
&Identity::new(b"idA"),
&Identity::new(b"idB"),
);
let msg2_slice = msg2.as_slice();
bench.iter(|| s1.finish(msg2_slice))
}
*/

fn spake2_start_and_finish(bench: &mut Bencher) {
let (_, msg2) = SPAKE2::<Ed25519Group>::start_b(
&Password::new(b"password"),
&Identity::new(b"idA"),
&Identity::new(b"idB"),
);
let msg2_slice = msg2.as_slice();
bench.iter(|| {
let (s1, _) = SPAKE2::<Ed25519Group>::start_a(
&Password::new(b"password"),
&Identity::new(b"idA"),
&Identity::new(b"idB"),
);
s1.finish(msg2_slice)
})
}

benchmark_group!(
benches,
spake2_start,
//spake2_finish,
spake2_start_and_finish
);
benchmark_main!(benches);
109 changes: 109 additions & 0 deletions spake2/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#![forbid(unsafe_code)]
#![cfg_attr(test, deny(warnings))]

extern crate curve25519_dalek;
extern crate hex;
extern crate hkdf;
extern crate num_bigint;
extern crate rand;
extern crate sha2;

mod spake2;
pub use spake2::*;

#[cfg(test)]
mod tests {
use spake2::{Ed25519Group, ErrorType, Identity, Password, SPAKE2, SPAKEErr};

#[test]
fn test_basic() {
let (s1, msg1) = SPAKE2::<Ed25519Group>::start_a(
&Password::new(b"password"),
&Identity::new(b"idA"),
&Identity::new(b"idB"),
);
let (s2, msg2) = SPAKE2::<Ed25519Group>::start_b(
&Password::new(b"password"),
&Identity::new(b"idA"),
&Identity::new(b"idB"),
);
let key1 = s1.finish(msg2.as_slice()).unwrap();
let key2 = s2.finish(msg1.as_slice()).unwrap();
assert_eq!(key1, key2);
}

#[test]
fn test_mismatch() {
let (s1, msg1) = SPAKE2::<Ed25519Group>::start_a(
&Password::new(b"password"),
&Identity::new(b"idA"),
&Identity::new(b"idB"),
);
let (s2, msg2) = SPAKE2::<Ed25519Group>::start_b(
&Password::new(b"password2"),
&Identity::new(b"idA"),
&Identity::new(b"idB"),
);
let key1 = s1.finish(msg2.as_slice()).unwrap();
let key2 = s2.finish(msg1.as_slice()).unwrap();
assert_ne!(key1, key2);
}

#[test]
fn test_reflected_message() {
let (s1, msg1) = SPAKE2::<Ed25519Group>::start_a(
&Password::new(b"password"),
&Identity::new(b"idA"),
&Identity::new(b"idB"),
);
let r = s1.finish(msg1.as_slice());
assert_eq!(
r.unwrap_err(),
SPAKEErr {
kind: ErrorType::BadSide,
}
);
}

#[test]
fn test_bad_length() {
let (s1, msg1) = SPAKE2::<Ed25519Group>::start_a(
&Password::new(b"password"),
&Identity::new(b"idA"),
&Identity::new(b"idB"),
);
let mut msg2 = Vec::<u8>::with_capacity(msg1.len() + 1);
msg2.resize(msg1.len() + 1, 0u8);
let r = s1.finish(&msg2);
assert_eq!(
r.unwrap_err(),
SPAKEErr {
kind: ErrorType::WrongLength,
}
);
}

#[test]
fn test_basic_symmetric() {
let (s1, msg1) = SPAKE2::<Ed25519Group>::start_symmetric(
&Password::new(b"password"),
&Identity::new(b"idS"),
);
let (s2, msg2) = SPAKE2::<Ed25519Group>::start_symmetric(
&Password::new(b"password"),
&Identity::new(b"idS"),
);
let key1 = s1.finish(msg2.as_slice()).unwrap();
let key2 = s2.finish(msg1.as_slice()).unwrap();
assert_eq!(key1, key2);
}

#[test]
fn it_works() {}

#[test]
#[should_panic(expected = "nope")]
fn it_panics() {
assert!(false, "nope");
}
}
Loading