-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: added documentation for each subpackage
- Loading branch information
Showing
14 changed files
with
582 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# PHC Crypto - Argon2 | ||
|
||
[![Go Reference](https://pkg.go.dev/badge/github.com/aldy505/phc-crypto.svg)](https://pkg.go.dev/github.com/aldy505/phc-crypto/argon2) | ||
|
||
According to [Wikipedia](https://en.wikipedia.org/wiki/Argon2): | ||
|
||
Argon2 is a key derivation function that was selected as the winner of the Password Hashing Competition in July 2015. It was designed by Alex Biryukov, Daniel Dinu, and Dmitry Khovratovich from the University of Luxembourg. The reference implementation of Argon2 is released under a Creative Commons CC0 license (i.e. public domain) or the Apache License 2.0, and provides three related versions: | ||
|
||
* Argon2d maximizes resistance to GPU cracking attacks. It accesses the memory array in a password dependent order, which reduces the possibility of time–memory trade-off (TMTO) attacks, but introduces possible side-channel attacks. | ||
* Argon2i is optimized to resist side-channel attacks. It accesses the memory array in a password independent order. | ||
* Argon2id is a hybrid version. It follows the Argon2i approach for the first half pass over memory and the Argon2d approach for subsequent passes. The Internet draft recommends using Argon2id except when there are reasons to prefer one of the other two modes. | ||
|
||
All three modes allow specification by three parameters that control: | ||
|
||
* execution time | ||
* memory required | ||
* degree of parallelism | ||
|
||
## Configuration options | ||
|
||
| Key | Type | Default | Notes | ||
|---|---|---|---| | ||
| Time | `int` | 32768 | Number of iterations to perform | | ||
| Memory | `int` | 8 | Amount of memory (in kilobytes) to use | | ||
| Parallelism | `int` | 4 | Parallelism factor (threads to run in parallel). | | ||
| KeyLen | `int` | 64 | How many bytes to generate as output. | | ||
| Variant | `string` | id | Argon2 variant to be used (`id` or `i`)| | ||
|
||
## Usage with PHC Crypto | ||
|
||
```bash | ||
$ go get github.com/aldy505/phc-crypto | ||
``` | ||
|
||
```go | ||
import ( | ||
"fmt" | ||
"github.com/aldy505/phc-crypto" | ||
) | ||
|
||
func main() { | ||
crypto, err := phccrypto.Use("argon2", phccrypto.Config{ | ||
Parallelism: 3, | ||
Variant: "i", | ||
}) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
hash, err := phccrypto.Hash("password") | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
fmt.Println(hash) // $argon2i$v=19$m=65536,t=16,p=3$8400b4e5f01f30092b794de34c61a6fdfea6b6b446560fda08a876bd11e9c62e$3fd77927d189... | ||
|
||
verify, err := phccrypto.Verify(hash, "password") | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
fmt.Println(verify) // true | ||
} | ||
``` | ||
|
||
## Standalone usage | ||
|
||
```bash | ||
$ go get github.com/aldy505/phc-crypto/argon2 | ||
``` | ||
|
||
```go | ||
import ( | ||
"fmt" | ||
"github.com/aldy505/phc-crypto/argon2" | ||
) | ||
|
||
func main() { | ||
|
||
hash, err := argon2.Hash("password", argon2.Config{ | ||
Parallelism: 3, | ||
Variant: "i", | ||
}) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
fmt.Println(hash) // $argon2i$v=19$m=65536,t=16,p=3$8400b4e5f01f30092b794de34c61a6fdfea6b6b446560fda08a876bd11e9c62e$3fd77927d189... | ||
|
||
verify, err := argon2.Verify(hash, "password") | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
fmt.Println(verify) // true | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# PHC Crypto - Bcrypt | ||
|
||
[![Go Reference](https://pkg.go.dev/badge/github.com/aldy505/phc-crypto.svg)](https://pkg.go.dev/github.com/aldy505/phc-crypto/bcrypt) | ||
|
||
According to [Wikipedia](https://en.wikipedia.org/wiki/Bcrypt): | ||
|
||
bcrypt is a password-hashing function designed by Niels Provos and David Mazières, based on the Blowfish cipher and presented at USENIX in 1999. Besides incorporating a salt to protect against rainbow table attacks, bcrypt is an adaptive function: over time, the iteration count can be increased to make it slower, so it remains resistant to brute-force search attacks even with increasing computation power. | ||
|
||
## Configuration options | ||
|
||
| Key | Type | Default | Notes | ||
|---|---|---|---| | ||
| Rounds | `int` | 10 | Cost of rounds, minimum of 4, maximum of 31. | | ||
|
||
|
||
## Usage with PHC Crypto | ||
|
||
```bash | ||
$ go get github.com/aldy505/phc-crypto | ||
``` | ||
|
||
```go | ||
import ( | ||
"fmt" | ||
"github.com/aldy505/phc-crypto" | ||
) | ||
|
||
func main() { | ||
crypto, err := phccrypto.Use("bcrypt", phccrypto.Config{ | ||
Rounds: 20, | ||
}) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
hash, err := phccrypto.Hash("password") | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
fmt.Println(hash) // $bcrypt$v=0$r=12$$2432612431322479356256373563666e503557... | ||
|
||
verify, err := phccrypto.Verify(hash, "password") | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
fmt.Println(verify) // true | ||
} | ||
``` | ||
|
||
## Standalone usage | ||
|
||
```bash | ||
$ go get github.com/aldy505/phc-crypto/bcrypt | ||
``` | ||
|
||
```go | ||
import ( | ||
"fmt" | ||
"github.com/aldy505/phc-crypto/bcrypt" | ||
) | ||
|
||
func main() { | ||
|
||
hash, err := bcrypt.Hash("password", bcrypt.Config{ | ||
Rounds: 12, | ||
}) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
fmt.Println(hash) // $bcrypt$v=0$r=12$$2432612431322479356256373563666e503557... | ||
|
||
verify, err := bcrypt.Verify(hash, "password") | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
fmt.Println(verify) // true | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.