Skip to content

Commit

Permalink
Add salt size flag to pw.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ignacio Gómez committed Nov 15, 2019
1 parent cbed8af commit 073dbe5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,21 @@ Individual backends have their options described in the sections below.

### Files

The `files` backend implements the regular password and acl checks as described in mosquitto. Passwords should be in PBKDF2 format (for other backends too), and may be generated using the `pw` utility (built by default when running `make`) included in the plugin (or one of your own). Check pw-gen dir for `pw` flags.
The `files` backend implements the regular password and acl checks as described in mosquitto. Passwords should be in PBKDF2 format (for other backends too), and may be generated using the `pw` utility (built by default when running `make`) included in the plugin (or one of your own). Passwords may also be tested using the [pw-test package](https://github.com/iegomez/pw-test).

Usage of `pw`:

```
Usage of ./pw:
-a string
algorithm: sha256 or sha512 (default "sha512")
-i int
hash iterations (default 100000)
-p string
password
-s int
salt size (default 16)
```

For this backend passwords and acls file paths must be given:

Expand Down
12 changes: 5 additions & 7 deletions pw-gen/pw.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ import (
"github.com/iegomez/mosquitto-go-auth/common"
)

// saltSize defines the salt size
const saltSize = 16

func main() {

var algorithm = flag.String("a", "sha512", "algorithm (sha256 or default: sha512)")
var HashIterations = flag.Int("i", 100000, "hash iterations (default: 100000)")
var algorithm = flag.String("a", "sha512", "algorithm: sha256 or sha512")
var HashIterations = flag.Int("i", 100000, "hash iterations")
var password = flag.String("p", "", "password")
var saltSize = flag.Int("s", 16, "salt size")

flag.Parse()

pwHash, err := common.Hash(*password, saltSize, *HashIterations, *algorithm)
pwHash, err := common.Hash(*password, *saltSize, *HashIterations, *algorithm)
if err != nil {
fmt.Errorf("error: %s\n", err)
fmt.Printf("error: %s\n", err)
} else {
fmt.Println(pwHash)
}
Expand Down

0 comments on commit 073dbe5

Please sign in to comment.