summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hash/ntapi_tt_crc64.c49
-rw-r--r--src/internal/ntapi.c6
-rw-r--r--src/internal/ntapi_fnapi.h5
3 files changed, 60 insertions, 0 deletions
diff --git a/src/hash/ntapi_tt_crc64.c b/src/hash/ntapi_tt_crc64.c
new file mode 100644
index 0000000..fd76ec5
--- /dev/null
+++ b/src/hash/ntapi_tt_crc64.c
@@ -0,0 +1,49 @@
+/********************************************************/
+/* ntapi: Native API core library */
+/* Copyright (C) 2013--2017 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
+/********************************************************/
+
+#include <psxtypes/psxtypes.h>
+#include <ntapi/nt_crc64.h>
+
+static const uint64_t crc64_table[256] = NTAPI_CRC64_TABLE;
+
+uint64_t __ntapi_tt_buffer_crc64(
+ uint64_t prev_hash,
+ const void * buffer,
+ size_t size)
+{
+ const unsigned char * ch;
+ uint64_t crc64;
+
+ crc64 = prev_hash ^ 0xFFFFFFFFFFFFFFFF;
+ ch = buffer;
+
+ for (; size; size--,ch++)
+ crc64 = (crc64 >> 8) ^ crc64_table[(crc64 ^ *ch) & 0xFF];
+
+ return (crc64 ^ 0xFFFFFFFFFFFFFFFF);
+}
+
+uint64_t __cdecl __ntapi_tt_mbstr_crc64(const void * str)
+{
+ const unsigned char * ch;
+ uint64_t crc64;
+
+ crc64 = 0 ^ 0xFFFFFFFFFFFFFFFF;
+ ch = str;
+
+ while (*ch) {
+ crc64 = (crc64 >> 8) ^ crc64_table[(crc64 ^ *ch) & 0xFF];
+ ch++;
+ }
+
+ return (crc64 ^ 0xFFFFFFFFFFFFFFFF);
+}
+
+
+const uint64_t * __cdecl __ntapi_tt_crc64_table(void)
+{
+ return crc64_table;
+}
diff --git a/src/internal/ntapi.c b/src/internal/ntapi.c
index c3f5817..5c60ffd 100644
--- a/src/internal/ntapi.c
+++ b/src/internal/ntapi.c
@@ -9,6 +9,7 @@
#include <ntapi/nt_status.h>
#include <ntapi/nt_crc32.h>
+#include <ntapi/nt_crc64.h>
#include <ntapi/nt_object.h>
#include <ntapi/nt_sysinfo.h>
#include <ntapi/nt_memory.h>
@@ -152,6 +153,11 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl)
__ntapi->tt_mbstr_crc32 = __ntapi_tt_mbstr_crc32;
__ntapi->tt_crc32_table = __ntapi_tt_crc32_table;
+ /* nt_crc64.h */
+ __ntapi->tt_buffer_crc64 = __ntapi_tt_buffer_crc64;
+ __ntapi->tt_mbstr_crc64 = __ntapi_tt_mbstr_crc64;
+ __ntapi->tt_crc64_table = __ntapi_tt_crc64_table;
+
/* nt_file.h */
__ntapi->tt_get_file_handle_type = __ntapi_tt_get_file_handle_type;
__ntapi->tt_open_logical_parent_directory = __ntapi_tt_open_logical_parent_directory;
diff --git a/src/internal/ntapi_fnapi.h b/src/internal/ntapi_fnapi.h
index 75621f7..93e38bd 100644
--- a/src/internal/ntapi_fnapi.h
+++ b/src/internal/ntapi_fnapi.h
@@ -32,6 +32,11 @@ ntapi_tt_buffer_crc32 __ntapi_tt_buffer_crc32;
ntapi_tt_mbstr_crc32 __ntapi_tt_mbstr_crc32;
ntapi_tt_crc32_table __ntapi_tt_crc32_table;
+/* nt_crc64.h */
+ntapi_tt_buffer_crc64 __ntapi_tt_buffer_crc64;
+ntapi_tt_mbstr_crc64 __ntapi_tt_mbstr_crc64;
+ntapi_tt_crc64_table __ntapi_tt_crc64_table;
+
/* nt_file.h */
ntapi_tt_get_file_handle_type __ntapi_tt_get_file_handle_type;
ntapi_tt_open_logical_parent_directory __ntapi_tt_open_logical_parent_directory;