History log of /php-src/ext/hash/hash.c (Results 26 – 50 of 215)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 98fb565c 05-Feb-2021 Máté Kocsis

Generate class entries from stubs for another batch of extensions

Closes GH-6669

# 3e01f5af 15-Jan-2021 Nikita Popov

Replace zend_bool uses with bool

We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool

Replace zend_bool uses with bool

We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.

show more ...

# 23590f7c 13-Dec-2020 Anatol Belski

hash: Implement xxHash

The implementation bundles the xxHash v0.8.0 release and includes all the variants

- xxh32, 32-bit wide
- xxh64, 64-bit wide
- xxh3, 64-bit wide
-

hash: Implement xxHash

The implementation bundles the xxHash v0.8.0 release and includes all the variants

- xxh32, 32-bit wide
- xxh64, 64-bit wide
- xxh3, 64-bit wide
- xxh128, 128-bit wide

An initial hash state can be passed through the options arrray. An additional
functionality not targeted in this implementation is the secret support in xxh3
and xxh128. That can be added at a later point.

The serialization for xxh3 and xxh128 should not be implemented, as the
state would contain the secret. Despite the xxHash is a non crypto
algorithm, the secret would be serialized as plain text which would be
insecure.

Closes GH-6524

Signed-off-by: Anatol Belski <ab@php.net>

show more ...

# 110b4e90 02-Nov-2020 Anatol Belski

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
randomi

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>

show more ...

# 72e91e9f 30-Aug-2020 Anatol Belski

hash: Add MurmurHash3 with streaming support

The implementation is based on the upstream PMurHash. The following
variants are implemented

- murmur3a, 32-bit hash
- murmur3c,

hash: Add MurmurHash3 with streaming support

The implementation is based on the upstream PMurHash. The following
variants are implemented

- murmur3a, 32-bit hash
- murmur3c, 128-bit hash for x86
- murmur3f, 128-bit hash for x64

The custom seed support is not targeted by this implementation. It will
need a major change to the API, so then custom arguments can be passed
through `hash_init`. For now, the starting hash is always zero.

Fixes bug #68109, closes #6059

Signed-off-by: Anatol Belski <ab@php.net>
Co-Developed-by: Michael Wallner <mike@php.net>
Signed-off-by: Michael Wallner <mike@php.net>

show more ...

# 7e339a33 08-Sep-2020 Nikita Popov

Make null byte error a ValueError

Currently we treat paths with null bytes as a TypeError, which is
incorrect, and rather inconsistent, as we treat empty paths as
ValueError. We do t

Make null byte error a ValueError

Currently we treat paths with null bytes as a TypeError, which is
incorrect, and rather inconsistent, as we treat empty paths as
ValueError. We do this because the error is generated by zpp and
it's easier to always throw TypeError there.

This changes the zpp implementation to throw a TypeError only if
the type is actually wrong and throw ValueError for null bytes.
The error message is also split accordingly, to be more precise.

Closes GH-6094.

show more ...

# 736c5dca 19-Aug-2020 Dmitry Stogov

Fixed memory leak (ext/hash/tests/mhash_001.phpt failure)

# f83368c6 13-Aug-2020 Máté Kocsis

Fix ZPP for mhash()

Closes GH-5985

# 2b5de6f8 01-Jul-2020 Max Semenik

Remove proto comments from C files

Closes GH-5758

# ada776c8 08-Jun-2020 Eddie Kohler

Make HashContexts serializable.

* Modify php_hash_ops to contain the algorithm name and
serialize and unserialize methods.

* Implement __serialize and __unserialize magic meth

Make HashContexts serializable.

* Modify php_hash_ops to contain the algorithm name and
serialize and unserialize methods.

* Implement __serialize and __unserialize magic methods on
HashContext.

Note that serialized HashContexts are not necessarily portable
between PHP versions or from architecture to architecture.
(Most are, though Keccak and slow SHA3s are not.)

An exception is thrown when an unsupported serialization is
attempted.

Because of security concerns, HASH_HMAC contexts are not
currently serializable; attempting to serialize one throws
an exception.

Serialization exposes the state of HashContext memory, so ensure
that memory is zeroed before use by allocating it with a new
php_hash_alloc_context function. Performance impact is
negligible.

Some hash internal states have logical pointers into a buffer,
or sponge, that absorbs input provided in bytes rather than
chunks. The unserialize functions for these hash functions
must validate that the logical pointers are all within bounds,
lest future hash operations cause out-of-bounds memory accesses.

* Adler32, CRC32, FNV, joaat: simple state, no buffer positions
* Gost, MD2, SHA3, Snefru, Tiger, Whirlpool: buffer positions
must be validated
* MD4, MD5, SHA1, SHA2, haval, ripemd: buffer positions encoded
bitwise, forced to within bounds on use; no need to validate

show more ...

# 1e9ff7e7 22-Jun-2020 Eddie Kohler

SHA-3 Keccak_Hash: Store Keccak_HashInstance in the main context.

Previously, the Keccak_HashInstance was separately allocated.
This could cause memory leaks on errors. For instance,

SHA-3 Keccak_Hash: Store Keccak_HashInstance in the main context.

Previously, the Keccak_HashInstance was separately allocated.
This could cause memory leaks on errors. For instance,
in php_hash_do_hash_hmac, the following code cleans up after
a file read error:

if (n < 0) {
efree(context);
efree(K);
zend_string_release(digest);
RETURN_FALSE;
}

This does not call the context's hash_final operation, which
was the only way to free the separately-allocated Keccak state.

The simplest fix is simply to place the Keccak_HashInstance state
inside the context object. Then it doesn't need to be freed.

As a result, there is no need to call hash_final in the
HashContext destructor: HashContexts cannot contain internally
allocated resources.

show more ...

# 3ebce8e9 02-May-2020 Máté Kocsis

Fix UNKNOWN default values in various extensions

Closes GH-5514

# 6111d64c 16-Apr-2020 Máté Kocsis

Improve a last couple of argument error messages

Closes GH-5404

# 3fe49d81 11-Apr-2020 Máté Kocsis

Generate method entries from stubs for a couple of extensions

Closes GH-5368

# 3e5fdef9 06-Apr-2020 Nikita Popov

Inline a ZEND_NUM_ARGS() variable

# 5322de1b 04-Apr-2020 Máté Kocsis

Generate functions entries from stubs for another set of extensions

Closes GH-5351

# c5fe1a19 18-Mar-2020 Máté Kocsis

Improve error messages of ext/hash

Closes GH-5275

# d5871e26 18-Mar-2020 Máté Kocsis

Promote warnings to exceptions in ext/hash

# 80392253 13-Feb-2020 Nikita Popov

Add arginfo for HashContext::__construct()

Arginfo was already generated, just not referenced.

# 99db00b1 19-Jan-2020 Máté Kocsis

Fix #78880 Another round

# d1764ca3 15-Jan-2020 Máté Kocsis

Make error messages more consistent by fixing capitalization

Closes GH-5066 As a first step, let's capitalize their initial letter when it is applicable.

# a6486088 30-Dec-2019 Nikita Popov

Switch hash() function to use fastzpp

For short inputs ZPP can be a large fraction of the hash()
execution time.

# 7c787e56 30-Dec-2019 Nikita Popov

Switch php_hash_fetch_ops() to use zend_string

This has two advantages: If the string is already lowercase, we
do not need to copy it, and it will hopefully match the interned
string

Switch php_hash_fetch_ops() to use zend_string

This has two advantages: If the string is already lowercase, we
do not need to copy it, and it will hopefully match the interned
string name of the hash, making the comparison more efficient.

show more ...

# 349a2864 01-Jan-2020 Máté Kocsis

Use RETURN_THROWS() after zend_throw_error()

# 9099dbd9 01-Jan-2020 Máté Kocsis

Use RETURN_THROWS() after zend_type_error()

123456789