diff options
author | Anatol Belski <ab@php.net> | 2020-11-02 20:00:28 +0100 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2020-12-13 14:14:07 +0100 |
commit | 110b4e90946b6d46864c54c0e15b7a0deb6ad4b3 (patch) | |
tree | 709fa450d15d862e04866c213715f8791134f42c /ext/hash/hash_haval.c | |
parent | 70c22dec2812bb7fec9d248268207b95f9cd4215 (diff) | |
download | php-git-110b4e90946b6d46864c54c0e15b7a0deb6ad4b3.tar.gz |
hash: Support custom algo parameters
The concrete need on this change is to support passing an initial seed
to the murmur hash. Passing a custom seed is important in terms of
randomizing the hash function.
The suggested implementation adds a HashTable parameter to all the
init callbacks. Further on, an array with custom arguments is accepted
from `hash` or `hash_init` from the user land. Currently several things
like `hash_hkdf` are not touched, as they don't need passing custom
args.
Some convenience macros have been added to the SHA/MD families of
functions, so the consuming code doesn't have to be changed widely.
Another way to implement this is to add another type of the init that
would accept a HT with arguments. However, that would still require
touching all the context structs in all the algos. That would also
increase the size of those structs. As an init function is called just
once, the way of modifying the existing init callback has been seen
as more preferrable.
Closes GH-6400.
Signed-off-by: Anatol Belski <ab@php.net>
Co-Developed-by: Nikita Popov <nikita.ppv@googlemail.com>
Signed-off-by: Nikita Popov <nikita.ppv@googlemail.com>
Acked-by: Michael Wallner <mike@php.net>
Reviewed-by: Máté Kocsis <kocsismate@woohoolabs.com>
Reviewed-by: Eddie Kohler <ekohler@gmail.com>
Diffstat (limited to 'ext/hash/hash_haval.c')
-rw-r--r-- | ext/hash/hash_haval.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ext/hash/hash_haval.c b/ext/hash/hash_haval.c index 84ff242bd9..9b117db8d9 100644 --- a/ext/hash/hash_haval.c +++ b/ext/hash/hash_haval.c @@ -253,7 +253,7 @@ const php_hash_ops php_hash_##p##haval##b##_ops = { \ php_hash_unserialize, \ PHP_HAVAL_SPEC, \ ((b) / 8), 128, sizeof(PHP_HAVAL_CTX), 1 }; \ -PHP_HASH_API void PHP_##p##HAVAL##b##Init(PHP_HAVAL_CTX *context) \ +PHP_HASH_API void PHP_##p##HAVAL##b##Init(PHP_HAVAL_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args) \ { int i; context->count[0] = context->count[1] = 0; \ for(i = 0; i < 8; i++) context->state[i] = D0[i]; \ context->passes = p; context->output = b; \ |