Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/crypto/argon2: hash differs from C++ implementation #29976

Closed
phifty opened this issue Jan 29, 2019 · 2 comments
Closed

x/crypto/argon2: hash differs from C++ implementation #29976

phifty opened this issue Jan 29, 2019 · 2 comments

Comments

@phifty
Copy link

phifty commented Jan 29, 2019

What version of Go are you using (go version)?

$ go version
1.11 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/philipp/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/philipp/go"
GOPROXY=""
GORACE=""
GOROOT="/nix/store/786qm6ljn16g6q913kv6dgzl6yma8i61-go-1.11/share/go"
GOTMPDIR=""
GOTOOLDIR="/nix/store/786qm6ljn16g6q913kv6dgzl6yma8i61-go-1.11/share/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/philipp/go/src/github.com/simia-tech/crypt/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build759245311=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Generated a Argon2i hash with parameters:

type = Argon2i
password = "password" (hex 70617373776f7264)
salt = "longsaltlongsalt" (hex 6c6f6e6773616c746c6f6e6773616c74)
m = 65536
t = 3
p = 1

What did you expect to see?

hash = cc3528e2fb0b3c289bb1a25052498fd82600ad5a372b2c6206894f2308b52717 (hex)

I generated this hash with the C++ implementation at https://github.com/khovratovich/Argon2 using the same parameters as above. I double-checked all the input parameters and it seems that the implementations differs in some way. I'm not sure which one is correct.

What did you see instead?

hash = 2b6acb7d5a101b5ecbb949f6ea8b5ab135f55815e3afa862e4d65728ac6662bb (hex)
@gopherbot gopherbot added this to the Unreleased milestone Jan 29, 2019
@AlexRouSg
Copy link
Contributor

The official reference implementation is https://github.com/P-H-C/phc-winner-argon2

Running with the following args:
echo -n "password" | ./argon2 longsaltlongsalt -t 3 -m 16 -p 1
-m is 2^N so -m 16 == 65536

Gives the result:

Type: Argon2i  
Iterations: 3 
Memory: 65536 KiB
Parallelism: 1                                                                
Hash: 2b6acb7d5a101b5ecbb949f6ea8b5ab135f55815e3afa862e4d65728ac6662bb 
Encoded: $argon2i$v=19$m=65536,t=3,p=1$bG9uZ3NhbHRsb25nc2FsdA$K2rLfVoQG17LuUn26otasTX1WBXjr6hi5NZXKKxmYrs
Verification ok

@phifty
Copy link
Author

phifty commented Jan 29, 2019

Thanks for the hint. It seems than that the other implementation is broken. I'll close the issue.

@phifty phifty closed this as completed Jan 29, 2019
@golang golang locked and limited conversation to collaborators Jan 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants