History log of /llvm-project/llvm/lib/Support/SipHash.cpp (Results 1 – 3 of 3)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-18.1.8
# 61069bd5 15-Jun-2024 Ahmed Bougacha <ahmed@bougacha.org>

[Support] Add SipHash-based 16-bit ptrauth ABI-stable hash. (#93902)

This finally wraps the now-lightly-modified SipHash C reference
implementation, for the main interface we need (16-bit ptrauth

[Support] Add SipHash-based 16-bit ptrauth ABI-stable hash. (#93902)

This finally wraps the now-lightly-modified SipHash C reference
implementation, for the main interface we need (16-bit ptrauth
discriminators).

The exact algorithm is the little-endian interpretation of the
non-doubled (i.e. 64-bit) result of applying a SipHash-2-4 using the
constant seed `b5d4c9eb79104a796fec8b1b428781d4` (big-endian), with the
result reduced by modulo to the range of non-zero discriminators (i.e.
`(rawHash % 65535) + 1`).

By "stable" we mean that the result of this hash algorithm will the same
across different compiler versions and target platforms.

The 16-bit hashes are used extensively for the AArch64 ptrauth ABI,
because AArch64 can efficiently load a 16-bit immediate into the high
bits of a register without disturbing the remainder of the value, which
serves as a nice blend operation.

16 bits is also sufficiently compact to not inflate a loader relocation.
We disallow zero to guarantee a different discriminator from the places
in the ABI that use a constant zero.

Co-authored-by: John McCall <rjmccall@apple.com>

show more ...


# 577c3f11 15-Jun-2024 Ahmed Bougacha <ahmed@bougacha.org>

[Support] Integrate SipHash.cpp into libSupport. (#94394)

Start building it as part of the library, with some minor
tweaks compared to the reference implementation:
- clang-format to match libSup

[Support] Integrate SipHash.cpp into libSupport. (#94394)

Start building it as part of the library, with some minor
tweaks compared to the reference implementation:
- clang-format to match libSupport
- remove tracing support
- add file header
- templatize cROUNDS/dROUNDS, as well as 8B/16B result length
- replace assert with static_assert
- use LLVM_FALLTHROUGH

This also exports interfaces for SipHash-2-4-64/-128, and
tests them using the reference test vectors.

show more ...


# cfbed2c0 14-Jun-2024 Ahmed Bougacha <ahmed@bougacha.org>

[Support] Import SipHash c reference implementation. (#94393)

This brings the unmodified SipHash reference implementation:
https://github.com/veorq/SipHash
which has been very graciously license

[Support] Import SipHash c reference implementation. (#94393)

This brings the unmodified SipHash reference implementation:
https://github.com/veorq/SipHash
which has been very graciously licensed under our llvm license
(Apache-2.0 WITH LLVM-exception) by Jean-Philippe Aumasson.

SipHash is a lightweight hash function optimized for speed on short
messages. We use it as part of the AArch64 ptrauth ABI (in arm64e and
ELF PAuth) to generate discriminators based on language identifiers and
mangled names.

This commit brings the unmodified reference implementation and tests
as of f26d35e, specifically siphash.c and vectors.h, as SipHash.cpp and
SipHashTest.cpp.

Next, we will integrate it properly into libSupport, with a wrapping API
suited for the ptrauth use-case.

show more ...