New Extension: xcrypt
| From: | M." Karpelès | Date: | Mon, 18 Feb 2008 06:42:51 +0000 |
| Subject: | New Extension: xcrypt | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-5122@lists.php.net to get a copy of this message | ||
Hello,
I'm working on a PHP module for the "libxcrypt" library.
This library offers on linux a replacement of crypt() supporting more
methods (includes blowfish for example).
I initially wrote this module when migrating from a FreeBSD system,
where I was using blowfish passwords, to a linux system, where such
passwords are not available.
Of course I could just do as explained on various pages on google, and
replace in the makefile all -lcrypt with -lxcrypt (libxcrypt provides
weak symbols such as "crypt()" and was made to be "binary compatible" so
one could replace libcrypt with libxcrypt - I tried that too and I had
to reinstall libc6 on my debian box), but it's better to have a module
do that for various reasons. One is to extend crypt() abilities.
My module implements two php.ini directives :
xcrypt.func_overload : overload php's crypt() (I'm checking how to
overload defines such as CRYPT_BLOWFISH). That's a PHP_INI_SYSTEM var.
xcrypt.default_salt_type : defines default salt type if none is
provided. PHP's crypt() usually provides only MD5 salt, so this
setting's default value would be XCRYPT_TYPE_MD5.
Of course this module don't have much interest on BSD boxes, however
it's useful for migration, or people who want more secure passwords,
like blowfish, without having to change any line of code (just make sure
the database fields are large enough to store blowfish passwords).
A little benchmark on my core2 duo system, using only one core :
Benchmarking: FreeBSD MD5 [32/64 X2]... DONE
Raw: 8316 c/s real, 8333 c/s virtual
Benchmarking: OpenBSD Blowfish (x32) [32/64]... DONE
Raw: 311 c/s real, 311 c/s virtual
Lower is better, as some people say. Basically means that it takes much
more time to bruteforce a blowfish password than it takes to bruteforce
a md5 password. That's what we want, as people are supposed to change
password from times to times.
So, basically, the goal is to allow people on linux systems to be able
to use "better" hash algorythms in passwords without having to think too
much, or having to generate their own salts.
For more license informations on libxcrypt :
http://beta.magicaltux.net/xcrypt.txt (the
"copyright" file provided by
debian).
Only the DES/MD5 code and UFC-crypt code seems to be LGPL, and it should
be possible to replace it with code from the PHP mainstream if we want
to make the "xcrypt" extension standalone, or at least if we want to
remove all LGPL code (as suggested in account-request : "PECL extensions
around GPL'ed libraries will not be accepted, and extensions around
LGPL'ed libraries are strongly discouraged").
Mark