From 23f424433d7610c9a10c96afefb1193a6a681acc Mon Sep 17 00:00:00 2001 From: ffs Upstream Date: Wed, 25 Oct 2023 14:45:03 -0400 Subject: [PATCH] ffs 2023-10-25 (6ba5b105) Code extracted from: https://github.com/GTkorvo/ffs.git at commit 6ba5b10561af555aa871294ccc0869acfc100e75 (master). Upstream Shortlog ----------------- --- CMakeLists.txt | 2 +- ffs/output_dir/context_test_output.osx-3.bin | Bin 0 -> 16939 bytes ffs/output_dir/file_output.osx-v3.bin | Bin 0 -> 14513 bytes ffs/output_dir/index_output.osx-v3.bin | Bin 0 -> 16305 bytes fm/fm_formats.c | 18 +- fm/siphash.c | 185 +++++++++++++++++++ fm/siphash.h | 22 +++ 7 files changed, 221 insertions(+), 6 deletions(-) create mode 100755 ffs/output_dir/context_test_output.osx-3.bin create mode 100755 ffs/output_dir/file_output.osx-v3.bin create mode 100755 ffs/output_dir/index_output.osx-v3.bin create mode 100644 fm/siphash.c create mode 100644 fm/siphash.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d8589f95e..28e78f5450 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,7 +134,7 @@ else() endif() set(FM_SRC_LIST - fm_formats.c fm_dump.c lookup3.c string_conversion.c fm_get.c xml.c + fm_formats.c fm_dump.c siphash.c string_conversion.c fm_get.c xml.c ${FM_SOCKET_IO} ${FFS_FILE_IO}) foreach(FM_SRC ${FM_SRC_LIST}) list(APPEND FM_MASTER_SRC_LIST fm/${FM_SRC} ) diff --git a/ffs/output_dir/context_test_output.osx-3.bin b/ffs/output_dir/context_test_output.osx-3.bin new file mode 100755 index 0000000000000000000000000000000000000000..e741dd13a65ccd7285d8c12c0edc85e395b10e26 GIT binary patch literal 16939 zcmeHO3v`s#wLTe;q9R6A6sz6=6;VW!0D>s`2NDPnG$2WXF(#ADBpH~@gvlg4e4(gd zeSuny*IUF#y;ZRnTYJk=D^$J8ver_qwZ7@acdeJjvQ;bU{l0Vd`TsMM;M87qt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LDZ$D=60>X9N2`e^e}=H}ZV`CMIuecbFAwE4)p`L;+t zt4C_>MQZag?dIDi`CMIVKT?~I{(LNuetbNT{!92e<*)&!X$b$cqVC%F)B7Ty{4sSy z=nfU4ZTQwB0m3%24U7vr%rw{6?<*i<2Yoj9IskTZ7H0jw+8oOKCc&ga=*uBW;(lDAXU&aUizYS-%75fP1g zIXG6bjqLkY>H7lk-IM_d=L4?XOv~N;%hh`FKJISv`5kl zyE^QF8ts3EL9XVrkqwr0RoW8a|_=F?p z9yud?mr#f_1Y4e9uM=!?zWh;gtCateQ1*eaU3l)>2naxW?(8Fm8Eg%tpZ0kb@MVsY H4AcJ$<;@mV literal 0 HcmV?d00001 diff --git a/ffs/output_dir/file_output.osx-v3.bin b/ffs/output_dir/file_output.osx-v3.bin new file mode 100755 index 0000000000000000000000000000000000000000..a8326f1e2644a75c390b7c69f092627f67634618 GIT binary patch literal 14513 zcmeHO3viUx6~0-}LR1V?5Uh_SDx!!X32&BgLjoj_NC+fG5tB`J^MK7RY&PK`6$J#W zqKFo-C{oc{6&-7>GKxyARR$4J+wqByvGr9SjBRz$sq{Pdp8N0pH`y%snsJ6RIeYFo z|M~CZ+HVis#Ty{fj0OiQUm3|x=1wO<@&4ru~@XJwlx+U>zg=n z`sjc^=GWC%HwDHH$@A(KJ6Frj^HS6Px>zvUxn@pYUb?as`ZdtDC-t)jclPwx4_r2T z`%yBVdFYY-$>6f=$>vqFR=1u5n|a7?BH$6{f>5~zNcOK{`xkte0Z zV8H8-M*Rzose_6W!RFdvAP@}996C$uJHI!!pJUjUrchJ>F9xD-3Ih0@2c(OH3xG?w zOml1+5l!xiMc#(YDDlEmOZ{&DB^ktTM^>i6)o4n>78W z^<#llHiqC*ODM$tak`5+L&&J;c=j+;Fp^7F>_OlYKx5)(Q2rb9Wa8I>A23f-|0(bQkcQ#~ z8dG<+&srKIQEWxm-U~&X3F6J;RHgLHtR3nW9e@t?HTFfn2z=9(IS+4-=B0Z9zUivZ zZT?VehkH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=6Qw zz}FEpne+7 z80lozaV1yrEksOT%`&OsYewG4JZD~FF7q5Q)xTkoh-RPQa`mf^NvTLfrYuF#Nro0N zUsSB+Ma7eO+;nv9Os8p_Dl#3SGJ&y=RGbi;3W-wY%|u?pyna2ae&+~HLWVXwg|IQ$ ze{F;9<2s0#fg6Ke&ex2574ya*YnboObTd;rA11h86Lk(u#U0Ee04UhYl+J$$*kFdn z4X7_W^2t-Qz%lR?o!nWxGL_Ar&y(<1dlK&Diiwy(8siV-Yl(}qhUI1g=P_>%s#Y++ zmZ?d&@CJPjy$EL-aSC(erFm8{YL{DFOpIqTt=OJP^CpGbH8Wynax-_v$j!`{ncBhE z>BOGE%#4|-x0O_%)KPIi^K>GofISkOyb)wDZ`$`V-&0?X&txM1ZDtmAxMmtI$IX`| z^3xKoPb=ru@rAuQ-sH{^F@`fDvr1}MFq>&B(<_)>%k*ZZ_b`2w>29WKZA9kIiwdXI ZVijX{xz)wAxw-iX?1DsoVLQPh@qcX3;!Xen literal 0 HcmV?d00001 diff --git a/ffs/output_dir/index_output.osx-v3.bin b/ffs/output_dir/index_output.osx-v3.bin new file mode 100755 index 0000000000000000000000000000000000000000..1a6cbe01711e5d85023297ddde77941f0cfb6bf7 GIT binary patch literal 16305 zcmeHO4|J8qm7j!2`6osM8Ys4psEDEs3E}@EOdvpjApcVoY4Vahl0fnvyu5%?Rz*~B zg;r@-aJ9;c-L6V|Z0oihYpv_HmSZVu-96S?v_0;&w%b~dyW6hqS=rxj=Fa!cdwDMp zTidfe$9vxWX70?Le|Ki?y))nU<~N>xutXIpr3U^C4??k0!)#0ym4H}&|DYFNKls&$ zzNXZLWCRqi!DCoP9*C3Q9y#lIIR@7=J!_tLPQ0f(fXFfXef zkYq7WrAlUlKJa`?{j^c9KYy=M{~di7k0rD##h292zK!A`He_6r~)H zT3xIf5DoyA0SApMR-ZwDsJar^4wN=j67iitW)g1%?gz4yrNE7ysh)IXV=~npORLUA zI^G^nMK*TEyV@M3+LFC3U2#d=*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|5y; zqmGP~4waipugIoXX63J3CA;G{{_c21I>*2X&Lz2B(kuy^BtmhkHm mo{-S&jpUZCDHX(eylC2w_ht~=GO6uZ + Copyright (c) 2012-2014 Daniel J. Bernstein + + To the extent possible under law, the author(s) have dedicated all copyright + and related and neighboring rights to this software to the public domain + worldwide. This software is distributed without any warranty. + + You should have received a copy of the CC0 Public Domain Dedication along + with + this software. If not, see + . + */ + +#include "siphash.h" +#include +#include +#include + +/* default: SipHash-2-4 */ +#ifndef cROUNDS +#define cROUNDS 2 +#endif +#ifndef dROUNDS +#define dROUNDS 4 +#endif + +#define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b)))) + +#define U32TO8_LE(p, v) \ + (p)[0] = (uint8_t)((v)); \ + (p)[1] = (uint8_t)((v) >> 8); \ + (p)[2] = (uint8_t)((v) >> 16); \ + (p)[3] = (uint8_t)((v) >> 24); + +#define U64TO8_LE(p, v) \ + U32TO8_LE((p), (uint32_t)((v))); \ + U32TO8_LE((p) + 4, (uint32_t)((v) >> 32)); + +#define U8TO64_LE(p) \ + (((uint64_t)((p)[0])) | ((uint64_t)((p)[1]) << 8) | \ + ((uint64_t)((p)[2]) << 16) | ((uint64_t)((p)[3]) << 24) | \ + ((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) | \ + ((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56)) + +#define SIPROUND \ + do { \ + v0 += v1; \ + v1 = ROTL(v1, 13); \ + v1 ^= v0; \ + v0 = ROTL(v0, 32); \ + v2 += v3; \ + v3 = ROTL(v3, 16); \ + v3 ^= v2; \ + v0 += v3; \ + v3 = ROTL(v3, 21); \ + v3 ^= v0; \ + v2 += v1; \ + v1 = ROTL(v1, 17); \ + v1 ^= v2; \ + v2 = ROTL(v2, 32); \ + } while (0) + +#ifdef DEBUG_SIPHASH +#include + +#define TRACE \ + do { \ + printf("(%3zu) v0 %016" PRIx64 "\n", inlen, v0); \ + printf("(%3zu) v1 %016" PRIx64 "\n", inlen, v1); \ + printf("(%3zu) v2 %016" PRIx64 "\n", inlen, v2); \ + printf("(%3zu) v3 %016" PRIx64 "\n", inlen, v3); \ + } while (0) +#else +#define TRACE +#endif + +/* + Computes a SipHash value + *in: pointer to input data (read-only) + inlen: input data length in bytes (any size_t value) + *k: pointer to the key data (read-only), must be 16 bytes + *out: pointer to output data (write-only), outlen bytes must be allocated + outlen: length of the output in bytes, must be 8 or 16 +*/ +int siphash(const void *in, const size_t inlen, const void *k, uint8_t *out, + const size_t outlen) { + + const unsigned char *ni = (const unsigned char *)in; + const unsigned char *kk = (const unsigned char *)k; + + assert((outlen == 8) || (outlen == 16)); + uint64_t v0 = UINT64_C(0x736f6d6570736575); + uint64_t v1 = UINT64_C(0x646f72616e646f6d); + uint64_t v2 = UINT64_C(0x6c7967656e657261); + uint64_t v3 = UINT64_C(0x7465646279746573); + uint64_t k0 = U8TO64_LE(kk); + uint64_t k1 = U8TO64_LE(kk + 8); + uint64_t m; + int i; + const unsigned char *end = ni + inlen - (inlen % sizeof(uint64_t)); + const int left = inlen & 7; + uint64_t b = ((uint64_t)inlen) << 56; + v3 ^= k1; + v2 ^= k0; + v1 ^= k1; + v0 ^= k0; + + if (outlen == 16) + v1 ^= 0xee; + + for (; ni != end; ni += 8) { + m = U8TO64_LE(ni); + v3 ^= m; + + TRACE; + for (i = 0; i < cROUNDS; ++i) + SIPROUND; + + v0 ^= m; + } + + switch (left) { + case 7: + b |= ((uint64_t)ni[6]) << 48; + /* FALLTHRU */ + case 6: + b |= ((uint64_t)ni[5]) << 40; + /* FALLTHRU */ + case 5: + b |= ((uint64_t)ni[4]) << 32; + /* FALLTHRU */ + case 4: + b |= ((uint64_t)ni[3]) << 24; + /* FALLTHRU */ + case 3: + b |= ((uint64_t)ni[2]) << 16; + /* FALLTHRU */ + case 2: + b |= ((uint64_t)ni[1]) << 8; + /* FALLTHRU */ + case 1: + b |= ((uint64_t)ni[0]); + break; + case 0: + break; + } + + v3 ^= b; + + TRACE; + for (i = 0; i < cROUNDS; ++i) + SIPROUND; + + v0 ^= b; + + if (outlen == 16) + v2 ^= 0xee; + else + v2 ^= 0xff; + + TRACE; + for (i = 0; i < dROUNDS; ++i) + SIPROUND; + + b = v0 ^ v1 ^ v2 ^ v3; + U64TO8_LE(out, b); + + if (outlen == 8) + return 0; + + v1 ^= 0xdd; + + TRACE; + for (i = 0; i < dROUNDS; ++i) + SIPROUND; + + b = v0 ^ v1 ^ v2 ^ v3; + U64TO8_LE(out + 8, b); + + return 0; +} diff --git a/fm/siphash.h b/fm/siphash.h new file mode 100644 index 0000000000..3fbd378068 --- /dev/null +++ b/fm/siphash.h @@ -0,0 +1,22 @@ +/* + SipHash reference C implementation + + Copyright (c) 2012-2021 Jean-Philippe Aumasson + + Copyright (c) 2012-2014 Daniel J. Bernstein + + To the extent possible under law, the author(s) have dedicated all copyright + and related and neighboring rights to this software to the public domain + worldwide. This software is distributed without any warranty. + + You should have received a copy of the CC0 Public Domain Dedication along + with + this software. If not, see + . + */ + +#include +#include + +int siphash(const void *in, const size_t inlen, const void *k, uint8_t *out, + const size_t outlen);