Code Monkey home page Code Monkey logo

erlang-bcrypt's People

Contributors

ferd avatar hntrmrrs avatar jasperla avatar jcomellas avatar joedevivo avatar jstasiak avatar licenser avatar metajack avatar mrinalwadhwa avatar russor 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

erlang-bcrypt's Issues

Port failure on string/list containing 0 byte

18> bcrypt:hashpw([1], element(2, bcrypt:gen_salt())).
{ok,"$2a$12$rrb1UvG99VjksrmA3o8.6uN0jx2tWXXsKTlHkL6N5sqyg1mv.6/OK"}
19> bcrypt:hashpw([0], element(2, bcrypt:gen_salt())).

=ERROR REPORT==== 8-Aug-2011::12:20:15 ===
Port died: 139
=ERROR REPORT==== 8-Aug-2011::12:20:15 ===
** Generic server <0.70.0> terminating 
** Last message in was {#Port<0.1084>,{exit_status,139}}
** When Server state == {state,#Port<0.1084>,12}
** Reason for termination == 
** port_died
** exception exit: {port_died,{gen_server,call,
                                          [<0.70.0>,
                                           {hashpw,[0],"$2a$12$wVVtLRy2GnObV9ND3q2pRe"},
                                           infinity]}}
     in function  gen_server:call/3
20> bcrypt:mechanism().                               
port

This is only tested on ports, no idea if NIFs handle it well or just crash. Anybody could submit such data, especially if you're sending JSON data structures around:

{'user': 'bob', 'pass':'abc\u0000d'}

Wish should be decoded to "abc\0d" and give the same crash.

If no support for special characters of this kind are given, then at least returning an error (without a crash) or telling people to base64 encode it before using the library should be part of the manuals/readme, I guess.

OSX compilation: -bundle' not allowed with '-dynamiclib'

I am getting this error when compiling the nif

Applications/Xcode.app/Contents/Developer/usr/bin/make -f c_src/Makefile.erlang.mk
cc -c -o c_src/async_queue.o c_src/async_queue.c  -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include -Ic_src -Wall -fPIC -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: argument unused during compilation: '-finline-functions'
clang: warning: argument unused during compilation: '-finline-functions'
cc -c -o c_src/bcrypt.o c_src/bcrypt.c  -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include -Ic_src -Wall -fPIC -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: argument unused during compilation: '-finline-functions'
clang: warning: argument unused during compilation: '-finline-functions'
cc -c -o c_src/bcrypt_nif.o c_src/bcrypt_nif.c  -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include -Ic_src -Wall -fPIC -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: argument unused during compilation: '-finline-functions'
clang: warning: argument unused during compilation: '-finline-functions'
cc -c -o c_src/bcrypt_port.o c_src/bcrypt_port.c  -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include -Ic_src -Wall -fPIC -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: argument unused during compilation: '-finline-functions'
clang: warning: argument unused during compilation: '-finline-functions'
cc -c -o c_src/blowfish.o c_src/blowfish.c  -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include -Ic_src -Wall -fPIC -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: argument unused during compilation: '-finline-functions'
clang: warning: argument unused during compilation: '-finline-functions'
cc -o priv/bcrypt_nif.so c_src/async_queue.o c_src/bcrypt.o c_src/bcrypt_nif.o c_src/bcrypt_port.o c_src/blowfish.o -flat_namespace -undefined suppress -L /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/lib -lerl_interface -lei -bundle -flat_namespace -undefined suppress -L /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/lib -lerl_interface -lei -lpthread  -shared
clang: error: invalid argument '-bundle' not allowed with '-dynamiclib'
make[2]: *** [priv/bcrypt_nif.so] Error 1
make[1]: *** [pre-app] Error 2

Does not support "$2b$"?

Hi!

56> bcrypt:hashpw("12456", "$2b$12$j4P7eTvx7x2F.wj6HORIzetQmoegqZ1xo0B2jo/XNABgN5lMWswMi"). 
{error,"bcrypt failed"}

The hash string is produced by comeonin

Not support Erlang/OTP 20+

Env: Erlang/OTP 20+

Exec following code

> {ok, Salt} = bcrypt:gen_salt().

exception error:

** exception exit: {{function_clause,[{bcrypt_nif_worker,terminate,
                                                         [{undef,[{crypto,rand_bytes,[16],[]},
                                                                  {bcrypt_nif,gen_salt,1,
                                                                              [{file,"src/bcrypt_nif.erl"},{line,57}]},
                                                                  ...

`priv/bcrypt` not built with rebar3

If bcrypt is added as a dependency in a "rebar3 project" then the port executable priv/bcrypt is not built. The .so file is built.

Am wondering what needs to be changed to the rebar.config file to enable building the executable (which is needed for the port mechanism).

Failed to load NIF library

The bcrypt_nif.so is missing.

/rel/tengiStore/lib/bcrypt-0.4.1/priv/bcrypt_nif.so: cannot open shared object file: No such file or directory'"

Include sys/types.h in c_src/erl_blf.h

chef@a8f2ff4

#include <sys/types.h>

This line is needed to compile on Alpine Linux (musl). Could we get at least this change in master?

Any idea why u_* types are in play here (vs. say uint8_t)? They look non-standard to me.

bcrypt:hashpw runs quite slow

In my Ubuntu virtual machine (Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz 16 cores, 64G memory), bcrypt:hashpw runs for more than 1 second. Is this normal? I worry that this is not fast enough for production use when registered users are more than half million.

8> {ok, Salt} = bcrypt:gen_salt().
{ok,"$2a$12$BWhbfsZTZI50EVRmsc2/q."}
9> {ok, Hash} = bcrypt:hashpw("foo", Salt). (more than 1 second)
{ok,"$2a$12$BWhbfsZTZI50EVRmsc2/q.emrJQ6J9Av4semi4/X4x11USlhypCIq"}
10> {ok, Hash} =:= bcrypt:hashpw("foo", Hash). (more than 1 second)
true

My env:

Ubuntu 14.04.3 LTS
Kernel: 3.13.0-74-generic x86_64
Erlang:
Package: esl-erlang
Priority: extra
Section: interpreters
Installed-Size: 124643
Maintainer: Erlang Solutions Ltd [email protected]
Architecture: amd64
Source: esl-erlang
Version: 1:18.2

I starts erlang by "erl -pa ebin -boot start_sasl -s crypto -s bcrypt".

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.