Skip to content

[BUG] half_siphash_32 does not work correctly with 8-byte key #5

@jiachin1995

Description

@jiachin1995

Issue: When using 8-byte key, half_siphash_32() changes output depending on when and where its called.

Suspected Cause: C library function is reading memory from the 9th byte onwards.

Steps to reproduce bug:

# Run the following code
from siphash import half_siphash_32

data = b'PQWXWDRRASD2164DW5G'
key = b'\x124Vx'     # 8-byte key
half_siphash_32(key, data)
key = b'\x124Vx'
half_siphash_32(key, data)
key = b'\x124Vx'
half_siphash_32(key, data)
key = b'\x124Vx'
half_siphash_32(key, data)

My output:

>>> from siphash import half_siphash_32
>>>
>>> data = b'PQWXWDRRASD2164DW5G'
>>> key = b'\x124Vx'
>>> half_siphash_32(key, data)
b'\xb73(\x1c'
>>> key = b'\x124Vx'
>>> half_siphash_32(key, data)
b'\x15\xcf\x1e\xa3'
>>> key = b'\x124Vx'
>>> half_siphash_32(key, data)
b'\xb73(\x1c'
>>> key = b'\x124Vx'
>>> half_siphash_32(key, data)
b'\x15\xcf\x1e\xa3'

As shown above, half_siphash_32 returns b'\x15\xcf\x1e\xa3' or b'\xb73(\x1c' randomly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions