|
|
|||
File indexing completed on 2026-05-10 08:44:34
0001 //===--- SipHash.h - An ABI-stable string SipHash ---------------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // An implementation of SipHash, a hash function optimized for speed on 0010 // short inputs. Based on the SipHash reference implementation. 0011 // 0012 // Also provides one specific wrapper on top of SipHash-2-4-64 to compute 0013 // compute ABI-stable ptrauth discriminators. 0014 // 0015 //===----------------------------------------------------------------------===// 0016 0017 #ifndef LLVM_SUPPORT_SIPHASH_H 0018 #define LLVM_SUPPORT_SIPHASH_H 0019 0020 #include <cstdint> 0021 0022 namespace llvm { 0023 0024 template <typename T> class ArrayRef; 0025 class StringRef; 0026 0027 /// Computes a SipHash-2-4 64-bit result. 0028 void getSipHash_2_4_64(ArrayRef<uint8_t> In, const uint8_t (&K)[16], 0029 uint8_t (&Out)[8]); 0030 0031 /// Computes a SipHash-2-4 128-bit result. 0032 void getSipHash_2_4_128(ArrayRef<uint8_t> In, const uint8_t (&K)[16], 0033 uint8_t (&Out)[16]); 0034 0035 /// Compute a stable non-zero 16-bit hash of the given string. 0036 /// 0037 /// The exact algorithm is the little-endian interpretation of the 0038 /// non-doubled (i.e. 64-bit) result of applying a SipHash-2-4 using 0039 /// a specific seed value which can be found in the source. 0040 /// This 64-bit result is truncated to a non-zero 16-bit value. 0041 /// 0042 /// We use a 16-bit discriminator because ARM64 can efficiently load 0043 /// a 16-bit immediate into the high bits of a register without disturbing 0044 /// the remainder of the value, which serves as a nice blend operation. 0045 /// 16 bits is also sufficiently compact to not inflate a loader relocation. 0046 /// We disallow zero to guarantee a different discriminator from the places 0047 /// in the ABI that use a constant zero. 0048 uint16_t getPointerAuthStableSipHash(StringRef S); 0049 0050 } // end namespace llvm 0051 0052 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|