Coder Social home page Coder Social logo

go-argon2's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-argon2's Issues

Building with path of argon2

Hoy hoy, is there a way not to have to make install argon2 (so that it gets into /usr), but just provide the path to the library?

I'm guessing the best way right now is to modify these:

// #cgo CFLAGS: -I/usr/include
// #cgo LDFLAGS: -L/usr/lib -largon2

in $GOPATH/src/github.com/tvdburgt/go-argon2/*.go

but then I get this error when trying to run go test in the library:

dyld: Library not loaded: @rpath/libargon2.dylib
  Referenced from: /var/folders/hh/2pwh6hxj7_vf8v89n2s74j2m0000gn/T/go-build726324610/github.com/tvdburgt/go-argon2/_test/go-argon2.test
  Reason: image not found
signal: abort trap
FAIL    github.com/tvdburgt/go-argon2   0.004s

(I'm on MAC)

PS: I suggest you add this to the README for easy copy/pasting ๐Ÿ˜›:

import "github.com/tvdburgt/go-argon2"

unimplemented: 64-bit mode not compiled

Hi,
i installed the minGW and download all packages and when i'm trying using this go Repository, I found this problem

cc1.exe: sorry, unimplemented: 64-bit mode not compiled in

So how to fix that

fails on go 1.6

go 1.6 has restrictions on pointer passing to C:

From: https://tip.golang.org/cmd/cgo/#hdr-Passing_pointers

Go code may pass a Go pointer to C provided the Go memory to which it points does not contain any Go pointers.

This results in the failure:

panic: runtime error: cgo argument has Go pointer to Go pointer

I have created a fork, https://github.com/bitmark-inc/go-argon2 to solve this problem.
However, I also removed git submodule and link to the shared version of the libargon2 using a more recent version with changed API (some functions and parameters were changed).

The main fix is to add wrapper.h that is used to pass all pointers as function parameter, create, use and destroy the C struct inside the wrapper so that the Go Garbage Collector can track them correctly.
Also this for is for FreeBSD.

Cannot use VerifyEncoded when mode is argon2id

Hey.

It's impossible to verify an encoded hash when using argon2id. I did some testing and it seems like it's related to the following code:

func getMode(s string) (int, error) {
	switch {
	case strings.HasPrefix(s, "$argon2d"):
		return ModeArgon2d, nil
	case strings.HasPrefix(s, "$argon2i"):
		return ModeArgon2i, nil
	case strings.HasPrefix(s, "$argon2id"):
		return ModeArgon2id, nil
	default:
		return -1, ErrDecodingFail
	}
}

"argon2id" also starts with "argon2i", so it's recognized as the wrong hash type, which will cause an error when calling C.argon2_verify

Running on Windows is impossible

Hi, the last time I tried to run go-argon2 on Windows I ended up porting the C code to pure Go. 2 versions have been released since that time and yet again I'm in need of a Go argon2 lib. Unfortunately I am not able to run the bindings without any changes on Windows - most of the issues are related to paths etc.

I "backported" (doesn't really make sense in this context, eh) the way the lib was included ~1yr ago and it works without any issues. Here's the code. This is also how mattn's go-sqlite3 works. Are you sure that the current usage method is the best way? Maybe the previous setup was better?

fatal error: 'argon2.h' file not found

After trying to install argon2 on macbook, i get message:
MacBook-Air:project-go admin$ go get

github.com/tvdburgt/go-argon2

../github.com/tvdburgt/go-argon2/argon2.go:12:11: fatal error: 'argon2.h' file not found
#include <argon2.h>
^~~~~~~~~~
1 error generated.
Is there any way to fix this?

Compatibility with golang.org/x/crypto/argon2 ?

Hi @tvdburgt,

I'm comparing your library and a new one integrated in golang.org/x/crypto/argon2, and I'm disappointed by the result of my tests.

With the same salt, password and params, I don't get the same hash, it's really weird isn't it ?

Am I missing something ?

To demonstrate, please consider the following test, that fails when I run it at the root of your library :

package argon2

import (
	"bytes"
	"encoding/base64"
	"testing"

	xargon2 "golang.org/x/crypto/argon2"
)

func TestCompat(t *testing.T) {
	salt := []byte("0123456789abcdef")
	pwd := []byte("some password")

	ctx := &Context{
		Iterations:  3,
		Memory:      1 << 16,
		Parallelism: 4,
		HashLen:     32,
		Mode:        ModeArgon2i,
	}
	hash, err := Hash(ctx, pwd, salt)
	if err != nil {
		t.Fatal(err)
	}

	xhash := xargon2.Key(pwd, salt, 3, 1<<16, 4, 32)

	if !bytes.Equal(hash, xhash) {
		t.Errorf("Compat failed:\n%s\n%s\n",
			base64.StdEncoding.EncodeToString(hash),
			base64.StdEncoding.EncodeToString(xhash),
		)
	}
}
$ go test .
--- FAIL: TestCompat (0.08s)
    compat_test.go:30: Compat failed:
        UgjfozCx6kU6vTNKoN8Ic2UTh7Ckphy0Dc79+1xlT/0=
        mf9LVGs+VH62cWpoLZVfCvtBWye6uMD7sWJfhYQk3fo=
FAIL
FAIL	github.com/tvdburgt/go-argon2	0.362s

Any help would be appreciated, thanks in advance!

Bundling argon2 source as a git submodule.

It would be cool to be able to directly be able to go get this package, this can be achieved to a degree by adding the argon2 source tree as a git submodule of this repo and then changing the argon2 build paths to reference the local submodule folder.
This works because golangs automatically downloads gitsubmodules at go get time.
This is what i did: luckcolors@8821398 (this was done on older version of this repo, might need to be adjusted a little bit)

The only catch would be that whenever https://github.com/P-H-C/phc-winner-argon2 updates the source the submodule refernce would need to be updated too, this is easy enough to do as it requires only one git command, see: https://stackoverflow.com/questions/5828324/update-git-submodule-to-latest-commit-on-origin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.