Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 12 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
language: rust
cache: cargo # https://docs.travis-ci.com/user/caching/#Rust-Cargo-cache
cache:
directories:
- $HOME/.cargo
- $HOME/protobuf
- $TRAVIS_BUILD_DIR/target

rust:
- stable
Expand All @@ -20,7 +24,7 @@ matrix:
before_script:
- rustup component add rustfmt-preview
script:
- cargo fmt --all -- --write-mode=diff
- cargo fmt --all -- --check
- env: NAME='kcov'
sudo: required # travis-ci/travis-ci#9061
before_script:
Expand Down Expand Up @@ -48,3 +52,9 @@ script:
- cargo build --verbose --all-features
- cargo test --verbose --all-features
- cargo doc --verbose --all-features

before_install:
- export PATH=$PATH:$HOME/protobuf/bin
- export PROTOC_VERSION=$(cat PROTOC_VERSION)
- bash install_protobuf.sh

202 changes: 91 additions & 111 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ default = []
dss = []

[dependencies]
base64 = "0.9.0"
rand = "^0.4.2"
ring = "^0.12"
merkle_sigs = "^1.4"
base64 = "0.9.2"
rand = "0.5.5"
ring = "0.13.2"
merkle_sigs = "1.6"
protobuf = ">= 1.4, < 1.6"

[dependencies.error-chain]
version = "0.11.0"
version = "0.12.0"
default-features = false

[dev-dependencies]
Expand Down
1 change: 1 addition & 0 deletions PROTOC_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.5.1
24 changes: 24 additions & 0 deletions install_protobuf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -e
set -x

PROTOC_VERSION=$(cat PROTOC_VERSION)

check_protoc_version () {
this_version=`protoc --version`
return `[ "libprotoc $PROTOC_VERSION" = "$this_version" ]`
}

if check_protoc_version; then
echo $PROTOC_VERSION detected.
exit
fi

wget https://github.com/google/protobuf/archive/v$PROTOC_VERSION.tar.gz
tar -xzf v$PROTOC_VERSION.tar.gz
cd protobuf-$PROTOC_VERSION
./autogen.sh >/dev/null 2>&1
./configure --prefix=$HOME/protobuf >/dev/null 2>&1
make >/dev/null 2>&1
make install >/dev/null 2>&1

1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

8 changes: 5 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
//! `RustySecrets` implements Shamir's secret sharing in Rust. It provides the possibility to sign shares.

#![deny(missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts,
trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces,
unused_qualifications)]
#![deny(
missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts,
trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces,
unused_qualifications
)]
#![cfg_attr(feature = "cargo-clippy", allow(doc_markdown))]
// `error_chain!` can recurse deeply
#![recursion_limit = "1024"]
Expand Down
9 changes: 4 additions & 5 deletions src/sss/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ static HASH_ALGO: &'static Algorithm = &SHA512;
/// }
/// ```
pub fn split_secret(k: u8, n: u8, secret: &[u8], sign_shares: bool) -> Result<Vec<String>> {
let mut rng = OsRng::new().chain_err(|| ErrorKind::CannotGenerateRandomNumbers)?;
SSS::default()
.split_secret(&mut OsRng::new()?, k, n, secret, sign_shares)
.split_secret(&mut rng, k, n, secret, sign_shares)
.map(|shares| shares.into_iter().map(Share::into_string).collect())
}

Expand All @@ -52,12 +53,10 @@ pub fn split_secret(k: u8, n: u8, secret: &[u8], sign_shares: bool) -> Result<Ve
/// # extern crate rusty_secrets;
/// # extern crate rand;
/// #
/// # use rand::ChaChaRng;
/// # use rand::{OsRng, ChaChaRng, SeedableRng};
/// #
/// # fn some_custom_rng() -> ChaChaRng {
/// # let mut rng = ChaChaRng::new_unseeded();
/// # rng.set_counter(42, 42);
/// # rng
/// # ChaChaRng::from_rng(OsRng::new().unwrap()).unwrap()
/// # }
/// #
/// # fn main() {
Expand Down
3 changes: 2 additions & 1 deletion src/wrapped_secrets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ pub fn split_secret(
mime_type: Option<String>,
sign_shares: bool,
) -> Result<Vec<String>> {
let mut rng = OsRng::new().chain_err(|| ErrorKind::CannotGenerateRandomNumbers)?;
WrappedSecrets::default()
.split_secret(&mut OsRng::new()?, k, n, secret, mime_type, sign_shares)
.split_secret(&mut rng, k, n, secret, mime_type, sign_shares)
.map(|shares| shares.into_iter().map(Share::into_string).collect())
}

Expand Down