Giter Club home page Giter Club logo

go-crypt's People

Contributors

amoghe avatar reezer avatar rhafer avatar

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

go-crypt's Issues

How can i static link this

I want to run this program on old linux operating systems.
I got this error: /lib/x86_64-linux-gnu/libcrypt.so.1: version `XCRYPT_2.0' not found
is it possible to link this library in the binary so that i can run it without libcrypt.so

Test failures on recent Linux distros

Running the tests on a recent build of openSUSE Tumbleweed gives me this:

src/go-crypt> go test
--- FAIL: TestCryptErrors (0.00s)
    crypt_test.go:64: Expected error when testing no salt, instead got *0
    crypt_test.go:64: Expected error when testing single char, instead got *0
    crypt_test.go:64: Expected error when testing first char bad, instead got *0
    crypt_test.go:64: Expected error when testing second char bad, instead got *0
    crypt_test.go:64: Expected error when testing both chars bad, instead got *0
    crypt_test.go:64: Expected error when testing un$upported algorithm, instead got *0
    crypt_test.go:64: Expected error when testing unsupported_algorithm, instead got *0
FAIL
exit status 1
FAIL    github.com/amoghe/go-crypt      0.860s

This might be related to the fact that many recent distros have switched away from glibc's implementation of crypt() to e.g. libxcrypt which supports a broader set of password hashes. Apparently the behaviour in case of errors is slightly different in some cases. From the crypt man-page:

Upon error, crypt_r, crypt_rn, and crypt_ra write an invalid hashed passphrase to the output field of their data argument, and crypt writes an invalid hash to its static storage area.  This string will be shorter than 13 characters, will begin with a ‘*’, and will not compare equal to setting.

The current code in go-crypt does not check for that type of error condition.

go-crypt fails to build on musl libc

Trying to build with the musl libc variant e.g. on Alpine Linux fails, due to some glibc specific code in the version test:

# github.com/amoghe/go-crypt
./version.go:6:10: fatal error: gnu/libc-version.h: No such file or directory
    6 | #include <gnu/libc-version.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.

Sucessful calls might return an error value

According to the docs:

Any C function (even void functions) may be called in a multiple assignment context to retrieve both the return value (if any) and the C errno variable as an error

But crypt() does not set errno, and the call to C.crypt() is building a error variable with a value of some other call. If errno is not 0, then err is not nil. Both

https://github.com/amoghe/go-crypt/blob/master/crypt.go#L41

and

https://github.com/amoghe/go-crypt/blob/master/crypt.go#L48

are returning an unrelated value.

So this code might or might fail:

	password, err := Crypt(password, salt)
	if err != nil {
		// TODO: oh no!
		log.Printf("crypt: [%v] %v", password, err)
		return err
	}

Like this:

2019/11/12 05:56:42 $6$iq.dbF2KUB2h, x
2019/11/12 05:56:42 crypt: [$6$iq.dbF2KUB2h$nV.xPcJUqHN1r46FQ/MJJc7OVbSb5Yd4nsOLU.XZ3QsVdwgGjqVoNeEx.u8MIFC1seQcS8jAelI95Z8BlBmeC/] errno -8191

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.