phpsec/phpSec — pull request #127 by technion (2014-05-10 15:24:44+00:00)
Title: Cryptsecure

Hi,

It is not a best security practice to utilise a key for both encryption and HMAC. Although there is no significant breach in the default CTR mode, a user unwittingly changing $_mode to CBC falls into a known exploit [1]/

The system proposed involves using PBKDF to break them the key into two - to "derive" as it's designed to. Although the salts are hardcoded in this patch, we are not using this to hash passwords, and this approach is within practices used by other projects [2].

Along the way I have increased the unit testing of the Crypto class.

The work order of 1000 on the HMAC only slows down the integrity check, as any key derivation should be done on the key itself.

Finally, I note that my build is failing a Travis-ci test on the Authy class[3]. I did not touch this class and will open an issue for it. I can't see where I caused this, although I'm happy to eat my words if wrong.

[1] http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx
[2] https://github.com/jamesyonan/jacs/blob/master/README.md
[3] https://travis-ci.org/technion/phpSec/jobs/24867427