libpasta 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +5 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +41 -0
  9. data/Rakefile +37 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/ext/Rakefile +9 -0
  13. data/ext/pasta-bindings/.gitmodules +3 -0
  14. data/ext/pasta-bindings/Makefile +84 -0
  15. data/ext/pasta-bindings/README.md +54 -0
  16. data/ext/pasta-bindings/libpasta/.gitignore +2 -0
  17. data/ext/pasta-bindings/libpasta/.travis.yml +60 -0
  18. data/ext/pasta-bindings/libpasta/Cargo.toml +42 -0
  19. data/ext/pasta-bindings/libpasta/LICENSE.md +21 -0
  20. data/ext/pasta-bindings/libpasta/Makefile +27 -0
  21. data/ext/pasta-bindings/libpasta/README.md +78 -0
  22. data/ext/pasta-bindings/libpasta/benches/bench.rs +125 -0
  23. data/ext/pasta-bindings/libpasta/examples/alternate_key_source.rs +33 -0
  24. data/ext/pasta-bindings/libpasta/examples/config.rs +10 -0
  25. data/ext/pasta-bindings/libpasta/examples/config_hmac.rs +25 -0
  26. data/ext/pasta-bindings/libpasta/examples/hash_password.rs +10 -0
  27. data/ext/pasta-bindings/libpasta/examples/migrate_password.rs +47 -0
  28. data/ext/pasta-bindings/libpasta/examples/verify_password.rs +24 -0
  29. data/ext/pasta-bindings/libpasta/libpasta-capi/Cargo.toml +12 -0
  30. data/ext/pasta-bindings/libpasta/libpasta-capi/ctest/compile +6 -0
  31. data/ext/pasta-bindings/libpasta/libpasta-capi/ctest/test +0 -0
  32. data/ext/pasta-bindings/libpasta/libpasta-capi/ctest/test.c +12 -0
  33. data/ext/pasta-bindings/libpasta/libpasta-capi/include/pasta.h +6 -0
  34. data/ext/pasta-bindings/libpasta/libpasta-capi/src/lib.rs +80 -0
  35. data/ext/pasta-bindings/libpasta/src/bench.rs +39 -0
  36. data/ext/pasta-bindings/libpasta/src/config.rs +358 -0
  37. data/ext/pasta-bindings/libpasta/src/hashing/de.rs +284 -0
  38. data/ext/pasta-bindings/libpasta/src/hashing/mod.rs +161 -0
  39. data/ext/pasta-bindings/libpasta/src/hashing/ser.rs +67 -0
  40. data/ext/pasta-bindings/libpasta/src/key/mod.rs +66 -0
  41. data/ext/pasta-bindings/libpasta/src/lib.rs +468 -0
  42. data/ext/pasta-bindings/libpasta/src/primitives/argon2.rs +180 -0
  43. data/ext/pasta-bindings/libpasta/src/primitives/bcrypt.rs +165 -0
  44. data/ext/pasta-bindings/libpasta/src/primitives/hmac.rs +134 -0
  45. data/ext/pasta-bindings/libpasta/src/primitives/mod.rs +312 -0
  46. data/ext/pasta-bindings/libpasta/src/primitives/pbkdf2.rs +272 -0
  47. data/ext/pasta-bindings/libpasta/src/primitives/scrypt.rs +144 -0
  48. data/ext/pasta-bindings/libpasta/src/sod.rs +46 -0
  49. data/ext/pasta-bindings/libpasta/tests/.libpasta.yaml +8 -0
  50. data/ext/pasta-bindings/libpasta/tests/common/mod.rs +37 -0
  51. data/ext/pasta-bindings/libpasta/tests/test_argon2.rs +8 -0
  52. data/ext/pasta-bindings/libpasta/tests/test_bcrypt.rs +8 -0
  53. data/ext/pasta-bindings/libpasta/tests/test_from_file.rs +13 -0
  54. data/ext/pasta-bindings/libpasta/tests/test_hmac.rs +26 -0
  55. data/ext/pasta-bindings/libpasta/tests/test_pbkdf2.rs +8 -0
  56. data/ext/pasta-bindings/libpasta/tests/test_ringpbkdf2.rs +8 -0
  57. data/ext/pasta-bindings/libpasta/tests/test_scrypt.rs +8 -0
  58. data/ext/pasta-bindings/pasta.i +31 -0
  59. data/ext/pasta-bindings/tests/Makefile +38 -0
  60. data/ext/pasta-bindings/tests/pasta_test.go +12 -0
  61. data/ext/pasta-bindings/tests/test.php +7 -0
  62. data/ext/pasta-bindings/tests/test.py +7 -0
  63. data/ext/pasta-bindings/tests/test.rb +5 -0
  64. data/lib/libpasta.rb +2 -0
  65. data/lib/libpasta/version.rb +3 -0
  66. data/libpasta.gemspec +52 -0
  67. data/spec/libpasta_spec.rb +11 -0
  68. data/spec/spec_helper.rb +11 -0
  69. metadata +183 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a216a2d4519b9c42bfcd8c5a30420c7566f5f42f
4
+ data.tar.gz: 8f298105caf41cae582685e12491dcd7394cae13
5
+ SHA512:
6
+ metadata.gz: 13768005bcf7bad34b7d86081b7d1dd7779db54309a260b8d14d2b7b1d6674ed02ba724335ed3c5f731dce175ee96a4cf433c6bf0e1762e9b595facbce05f7ff
7
+ data.tar.gz: ce2ca7324a29eb982e527497fd1b049df0a1923ffad65468c82331945dbdfb0321cd8b4dbd35e1be1394bd5cc0603fb2041156efee6538494f5e5cca8711dd58
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+
16
+ # rspec failure tracking
17
+ .rspec_status
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "ext/pasta-bindings"]
2
+ path = ext/pasta-bindings
3
+ url = https://github.com/libpasta/pasta-bindings/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.14.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in libpasta.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Sam Scott
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Libpasta
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/libpasta`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'libpasta'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install libpasta
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Sam Scott/libpasta.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require 'rake/clean'
4
+
5
+ CLOBBER.include('lib/*{.so,.bundle}')
6
+
7
+
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ task build: ["thermite:build", :build_ext]
11
+ task :default => [:clobber, :build, :spec]
12
+
13
+ require 'thermite/tasks'
14
+
15
+ Thermite::Tasks.new(cargo_project_path: "ext/pasta-bindings/libpasta/libpasta-capi/")
16
+
17
+ desc 'Run Rust & Ruby testsuites'
18
+ task test: ['thermite:build', 'thermite:test'] do
19
+ # …
20
+ end
21
+
22
+ desc 'Build the libpasta C extension'
23
+ task :build_ext do
24
+ # FileUtils.mv("#{config.ruby_extension_path}/pasta.so")
25
+ # rm "lib/pasta.so"
26
+ Dir.chdir("ext/pasta-bindings") do
27
+ sh "USE_STATIC=1 STATIC_LIBPASTA=libpasta/libpasta-capi/target/release/libpasta.a make ruby"
28
+ end
29
+ # cp "ext/pasta-bindings/libpasta.so", "lib/"
30
+ cp "ext/pasta-bindings/ruby/pasta.so", "lib/"
31
+ end
32
+
33
+ task :clean do
34
+ Dir.chdir("ext/pasta-bindings") do
35
+ sh "make clean"
36
+ end
37
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "libpasta"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/ext/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'thermite/tasks'
2
+
3
+ # This runs the cargo build project on libpasta-capi and produces
4
+ # lib/pasta.so (kind of annoyingly)
5
+ # If we already have a system lib we don't need this I guess
6
+ project_dir = File.dirname(File.dirname(__FILE__))
7
+ Thermite::Tasks.new(cargo_project_path: "#{project_dir}/ext/pasta-bindings/libpasta/libpasta-capi/", ruby_project_path: project_dir)
8
+ task default: %w(thermite:build)
9
+
@@ -0,0 +1,3 @@
1
+ [submodule "libpasta"]
2
+ path = libpasta
3
+ url = https://github.com/libpasta/libpasta
@@ -0,0 +1,84 @@
1
+ targets = java python php5 ruby
2
+
3
+ STATIC_LIBPASTA ?= ./libpasta/build/libpasta.a
4
+ SHARED_LIBPASTA ?= -lpasta
5
+ NATIVE_LIBS = -lpthread -l:libcrypto.so.1.0.0 -ldl -lm
6
+ SWIG = swig
7
+ OUTPUT_NAME = pasta.so
8
+ CC = gcc
9
+ CC_OPTS = -z noexecstack
10
+
11
+ BUILD_TYPE = release
12
+
13
+ PHP_VERSION ?= 56
14
+ export PHP_CONFIG = php-config${PHP_VERSION}
15
+ export PHP_BIN = php${PHP_VERSION}
16
+ PYTHON_VERSION ?= python2.7
17
+
18
+ go_SWIG_ARGS = -cgo -intgosize 64 -use-shlib -soname libpasta.so
19
+ javascript_SWIG_ARGS = -c++ -v8
20
+ java_SWIG_ARGS = -package io.github.libpasta
21
+ java_DIR = $(shell java -XshowSettings 2>&1 | grep java.home | grep '/usr/.*/' -o)
22
+ java_INCLUDES = -I$(java_DIR)include/ -I$(java_DIR)include/linux/
23
+ javascript_INCLUDES = -I/usr/include/node/
24
+ php_INCLUDE_DIR = $(shell $(PHP_CONFIG) --include-dir)
25
+ php5_INCLUDES = $(shell $(PHP_CONFIG) --includes)
26
+ python_INCLUDES = $(shell python2-config --includes)
27
+ ruby_INCLUDES = -I$(shell ruby -rrbconfig -e 'puts RbConfig::CONFIG[%q{rubyhdrdir}]') -I$(shell ruby -rrbconfig -e 'puts RbConfig::CONFIG[%q{rubyarchhdrdir}]')
28
+
29
+ all: libpasta-sync $(targets)
30
+
31
+ java: OUTPUT_DIR = META-INF/lib/linux_64
32
+ java: OUTPUT_NAME = libpasta_jni.so
33
+ javascript: CC = g++
34
+ python: OUTPUT_NAME = _pasta.so
35
+
36
+ $(targets): pasta.i
37
+ mkdir -p $@/$(OUTPUT_DIR)
38
+ $(SWIG) -$@ $($@_SWIG_ARGS) -outdir $@ -o $@/pasta_wrap.c pasta.i
39
+ $(CC) $(CC_OPTS) $@/pasta_wrap.c -fPIC -c -g $($@_INCLUDES) -o $@/pasta_wrap.o
40
+ ifdef USE_STATIC
41
+ $(CC) $(CC_OPTS) -static-libgcc -shared $@/pasta_wrap.o $(STATIC_LIBPASTA) -L/usr/lib/ $(NATIVE_LIBS) -o $@/$(OUTPUT_DIR)/$(OUTPUT_NAME)
42
+ else
43
+ $(CC) $(CC_OPTS) -shared $@/pasta_wrap.o $(SHARED_LIBPASTA) -o $@/$(OUTPUT_DIR)/$(OUTPUT_NAME) ${BUILD_OPTS}
44
+ endif
45
+
46
+ clean:
47
+ rm -rf $(targets)
48
+ make -C libpasta clean
49
+
50
+ force: clean
51
+ make -C libpasta force
52
+ make all
53
+
54
+ test: all
55
+ make -C tests/ c $(targets)
56
+
57
+ libpasta-sync:
58
+ git submodule update --init --recursive
59
+ ifneq ($(shell git -C libpasta/ rev-parse --abbrev-ref HEAD),master)
60
+ cd libpasta && git fetch && git checkout origin/master
61
+ endif
62
+
63
+ libpasta/build/libpasta.%:
64
+ make -C libpasta $(@F)
65
+
66
+ libpasta: libpasta-sync libpasta/build/libpasta.a libpasta/build/libpasta.so
67
+ ifndef USE_STATIC
68
+ make -C libpasta install
69
+ endif
70
+
71
+ PHP_INI=$(shell $(PHP_BIN) -i | grep -o '/etc/.*/php.ini')
72
+ PHPENMOD := $(shell command -v php${PHP_VERSION}enmod 2> /dev/null)
73
+
74
+ install_php: libpasta php5
75
+ sudo cp bindings/php5/pasta.so $(shell $(PHP_CONFIG) --extension-dir)/pasta.so
76
+ ifdef PHPENMOD
77
+ sudo $(PHPENMOD) pasta
78
+ else
79
+ (grep -qi pasta.so $(PHP_INI) && sudo sed -i 's/;extension=pasta.so/extension=pasta/' $(PHP_INI)) || \
80
+ (echo "extension=pasta.so" | sudo tee --append $(PHP_INI) > /dev/null)
81
+ endif
82
+
83
+
84
+ .PHONY: all clean force test libpasta-sync
@@ -0,0 +1,54 @@
1
+ Cross-language bindings for libpasta
2
+ ====================================
3
+
4
+ This library is intended for developers wishing to extend or improve the
5
+ existing language bindings for [libpasta](https://libpasta.github.io/).
6
+
7
+ For existing language bindings, and ways to install in those languages,
8
+ please see the information
9
+ [here](https://libpasta.github.io/other-languages/overview/).
10
+
11
+ SWIG and libpasta
12
+ ------------------
13
+
14
+ The language bindings produced here are through using
15
+ [SWIG](http://www.swig.org/).
16
+
17
+ The following logic is used to produce the language bindings:
18
+
19
+ We define the C header file in [pasta.h](./pasta.h) which corresponds to the
20
+ Rust definitions from the
21
+ [libpasta-capi](https://github.com/libpasta/libpasta/tree/master/libpasta-capi) crate (included as a
22
+ submodule for convenience).
23
+
24
+ This header file is now compatible with using SWIG, and the [pasta.i](./pasta.i)
25
+ file produces basic bindings with just the `%include <pasta.h>` line.
26
+
27
+ The rest of the [pasta.i](./pasta.i) file is dedicated to language-specific
28
+ requirements, and convenience code, such as automatically deallocating
29
+ the Rust `String` objects required to call the library.
30
+
31
+ We produce code for each support language using the [Makefile](./Makefile).
32
+ In general, this runs SWIG over the definition file to produce wrapper code,
33
+ and compiles it into a single `pasta.so` file (name depending on the language
34
+ and system preferences), and language-specific code to use this library.
35
+
36
+ Current Status
37
+ --------------
38
+
39
+ The entire libpasta project is still in an early phase. These bindings are
40
+ designed for ease of use, and early testing.
41
+
42
+ In the future, the goal is for libpasta to be a systems library, and thus
43
+ the default assumption is that `libpasta.so` is installed. This can
44
+ be tested with `ldconfig -p | grep libpasta`.
45
+
46
+ For initial ease of use, we also permit compiling libpasta statically, and
47
+ packaged into the produced wrapper library. This is not ideal, but effective
48
+ for early prototyping. To force use of the static compilation, make with the
49
+ `USE_STATIC` flag, e.g. `USE_STATIC=1 make ...`.
50
+
51
+ Currently these bindings are designed for `x86_64-unknown-linux-gnu`
52
+ (as per
53
+ [Rust platform support](https://forge.rust-lang.org/platform-support.html)),
54
+ but we are trying to increase support to other platforms.
@@ -0,0 +1,2 @@
1
+ target
2
+ Cargo.lock
@@ -0,0 +1,60 @@
1
+ ### Travis file built using https://medium.com/@Razican/continuous-integration-and-code-coverage-report-for-a-rust-project-5dfd4d68fbe5
2
+ language: rust
3
+ cache: cargo
4
+ dist: trusty
5
+ os:
6
+ - linux
7
+ # - osx
8
+
9
+ # Run builds for all the supported trains
10
+ rust:
11
+ - stable
12
+ - beta
13
+ - nightly
14
+
15
+ sudo: true
16
+
17
+ env:
18
+ global:
19
+ - RUSTFLAGS="-C link-dead-code"
20
+
21
+ before_install:
22
+ - sudo apt-get update
23
+
24
+ addons:
25
+ apt:
26
+ packages:
27
+ - libssl-dev
28
+
29
+ # Add clippy
30
+ before_script:
31
+ - |
32
+ if [[ "$TRAVIS_RUST_VERSION" == "nightly" ]]; then
33
+ ( ( cargo install clippy --force && export CLIPPY=true ) || export CLIPPY=false );
34
+ fi
35
+ - export PATH=$PATH:~/.cargo/bin
36
+
37
+ # The main build
38
+ script:
39
+ - cargo build
40
+ - cargo test
41
+ - |
42
+ if [[ "$TRAVIS_RUST_VERSION" == "nightly" && $CLIPPY ]]; then
43
+ cargo clippy
44
+ fi
45
+ - |
46
+ cargo build --verbose --manifest-path libpasta-capi/Cargo.toml
47
+ (cd libpasta-capi/ctest && sh compile && LD_LIBRARY_PATH=../target/debug ./test)
48
+
49
+ # Coverage report
50
+ after_success:
51
+ - |
52
+ if [[ "$TRAVIS_RUST_VERSION" == stable ]]; then
53
+ bash <(curl https://raw.githubusercontent.com/xd009642/tarpaulin/master/travis-install.sh)
54
+ # Uncomment the following line for coveralls.io
55
+ # cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID
56
+
57
+ # Uncomment the following two lines create and upload a report for codecov.io
58
+ travis_wait 30 cargo tarpaulin --out Xml
59
+ bash <(curl -s https://codecov.io/bash)
60
+ fi
@@ -0,0 +1,42 @@
1
+ [package]
2
+ name = "libpasta"
3
+ version = "0.0.5"
4
+ authors = ["Sam Scott <me@samjs.co.uk>"]
5
+ categories = ["authentication", "cryptography"]
6
+ description = "All-inclusive password hashing library"
7
+ documentation = "https://docs.rs/libpasta"
8
+ license = "MIT"
9
+ readme = "README.md"
10
+ repository = "https://github.com/libpasta/libpasta"
11
+
12
+ [dependencies]
13
+ argon2rs = "0.2"
14
+ cargon = "0.0.1"
15
+ data-encoding = "2.0.0"
16
+ error-chain = "0.11.0"
17
+ fastpbkdf2 = "0.1"
18
+ itertools = "0.7"
19
+ lazy_static = "1.0"
20
+ log = "0.3"
21
+ num-traits = "0.1"
22
+ ring-pwhash = ">= 0.11, < 0.13"
23
+ rpassword = "2.0"
24
+ rust-crypto = "0.2"
25
+ serde = "1.0.2"
26
+ serde_derive = "1.0.4"
27
+ serde_mcf = "0.1.3"
28
+ serde_yaml = "0.7"
29
+
30
+ [dependencies.ring]
31
+ version = ">= 0.11, < 0.13"
32
+ default-features = false
33
+ features = []
34
+
35
+ [dev-dependencies]
36
+ env_logger = "0.4"
37
+ time = "0.1.36"
38
+
39
+ [features]
40
+ bench = []
41
+ long_tests = []
42
+ simd = ["argon2rs/simd"]