Closed (won't fix)
Project:
Acquia Connector
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Feb 2009 at 06:11 UTC
Updated:
30 Dec 2019 at 00:12 UTC
Jump to comment: Most recent
Comments
Comment #1
pwolanin commentedbasically looks good - however, we will probably postpone committing until we release version 6.x-1.2 of this project.
Comment #2
heine commentedJust a FYI, this is the hmac implementation I wanted to introduce in Drupal 6. It correctly deals with short and long keys and has been tested with the MD5 examples from RCF2202. If the "HASH Message Digest Framework" functions are available, the work is handed to them.
Comment #3
pwolanin commented@Heine - since hash_hmac assume the 64 block size, I think your suggested implementation is flawed.
I guess you could say ours is flawed by not handling a key > 64 bytes, but we know our keys are not that long.
Comment #4
pwolanin commentedActually, since we know we are on php5, we can omit the pack() command by passing the last arg to sha1
Comment #5
pwolanin commentedAlso, we might as well make our function really compliant with http://www.faqs.org/rfcs/rfc2104.html
" The key for HMAC can be of any length (keys longer than B bytes are first hashed using H)."
Comment #6
heine commentedIf hash_hmac assumes a 64 block size, it is flawed. According to hash_algos, the Hash Messaging Digest Framework supports a SHA512 hash, which has a block size of 128 bytes.
According to the source, hash.c uses ops->block_size, which for SHA512 is 128 bytes according to hash_sha.c:
Comment #7
pwolanin commented@Heine - ah, you are right, but then you still might have a mismatch between the requested blok size and the actual block size.
I don't think there is a lot of value to trying to much such a generic function with extra overhead - just mac hmac_md5() and hmac_sha1() functions (for example).
Comment #8
heine commentedThat's right, you need to pass the correct $block_size for sha512, but I just wanted to give you guys a headstart on an RFC2104 compliant implementation. Mutilate as necessary :)
Comment #9
pwolanin commented@Heine - our implmentation matches with hash_hmac() one and the in python 2.4, so I think we're ok (barring key length issues).
Comment #10
pwolanin commentedSo, unless we want to have 2 alternate hmac algorithms in the module, I'm not sure we should proceed any further with this until we are at 7.x, which requires php 5.2
Comment #11
pwolanin commentedWe really need to do something for Drupal 7, since use of sha1 is deprecated.
Comment #12
pwolanin commentedIf we do something like this, we should probably consider the proposed Oauth2 HMAC spec: http://tools.ietf.org/html/draft-hammer-oauth-v2-mac-token-02
Comment #13
danepowell commentedThe 6.x branch is no longer supported, if this is still an issue in the 7.x-3.x or 8.x branches please reopen with the appropriate target version. Thanks!