summaryrefslogtreecommitdiff
path: root/src/basic/siphash24.h
Commit message (Collapse)AuthorAgeFilesLines
* siphash: introduce siphash24_compress_safe()Yu Watanabe2020-12-301-4/+8
|
* headers: add spdx tags to imported files with a known licenseZbigniew Jędrzejewski-Szmek2020-10-291-0/+2
| | | | | | | | | | | | | | | I added the header in the cases where the license text is present and it is easy to find the appropriate SPDX header. For "public domain" stuff: SDPX treats each "public domain" license as unique [1], but luckily the one in siphash24.c is one of the identified variants. There are some other cases which specify "public domain" but there doesn't seem to be a SPDX identifier. [1] https://wiki.spdx.org/view/Legal_Team/Decisions/Dealing_with_Public_Domain_within_SPDX_Files gunicode.[ch] are imported from glib, which is licensed as LGPL2.1+, see https://gitlab.gnome.org/GNOME/glib/-/blob/master/glib/gunicode.h.
* Rework how we cache mtime to figure out if units changedZbigniew Jędrzejewski-Szmek2020-08-311-0/+6
| | | | | | | | | | | | | | | | | Instead of assuming that more-recently modified directories have higher mtime, just look for any mtime changes, up or down. Since we don't want to remember individual mtimes, hash them to obtain a single value. This should help us behave properly in the case when the time jumps backwards during boot: various files might have mtimes that in the future, but we won't care. This fixes the following scenario: We have /etc/systemd/system with T1. T1 is initially far in the past. We have /run/systemd/generator with time T2. The time is adjusted backwards, so T2 will be always in the future for a while. Now the user writes new files to /etc/systemd/system, and T1 is updated to T1'. Nevertheless, T1 < T1' << T2. We would consider our cache to be up-to-date, falsely.
* util: introduce siphash24_compress_string()Yu Watanabe2020-07-221-0/+7
|
* util: make siphash24_compress_boolean() inlineYu Watanabe2020-07-221-1/+6
| | | | | This also changes the stored type from int to uint8_t in order to make hash value endianness independent.
* util: introduce siphash24_compress_boolean()Yu Watanabe2019-06-191-0/+1
|
* tree-wide: use c99 static for array size declarationsZbigniew Jędrzejewski-Szmek2019-01-041-3/+3
| | | | | | | | | | | | | | | | https://hamberg.no/erlend/posts/2013-02-18-static-array-indices.html This only works with clang, unfortunately gcc doesn't seem to implement the check (tested with gcc-8.2.1-5.fc29.x86_64). Simulated error: [2/3] Compiling C object 'systemd-nspawn@exe/src_nspawn_nspawn.c.o'. ../src/nspawn/nspawn.c:3179:45: warning: array argument is too small; contains 15 elements, callee requires at least 16 [-Warray-bounds] candidate = (uid_t) siphash24(arg_machine, strlen(arg_machine), hash_key); ^ ~~~~~~~~ ../src/basic/siphash24.h:24:64: note: callee declares array parameter as static here uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[static 16]); ^~~~~~~~~~~~
* siphash24: add helper for calculating the hash value for a stringLennart Poettering2018-10-161-0/+5
| | | | Let's shorten some code.
* shared: make sure foo.bar and foobar result in different domain name hashesLennart Poettering2016-01-111-0/+2
| | | | | This also introduces a new macro siphash24_compress_byte() which is useful to add a single byte into the hash stream, and ports one user over to it.
* basic: include only what we useThomas Hindoe Paaboel Andersen2015-11-301-0/+2
| | | | | This is a cleaned up result of running iwyu but without forward declarations on src/basic.
* siphash: minor coding style fixes and modernizationsLennart Poettering2015-11-171-6/+6
| | | | Only cosmetics really, doesn't change any actual logic.
* siphash24: let siphash24_finalize() and siphash24() return the result directlyDaniel Mack2015-11-161-2/+2
| | | | | | | | | | Rather than passing a pointer to return the result, return it directly from the function calls. Also, return the result in native endianess, and let the callers care about the conversion. For hash tables and bloom filters, we don't care, but in order to keep MAC addresses and DHCP client IDs stable, we explicitly convert to LE.
* siphash24: change result argument to uint64_tMartin Pitt2015-11-161-2/+2
| | | | | | | | | | | | Change the "out" parameter from uint8_t[8] to uint64_t. On architectures which enforce pointer alignment this fixes crashes when we previously cast an unaligned array to uint64_t*, and on others this should at least improve performance as the compiler now aligns these properly. This also simplifies the code in most cases by getting rid of typecasts. The only place which we can't change is struct duid's en.id, as that is _packed_ and public API, so we can't enforce alignment of the "id" field and have to use memcpy instead.
* siphash24: unify APITom Gundersen2015-10-061-2/+2
| | | | | | | Make the API of the new helpers more similar to the old wrapper. In particular we now return the hash as a byte string to avoid any endianness problems.
* siphash24: expose the internal helper functionsTom Gundersen2015-10-051-0/+13
|
* build-sys: split internal basic/ library from shared/Kay Sievers2015-06-111-0/+6
basic/ can be used by everything cannot use anything outside of basic/ libsystemd/ can use basic/ cannot use shared/ shared/ can use libsystemd/