zendframework / zend-crypt

Cryptographic component from Zend Framework
BSD 3-Clause "New" or "Revised" License
90 stars 40 forks source link

Will Zend\Crypt\Password\Bcrypt be deprecated in ZF3? #7

Closed RalfEggert closed 8 years ago

RalfEggert commented 8 years ago

ZF3 will move to PHP 5.5 and we have a native password_verify() and password_hash() there.

Will Zend\Crypt\Password\Bcrypt be deprecated or even removed from ZF3? Or has Zend\Crypt\Password\Bcrypt any advantage over the native PHP implementation?

Maks3w commented 8 years ago

It provide a better pseudorandom source which is the main source of security issues until PHP 7

RalfEggert commented 8 years ago

So, Zend\Crypt\Password\Bcrypt should be prefered over the PHP implementation until I use PHP7?

paragonie-scott commented 8 years ago

It provide a better pseudorandom source which is the main source of security issues until PHP 7

I really hope "it" is referring to PHP 5.5's implementation, not ZF2's. Insecure CSPRNG fallbacks are a bad idea.

(Maybe consider using https://github.com/paragonie/random_compat or https://github.com/ircmaxell/RandomLib instead?)

Ocramius commented 8 years ago

Since PHP 5.5 is a requirement as of 2.5.2, we can safely remove any of our internal implementation and just rely on PHP's password_hash() and password_verify() implementation. Deprecation is not worth it, IMO, especially since we may throw exceptions (maybe at install time?), should the machine where the component is installed contain some security issues around password hashing, but the classes would basically become empty shells forwarding calls to password_hash() and password_verify().

paragonie-scott commented 8 years ago

:+1: for using the password API built into PHP :)

Maks3w commented 8 years ago

I'm not sure if PHP 5.5 hash implementation is "good" without to dig in PHP 5.5 source code.

As far as I can say PHP 5.6 improves the random generator for MCrypt and Crypt. PHP 7 definitevely provides native CSPRNG functions. And only PHP 7 deprecate bcrypt salt option because native generator is enough safe.

So a new PasswordInterface adapter can be proposed for wrap PHP hash API exposing algorithm (1st argument) and options (3rd argument) in the adapter constructor.

ezimuel commented 8 years ago

@RalfEggert we provided the Bcrypt support since PHP 5.3. For BC reason, we will continue to support it and I'm working on a patch to support the PHP 5.5 password_verify() and password_usage() under the hood. Regarding the security of bcrypt usage of ZF2 we used some best practices for random number generation and cost value. That said, the security with PHP 5.5+ it's equivalent.

ezimuel commented 8 years ago

@paragonie-scott we are already using the ircmaxell/RandomLib library as fallback in zend-math, with a mixer function.