Skip to content

Commit

Permalink
[authutil] standardize argon2 dependency (#244)
Browse files Browse the repository at this point in the history
Co-authored-by: cviecco <cviecco@gmail.com>
  • Loading branch information
sethyes and cviecco authored Oct 29, 2024
1 parent da254f5 commit 2f98c62
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ require (
github.com/aws/aws-sdk-go-v2/service/sts v1.32.2
github.com/bearsh/hid v1.6.0
github.com/cloudflare/cfssl v1.6.5
github.com/cviecco/argon2 v0.0.0-20171122181119-1dc43e2eaa99
github.com/duo-labs/webauthn v0.0.0-20221205164246-ebaf9b74c6ec
github.com/flynn/u2f v0.0.0-20180613185708-15554eb68e5d
github.com/foomo/htpasswd v0.0.0-20200116085101-e3a90e78da9c
Expand Down Expand Up @@ -80,7 +79,6 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/boombuler/barcode v1.0.2 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dchest/blake2b v1.0.0 // indirect
github.com/flynn/hid v0.0.0-20190502022136-f1b9b6cc019a // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,11 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cviecco/argon2 v0.0.0-20171122181119-1dc43e2eaa99 h1:8co/GRKovq1R4wCidV2GrIf9FQ+2s0bV4IXulkzbkeI=
github.com/cviecco/argon2 v0.0.0-20171122181119-1dc43e2eaa99/go.mod h1:bhY/hbDzWD0J/Sr4zDxR9WaRilSZ06n+qMzGWUjU6yQ=
github.com/cyphar/filepath-securejoin v0.3.4 h1:VBWugsJh2ZxJmLFSM06/0qzQyiQX2Qs0ViKrUAcqdZ8=
github.com/cyphar/filepath-securejoin v0.3.4/go.mod h1:8s/MCNJREmFK0H02MF6Ihv1nakJe4L/w3WZLHNkvlYM=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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/dchest/blake2b v1.0.0 h1:KK9LimVmE0MjRl9095XJmKqZ+iLxWATvlcpVFRtaw6s=
github.com/dchest/blake2b v1.0.0/go.mod h1:U034kXgbJpCle2wSk5ybGIVhOSHCVLMDqOzcPEA0F7s=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/duo-labs/webauthn v0.0.0-20221205164246-ebaf9b74c6ec h1:darQ1FPPrwlzwmuN3fRMVCrsaCpuDqkKHADYzcMa73M=
Expand Down
14 changes: 3 additions & 11 deletions lib/authutil/authutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"strings"
"time"

"github.com/cviecco/argon2"
"github.com/foomo/htpasswd"
"golang.org/x/crypto/argon2"
"golang.org/x/crypto/bcrypt"
"gopkg.in/ldap.v2"
)
Expand Down Expand Up @@ -56,12 +56,8 @@ func Argon2MakeNewHash(password []byte) (string, error) {
if err != nil {
return "", err
}
key, err := argon2.Key(password, []byte(salt), argon2t, argon2p, argon2m, argon2l)
if err != nil {
return "", err
}
key := argon2.Key(password, []byte(salt), argon2t, argon2p, argon2m, argon2l)
return fmt.Sprintf("%s%s:%x", argon2dPrefix, salt, key), nil

}

// We only support argon2d as is the only pure golang implementation
Expand All @@ -73,11 +69,7 @@ func Argon2CompareHashAndPassword(hash string, password []byte) error {
splitHashString := strings.SplitN(hash, ":", 2)
hexKey := splitHashString[1]
salt := splitHashString[0][len(argon2dPrefix):]
//log.Printf("salt='%s' heykey=%s", salt, hexKey)
key, err := argon2.Key(password, []byte(salt), argon2t, argon2p, argon2m, argon2l)
if err != nil {
return err
}
key := argon2.Key(password, []byte(salt), argon2t, argon2p, argon2m, argon2l)
if hexKey == fmt.Sprintf("%x", key) {
return nil
}
Expand Down

0 comments on commit 2f98c62

Please sign in to comment.