Skip to content

Commit

Permalink
Merge pull request #9 from dwin/#6_CI-Improvement
Browse files Browse the repository at this point in the history
#6 ci improvement
  • Loading branch information
dwin authored Dec 11, 2020
2 parents 70d5ea0 + da3de3e commit f93294c
Show file tree
Hide file tree
Showing 11 changed files with 305 additions and 153 deletions.
32 changes: 22 additions & 10 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,31 @@ steps:
- name: build-alpine_latest
image: golang:alpine
pull: always
environment:
GOFLAGS: -mod=readonly
commands:
- go build -race -v .

- name: test-1.11-alpine
image: golang:1.11-alpine
- name: test-1.13-alpine
image: golang:1.13-alpine
commands:
- apk add --update bash build-base
- go test ./...
- apk add --update bash build-base git
- go get
- scripts/go_coverage.sh

- name: test-1.12-alpine
image: golang:1.12-alpine3.9
- name: test-1.14-alpine
image: golang:1.14-alpine
commands:
- apk add --update bash build-base
- go test ./...
- apk add --update bash build-base git
- go get
- scripts/go_coverage.sh

- name: test-1.15-alpine
image: golang:1.15-alpine
commands:
- apk add --update bash build-base git
- go get
- scripts/go_coverage.sh

- name: test-alpine_latest
image: golang:alpine
Expand All @@ -31,7 +42,8 @@ steps:
- name: cache
path: /tmp/cache
commands:
- apk add --update bash build-base
- apk add --update bash build-base git
- go get
- go test -coverprofile=/tmp/cache/coverage.txt -covermode=atomic ./...

- name: coverage
Expand All @@ -48,4 +60,4 @@ steps:

volumes:
- name: cache
temp: {}
temp: {}
51 changes: 51 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
linters-settings:
errcheck:
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
check-type-assertions: true
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: true
lll:
# max line length, lines longer will be reported.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
line-length: 180
# tab width in spaces. Default to 1.
tab-width: 1
govet:
check-shadowing: true
golint:
min-confidence: 0
gocyclo:
min-complexity: 30
maligned:
suggest-new: true
dupl:
threshold: 50
goconst:
min-len: 2
min-occurrences: 3

misspell:
locale: US

goimports:
local-prefixes: github.com/golangci/golangci-lint
gocritic:
enabled-tags:
- performance
- style
- experimental
disabled-checks:
- wrapperFunc

linters:
enable-all: true
disable:
- gochecknoglobals
- testpackage

run:
modules-download-mode: vendor
skip-dirs:
- example
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
language: go

go:
- 1.x
- "1.12"
- "1.13"
- "1.14"
- "1.15"
- master

os:
- linux

Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# goArgonPass

[![GoDoc](https://godoc.org/github.com/dwin/goArgonPass?status.svg)](https://godoc.org/github.com/dwin/goArgonPass)
[![cover.run](https://cover.run/go/github.com/dwin/goArgonPass.svg?style=flat&tag=golang-1.10)](https://cover.run/go?tag=golang-1.10&repo=github.com%2Fdwin%2FgoArgonPass)
[![Build Status](https://travis-ci.org/dwin/goArgonPass.svg?branch=master)](https://travis-ci.org/dwin/goArgonPass)
[![Coverage Status](https://coveralls.io/repos/github/dwin/goArgonPass/badge.svg?branch=master)](https://coveralls.io/github/dwin/goArgonPass?branch=master)
[![codecov](https://codecov.io/gh/dwin/goArgonPass/branch/master/graph/badge.svg)](https://codecov.io/gh/dwin/goArgonPass)
[![Go Report Card](https://goreportcard.com/badge/github.com/dwin/goArgonPass)](https://goreportcard.com/report/github.com/dwin/goArgonPass)
[![CodeFactor](https://www.codefactor.io/repository/github/dwin/goargonpass/badge)](https://www.codefactor.io/repository/github/dwin/goargonpass)

Travis:

[![Travis Build Status](https://travis-ci.org/dwin/goArgonPass.svg?branch=master)](https://travis-ci.org/dwin/goArgonPass)

Drone:

[![Drone Build Status](https://drone.github.dlsmi.com/api/badges/dwin/goArgonPass/status.svg)](https://drone.github.dlsmi.com/dwin/goArgonPass)

Master:
[![Build Status](https://drone.github.dlsmi.com/api/badges/dwin/goArgonPass/status.svg)](https://drone.github.dlsmi.com/dwin/goArgonPass)
[![codecov](https://codecov.io/gh/dwin/goArgonPass/branch/master/graph/badge.svg)](https://codecov.io/gh/dwin/goArgonPass)

Dev:
[![Build Status](https://drone.github.dlsmi.com/api/badges/dwin/goArgonPass/status.svg?ref=/refs/heads/dev)](https://drone.github.dlsmi.com/dwin/goArgonPass)
[![codecov](https://codecov.io/gh/dwin/goArgonPass/branch/dev/graph/badge.svg)](https://codecov.io/gh/dwin/goArgonPass)

**_All hashing and crypto is done by Go library packages. This is only a utility package to make the process described easier._**

Expand All @@ -39,15 +40,15 @@ import (
"fmt"
"os"

"github.com/dwin/goArgonPass"
argonpass "github.com/dwin/goArgonPass"
)

func main() {
// Obtain user password from form or other input
userPassInput := "password"

// Hash with Default Parameters
hash, err := argonpass.Hash(userPassInput)
hash, err := argonpass.Hash(userPassInput, nil)
if err != nil {
// Handle Error
os.Exit(1)
Expand Down
21 changes: 21 additions & 0 deletions benchmark.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package argonpass

import "time"

// Benchmark takes ArgonParams and returns the number of seconds elapsed as a float64 and error.
func Benchmark(params *ArgonParams) (elapsed float64, err error) {
pass := "benchmarkpass"
start := time.Now()

salt, err := generateSalt(params.SaltSize)
if err != nil {
return elapsed, err
}

_, err = generateHash([]byte(pass), salt, params)

t := time.Now()
dur := t.Sub(start)

return dur.Seconds(), err
}
38 changes: 19 additions & 19 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@ package argonpass
import "errors"

var (
// ErrPassphraseInputTooShort indicates the passphrase was less than 8 characters
ErrPassphraseInputTooShort = errors.New("Passphrase Input too short, must be >= 8 characters")
// ErrPassphraseInputTooShort indicates the passphrase was less than 8 characters.
ErrPassphraseInputTooShort = errors.New("passphrase input too short, must be >= 8 characters")

// ErrVersion indicates the version could not be found in hash string or version of hash is
// greater than current package version and is incompatible
ErrVersion = errors.New("Unable to parse version or incorrect version")
// greater than current package version and is incompatible.
ErrVersion = errors.New("unable to parse version or incorrect version")

// ErrFunctionMismatch indicates the function does not match a supported Argon2 function of 'i' or 'id'
ErrFunctionMismatch = errors.New("Function of hash is invalid, must be 'argon2i' or 'argon2id'")
// ErrFunctionMismatch indicates the function does not match a supported Argon2 function of 'i' or 'id'.
ErrFunctionMismatch = errors.New("function of hash is invalid, must be 'argon2i' or 'argon2id'")

// ErrDecodingSalt indicates there was an issue converting the expected base64 salt to bytes
ErrDecodingSalt = errors.New("Unable to decode salt base64 to byte")
// ErrDecodingSalt indicates there was an issue converting the expected base64 salt to bytes.
ErrDecodingSalt = errors.New("unable to decode salt base64 to byte")

// ErrDecodingDigest indicates there was an issue converting the expected base64 hash digest to bytes
ErrDecodingDigest = errors.New("Unable to decode passhash digest base64 to byte")
// ErrDecodingDigest indicates there was an issue converting the expected base64 hash digest to bytes.
ErrDecodingDigest = errors.New("unable to decode passhash digest base64 to byte")

// ErrParseTime indicates there was an issue parsing the time parameter from the hash
// input string, possibly was not expected integer value
ErrParseTime = errors.New("Unable to parse time parameter")
// input string, possibly was not expected integer value.
ErrParseTime = errors.New("unable to parse time parameter")

// ErrParseMemory indicates there was an issue parsing the memory parameter from the hash
// input string, possibly was not expected integer value
ErrParseMemory = errors.New("Unable to parse memory parameter")
// input string, possibly was not expected integer value.
ErrParseMemory = errors.New("unable to parse memory parameter")

// ErrParseParallelism indicates there was an issue parsing the parallelism parameter from the hash
// input string, possibly was not expected integer value
ErrParseParallelism = errors.New("Unable to parse parallelism/threads parameter")
// input string, possibly was not expected integer value.
ErrParseParallelism = errors.New("unable to parse parallelism/threads parameter")

// ErrHashMismatch indicates the Argon2 digest regenerated using the hash input string salt
// and user password input did not produce a matching value. Passphrase input does not match
// hash string input.
ErrHashMismatch = errors.New("Unable to verify passphrase input with given hash value")
ErrHashMismatch = errors.New("unable to verify passphrase input with given hash value")

// ErrInvalidHashFormat indicates the hash string input does not match specified format,
// example: '$argon2{function(i/id)}$v={version}$m={memory},t={time},p={parallelism}${salt(base64)}${digest(base64)}'
ErrInvalidHashFormat = errors.New("Invalid hash input string format")
// example: '$argon2{function(i/id)}$v={version}$m={memory},t={time},p={parallelism}${salt(base64)}${digest(base64)}'.
ErrInvalidHashFormat = errors.New("invalid hash input string format")
)
13 changes: 8 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
module github.com/dwin/goArgonPass

go 1.12
go 1.14

require (
github.com/corpix/uarand v0.1.1 // indirect
github.com/icrowley/fake v0.0.0-20180203215853-4178557ae428
github.com/stretchr/testify v1.4.0
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/stretchr/testify v1.6.1
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9
golang.org/x/sys v0.0.0-20201211002650-1f0c578a6b29 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
)
57 changes: 30 additions & 27 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
github.com/Masterminds/glide v0.13.2/go.mod h1:STyF5vcenH/rUqTEv+/hBXlSTo7KYwg2oc2f4tzPWic=
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/vcs v1.13.0/go.mod h1:N09YCmOQr6RLxC6UNHzuVwAdodYbbnycGHSmwVJjcKA=
github.com/codegangsta/cli v1.20.0/go.mod h1:/qJNoX69yVSKu5o4jLyXAENLRyk1uhi7zkbQ3slBdOA=
github.com/corpix/uarand v0.0.0 h1:mNbzro1GwUcZ1hmO2rWXytkR3JBxNxxctzjyuhO+Aig=
github.com/corpix/uarand v0.0.0/go.mod h1:JSm890tOkDN+M1jqN8pUGDKnzJrsVbJwSMHBY4zwz7M=
github.com/corpix/uarand v0.1.1 h1:RMr1TWc9F4n5jiPDzFHtmaUXLKLNUFK0SgCLo4BhX/U=
github.com/corpix/uarand v0.1.1/go.mod h1:SFKZvkcRoLqVRFZ4u25xPmp6m9ktANfbpXZ7SJ0/FNU=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dwin/goArgonPass v1.0.2 h1:2Ch3rgZjnCYwkOekOuaUQOx1f9YcJSJYLnOKbujIdDQ=
github.com/dwin/goArgonPass v1.0.2/go.mod h1:T0VQwYR/zZzz49GW6BwAeb9dNNPxeTFhMZtYQOG411s=
github.com/icrowley/fake v0.0.0-20180203215853-4178557ae428 h1:Mo9W14pwbO9VfRe+ygqZ8dFbPpoIK1HFrG/zjTuQ+nc=
github.com/icrowley/fake v0.0.0-20180203215853-4178557ae428/go.mod h1:uhpZMVGznybq1itEKXj6RYw9I71qK4kH+OGMjRC4KEo=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/ngdinhtoan/glide-cleanup v0.2.0/go.mod h1:UQzsmiDOb8YV3nOsCxK/c9zPpCZVNoHScRE3EO9pVMM=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.1 h1:52QO5WkIUcHGIR7EnGagH88x1bUzqGXTC5/1bDTUQ7U=
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/crypto v0.0.0-20180606015541-b47b15873692 h1:O9W34I8ef1ifsNUjJoqTsouE17HSL5RVJNn9pLMf7Og=
golang.org/x/crypto v0.0.0-20180606015541-b47b15873692/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/sys v0.0.0-20180525142821-c11f84a56e43 h1:PvnWIWTbA7gsEBkKjt0HV9hckYfcqYv8s/ju7ArZ0do=
golang.org/x/sys v0.0.0-20180525142821-c11f84a56e43/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 h1:sYNJzB4J8toYPQTM6pAkcmBRgw9SnQKP9oXCHfgy604=
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201211002650-1f0c578a6b29 h1:hAYi5mzhvBeCfkgaIHGZ8R+Q04WjSW5ZvQO3BZ94dHY=
golang.org/x/sys v0.0.0-20201211002650-1f0c578a6b29/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading

0 comments on commit f93294c

Please sign in to comment.