The openId functionality implements some functionality by itself because it is not available for PHP < 5. Now that D7 is PHP5 only we can use that functionality. This patch removes the manual conversion to raw format by using the PHP5 only parameter raw_output (http://www.php.net/manual/en/function.sha1.php).

Comments

jax’s picture

Title: Use PHP5 functionality for _openid_sha1() » Use PHP5 functionality for _openid_sha1() and _openid_hmac
StatusFileSize
new1.22 KB

hmac_hash generation is also in PHP5 http://www.php.net/manual/en/function.hash-hmac.php

c960657’s picture

Status: Needs review » Needs work

Patch no longer applies to HEAD.

c960657’s picture

Status: Needs work » Needs review
StatusFileSize
new2.95 KB

Reroll.

chx’s picture

Status: Needs review » Needs work

This is a kitten killer patch. Using the new sha1 argument is one patch. And a good one. Making openid rely on hash extension is a different patch and one that would quickly get a won't fix.

jax’s picture

Well...

The Hash extension requires no external libraries and is enabled by default as of PHP 5.1.2.

Not even if it's a default?

recidive’s picture

Status: Needs work » Needs review

Also,

"There is no installation needed to use these functions; they are part of the PHP core."

http://php.net/manual/en/hash.installation.php

Switching back to "needs review".

dries’s picture

This looks like a good move to me, but I'd like to get chx's take on why he thinks it is a "Won't fix".

chx’s picture

We really try to avoid relying on PHP extensions unless really necessary because they are a support burden. I blame every distribution out there that separates these out from their core -- but alas, they exist and they are widespread. You win less than 10 lines of code and get a support burden? No thanks. Feel free to add a if (function_exists(hash_hmac)) and use it inside our hmac but leave the workaround.

dries’s picture

chx is is right. Let's start with a patch that uses sha1() and worry about hash_hmac() next. The former is guaranteed to be built-in, the later is most likely to be available (and might require a requirements check). Thanks for clarifying, chx.

recidive’s picture

Title: Use PHP5 functionality for _openid_sha1() and _openid_hmac » Use PHP5 functionality for _openid_sha1()
StatusFileSize
new1.88 KB

Ok, here's a patch for the sha1 function only.

dries’s picture

Looks good. I haven't committed it yet, because I don't know for sure whether the OpenID tests are sufficient.

c960657’s picture

Status: Needs review » Needs work

The OPENID_SHA1_BLOCKSIZE constant is still used, so the define() should not be removed.

Tests for OpenID are awaiting review in #251245: openid.module needs tests. Until they are committed to CVS, you can apply the patch and run the tests locally.

recidive’s picture

Status: Needs work » Needs review
StatusFileSize
new1.57 KB

Re-adding OPENID_SHA1_BLOCKSIZE constant.

I'll run tests, but I think we need to wait the tests patch to get in prior to commiting this one.

dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.