Crypt module (#549)

- Moved cryptography code out of Tactility project and into a kernel module.
- Converted C++ code to C style interface
- Hardened security
This commit is contained in:
Ken Van Hoeylandt
2026-07-05 11:17:42 +02:00
committed by GitHub
parent 9d5993930d
commit dfaeb9a2d9
229 changed files with 482 additions and 112246 deletions
+25
View File
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: Apache-2.0
#include <tactility/hash.h>
uint32_t djb2_str(const char* str) {
uint32_t hash = 5381;
char c = (char)*str++;
while (c != 0) {
hash = ((hash << 5) + hash) + (uint32_t)c; // hash * 33 + c
c = (char)*str++;
}
return hash;
}
uint32_t djb2_data(const void* data, size_t length) {
uint32_t hash = 5381;
auto* data_bytes = static_cast<const uint8_t*>(data);
uint8_t c = *data_bytes++;
size_t index = 0;
while (index < length) {
hash = ((hash << 5) + hash) + (uint32_t)c; // hash * 33 + c
c = *data_bytes++;
index++;
}
return hash;
}