-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegrity.h
More file actions
35 lines (31 loc) · 1.36 KB
/
integrity.h
File metadata and controls
35 lines (31 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef INTEGRITY_H
#define INTEGRITY_H
#include <stdint.h> // for uint64_t, uint8_t
#include <stdio.h> // for sprintf (used in to_hex)
#include <string.h> // for strlen
// -------------------------------------------------------
// Converts raw hash bytes to a printable hex string
// Example: [0xAB, 0x4F] -> "ab4f"
// -------------------------------------------------------
void to_hex(const unsigned char *hash, int len, char *output);
// -------------------------------------------------------
// Custom Key-Mixed Rolling Hash Function
// -------------------------------------------------------
// Parameters:
// data - input data (binary data to hash)
// datalen - length of input data in bytes
// key - secret key (used as dynamic modifier)
// hash - output buffer for hash bytes
// hash_len - number of hash bytes to generate (e.g., 8, 16)
//
// Description:
// - Uses the key to alter each round of hashing.
// - Introduces feedback, shifts, and XOR to increase diffusion.
// - Produces consistent but unique hash for each data-key pair.
// -------------------------------------------------------
void key_mixed_rolling_hash(const char *data,
int datalen,
const char *key,
unsigned char *hash,
int hash_len);
#endif // INTEGRITY_H