Skip to content

Commit

Permalink
Roll back siphash, fix version output (#67)
Browse files Browse the repository at this point in the history
* Roll back siphash, fix version output

* unref
  • Loading branch information
eisenhauer authored Oct 28, 2023
1 parent 6ba5b10 commit e8989c2
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 231 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ else()
endif()

set(FM_SRC_LIST
fm_formats.c fm_dump.c siphash.c string_conversion.c fm_get.c xml.c
fm_formats.c fm_dump.c lookup3.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} )
Expand Down
Binary file removed ffs/output_dir/context_test_output.osx-3.bin
Binary file not shown.
Binary file removed ffs/output_dir/file_output.osx-v3.bin
Binary file not shown.
Binary file removed ffs/output_dir/index_output.osx-v3.bin
Binary file not shown.
38 changes: 15 additions & 23 deletions fm/fm_formats.c
Original file line number Diff line number Diff line change
Expand Up @@ -1946,20 +1946,12 @@ register_data_format(FMContext context, FMStructDescList struct_list)

INT4 FFS_self_server_IP_addr = 0;

#include "siphash.h"

static void hashlittle2(
const void *data, /* the data to hash */
size_t length, /* length of the data */
extern void hashlittle2(
const void *key, /* the key to hash */
size_t length, /* length of the key */
INT4 *pc, /* IN: primary initval, OUT: primary hash */
INT4 *pb)
{
static const uint64_t skey[2] = {0xECB8FF2F434B2FBB, 0xB4E298A99A71F723 };
INT4 output[2];
siphash(data, length, &skey, (uint8_t*) &output[0], sizeof(output));
*pc = output[0];
*pb = output[1];
}
INT4 *pb) /* IN: secondary initval, OUT: secondary hash */;


extern void
generate_format3_server_ID(server_ID_type *server_ID,
Expand Down Expand Up @@ -1990,7 +1982,7 @@ generate_format3_server_ID(server_ID_type *server_ID,
((version_3_format_ID *) server_ID->value)->rep_len =
htons((short)(server_format_rep_length >> 2)); // Mod length by 4
((version_3_format_ID *) server_ID->value)->top_byte_rep_len = (unsigned char)
htons((short)(server_format_rep_length >> 18)); // Essentially, we capture the top 26 bytes of the server length
0xff & (server_format_rep_length >> 18);
((version_3_format_ID *) server_ID->value)->hash1 = htonl(hash1);
((version_3_format_ID *) server_ID->value)->hash2 = htonl(hash2);
}
Expand Down Expand Up @@ -3961,11 +3953,12 @@ stringify_server_ID(unsigned char *ID, char *buffer, int len)
break;
}
case 2:{
version_2_format_ID *id2 = (version_2_format_ID*)ID;
version_3_format_ID *id3 = (version_3_format_ID*)ID;
if (len < 3+3+6+10+6+50) /* approx size */ return;
snprintf(buffer, len, "<ID ver=%d, unused %d, rep_len %d, hash1 %x, hash2 %x>\n",
id2->version, id2->unused, ntohs(id2->rep_len) << 2,
ntohl(id2->hash1), ntohl(id2->hash2));
int rep_len = get_rep_len_format_ID(ID);
snprintf(buffer, len, "<ID ver=%d, rep_len %d, hash1 %x, hash2 %x>\n",
id3->version, rep_len,
ntohl(id3->hash1), ntohl(id3->hash2));
break;
}
default:
Expand Down Expand Up @@ -4029,11 +4022,10 @@ get_rep_len_format_ID(void *format_ID)
{
switch (version_of_format_ID(format_ID)) {
case 2:{
version_2_format_ID *id2 = (version_2_format_ID *) format_ID;
short tmp;
memcpy(&tmp, &id2->rep_len, 2);
tmp = ntohs(tmp);
return tmp << 2;
version_3_format_ID *id3 = (version_3_format_ID *) format_ID;
int rep_len = htons(id3->rep_len);
rep_len += (id3->top_byte_rep_len << 16);
return rep_len << 2;
}
case 0:
case 1:
Expand Down
185 changes: 0 additions & 185 deletions fm/siphash.c

This file was deleted.

22 changes: 0 additions & 22 deletions fm/siphash.h

This file was deleted.

0 comments on commit e8989c2

Please sign in to comment.