Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
samscott89 committed Jan 21, 2019
2 parents 41e7120 + 9428f9d commit 6a7bcd9
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 195 deletions.
37 changes: 20 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ cache: cargo
dist: trusty
os:
- linux
# - osx
- osx

# Run builds for all the supported trains
rust:
- stable
- beta
- nightly

sudo: true

env:
global:
- RUSTFLAGS="-C link-dead-code"

before_install:
- sudo apt-get update

addons:
apt:
packages:
- libssl-dev
matrix:
include:
- rust: stable
os: linux
sudo: true
env: SKIPTEST=true RUSTFLAGS="-C link-dead-code"
before_install:
- sudo apt-get update
addons:
apt:
packages:
- libssl-dev

# Add clippy
before_script:
Expand All @@ -36,18 +36,21 @@ before_script:

# The main build
script:
- cargo build
- cargo test
- |
if [[ -z $SKIPTEST ]]; then
cargo build
cargo test
make test
fi
- |
if [[ "$TRAVIS_RUST_VERSION" == "nightly" && $CLIPPY ]]; then
cargo clippy
fi
- make test
# Coverage report
after_success:
- |
if [[ "$TRAVIS_RUST_VERSION" == stable ]]; then
if [[ "$TRAVIS_RUST_VERSION" == "stable" && "$TRAVIS_OS_NAME" = linux ]]; then
bash <(curl https://raw.githubusercontent.com/xd009642/tarpaulin/master/travis-install.sh)
# Uncomment the following line for coveralls.io
# cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID
Expand Down
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ repository = "https://github.com/libpasta/libpasta"
argon2rs = "0.2.5"
data-encoding = "2.1.2"
error-chain = "0.12.0"
fastpbkdf2 = "0.1.0"
itertools = "0.8.0"
lazy_static = "1.2.0"
log = "0.4.6"
num-traits = "0.2.6"
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
VERSION = 0.1.0-rc0
VERSION = 0.1.0-rc1

all: libpasta.so libpasta.a

clean:
cargo clean --manifest-path libpasta-capi/Cargo.toml
rm -rf build/

force:
Expand All @@ -11,7 +12,7 @@ force:
make all

libpasta: Cargo.toml libpasta-capi/Cargo.toml
cargo build --release --manifest-path libpasta-capi/Cargo.toml
RUSTFLAGS="--print native-static-libs" cargo build --release --manifest-path libpasta-capi/Cargo.toml

libpasta.%: libpasta
mkdir -p build
Expand Down
4 changes: 2 additions & 2 deletions libpasta-capi/ctest/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
set -ex

cargo build --release --manifest-path ../Cargo.toml
gcc -DDEBUG -ggdb -o test_c test.c -Wall -I../include -L../target/release/ -lpasta
g++ -DDEBUG -std=c++11 -ggdb -o test_cpp test.cpp -Wall -I../include -L../target/release/ -lpasta
${CC:="gcc"} -DDEBUG -ggdb -o test_c test.c -Wall -I../include -L../target/release/ -lpasta
${CXX:="g++"} -DDEBUG -std=c++11 -ggdb -o test_cpp test.cpp -Wall -I../include -L../target/release/ -lpasta
6 changes: 4 additions & 2 deletions libpasta-capi/include/pasta-bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ typedef struct {
};
} HashUpdateFfi;

void config_free(Config *config);

char *config_hash_password(const Config *config, const char *password);

HashUpdateFfi *config_migrate_hash(const Config *config, const char *hash);

Config *config_new(void);

bool config_verify_password(const Config *config, const char *hash, const char *password);

HashUpdateFfi *config_verify_password_update_hash(const Config *config,
Expand All @@ -58,8 +62,6 @@ Primitive *default_pbkdf2i(void);

Primitive *default_scrypt(void);

void free_Config(Config *config);

void free_Primitive(Primitive *prim);

void free_string(char *s);
Expand Down
6 changes: 4 additions & 2 deletions libpasta-capi/include/pasta-bindings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ struct HashUpdateFfi {

extern "C" {

void config_free(Config *config);

char *config_hash_password(const Config *config, const char *password);

HashUpdateFfi *config_migrate_hash(const Config *config, const char *hash);

Config *config_new();

bool config_verify_password(const Config *config, const char *hash, const char *password);

HashUpdateFfi *config_verify_password_update_hash(const Config *config,
Expand All @@ -55,8 +59,6 @@ Primitive *default_pbkdf2i();

Primitive *default_scrypt();

void free_Config(Config *config);

void free_Primitive(Primitive *prim);

void free_string(char *s);
Expand Down
14 changes: 9 additions & 5 deletions libpasta-capi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ pub extern fn hash_password(password: *const c_char) -> *mut c_char {
CString::new(output).unwrap().into_raw()
}

#[no_mangle]
pub extern "C" fn config_new() -> *mut Config {
box_ptr!(Config::default())
}

#[no_mangle]
pub extern "C" fn config_free(config: *mut Config) {
let _config = unsafe { ffi_ref!(config) };
}

#[no_mangle]
pub extern "C" fn config_hash_password(config: *const Config, password: *const c_char) -> *mut c_char {
Expand Down Expand Up @@ -183,11 +192,6 @@ pub extern "C" fn free_Primitive(prim: *mut Primitive) {
let _prim = unsafe { ffi_ref!(prim) };
}

#[no_mangle]
pub extern "C" fn free_Config(config: *mut Config) {
let _config = unsafe { ffi_ref!(config) };

}

#[cfg(test)]
mod test {
Expand Down
6 changes: 3 additions & 3 deletions src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ macro_rules! benches {

#[bench]
fn short(b: &mut Bencher) {
let password = "hunter2*********".to_owned();
let password = "hunter2*********";
let alg = Algorithm::Single(<$params>::default().into());
println!("Bench params: {:?}", alg);
b.iter(|| {
alg.hash(password.clone().into())
alg.hash(password)
})
}

Expand All @@ -30,7 +30,7 @@ macro_rules! benches {
let alg = Algorithm::Single(<$params>::default().into());
println!("Bench params: {:?}", alg);
b.iter(|| {
alg.hash(password.clone().into())
alg.hash(&password)
})
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
//! `libpasta` attempts to support some legacy formats. For example, the `bcrypt`
//! format `$2y$...`.

#![cfg_attr(all(feature="bench", test), feature(test))]


#![allow(unknown_lints)]
#![deny(clippy::pedantic)]
#![allow(
Expand Down Expand Up @@ -93,9 +90,10 @@
unused_unsafe,
unused_variables,
variant_size_differences,
warnings,
while_true,
)]
// Necessary for having benchmarks defined inline.
#![cfg_attr(all(feature="bench", test), feature(test))]
#![cfg_attr(all(feature="bench", test), allow(unstable_features))]

extern crate data_encoding;
Expand Down Expand Up @@ -332,9 +330,11 @@ mod api_tests {
fn nested_hash() {
let password = "hunter2";

let fast_prim = Bcrypt::new(5);

let params = Algorithm::Nested {
inner: Box::new(Algorithm::default()),
outer: DEFAULT_PRIM.clone(),
inner: Box::new(Algorithm::Single(fast_prim.clone())),
outer: fast_prim.clone(),
};
let hash = params.hash(&password);

Expand Down Expand Up @@ -372,7 +372,7 @@ mod api_tests {
fn migrate() {
let password = "hunter2";

let params = Algorithm::Single(Bcrypt::default());
let params = Algorithm::Single(Bcrypt::new(5));
let mut hash = serde_mcf::to_string(&params.hash(&password)).unwrap();
println!("Original: {:?}", hash);
if let Some(new_hash) = migrate_hash(&hash) {
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub use self::hmac::Hmac;
/// Implementations are from both `ring` and the C `fastpbkdf2` implementations.
/// The latter is currently in use.
mod pbkdf2;
pub use self::pbkdf2::{Pbkdf2, RingPbkdf2};
pub use self::pbkdf2::Pbkdf2;

/// `Scrypt` implementations.
///
Expand Down

0 comments on commit 6a7bcd9

Please sign in to comment.