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/php_hash_tiger.h | |
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/php_hash_tiger.h')
-rw-r--r-- | ext/hash/php_hash_tiger.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/hash/php_hash_tiger.h b/ext/hash/php_hash_tiger.h index d30276ddea..6854c35887 100644 --- a/ext/hash/php_hash_tiger.h +++ b/ext/hash/php_hash_tiger.h @@ -27,8 +27,8 @@ typedef struct { } PHP_TIGER_CTX; #define PHP_TIGER_SPEC "q3qb64l" -PHP_HASH_API void PHP_3TIGERInit(PHP_TIGER_CTX *context); -PHP_HASH_API void PHP_4TIGERInit(PHP_TIGER_CTX *context); +PHP_HASH_API void PHP_3TIGERInit(PHP_TIGER_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args); +PHP_HASH_API void PHP_4TIGERInit(PHP_TIGER_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args); PHP_HASH_API void PHP_TIGERUpdate(PHP_TIGER_CTX *context, const unsigned char *input, size_t len); PHP_HASH_API void PHP_TIGER128Final(unsigned char digest[16], PHP_TIGER_CTX *context); PHP_HASH_API void PHP_TIGER160Final(unsigned char digest[20], PHP_TIGER_CTX *context); |