- Add arena allocator for zero-allocation hot paths - Add thread pool for parallel operations - Add mmap utilities for memory-mapped I/O - Implement queue_index with heap-based priority queue - Implement dataset_hash with SIMD support (SHA-NI, ARMv8) - Add runtime SIMD detection for cross-platform correctness - Add comprehensive tests and benchmarks
28 lines
759 B
C
28 lines
759 B
C
#pragma once
|
|
#include "sha256_base.h"
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
// SHA256 state - just data
|
|
struct Sha256State {
|
|
uint32_t state[8];
|
|
uint8_t buffer[64];
|
|
size_t buffer_len;
|
|
uint64_t total_len;
|
|
TransformFunc transform_fn;
|
|
};
|
|
|
|
// Initialize hasher
|
|
void sha256_init(Sha256State* hasher);
|
|
|
|
// Incremental hashing
|
|
void sha256_update(Sha256State* hasher, const uint8_t* data, size_t len);
|
|
void sha256_finalize(Sha256State* hasher, uint8_t out[32]);
|
|
|
|
// Convenience: hash entire buffer at once
|
|
// out_hex must be 65 bytes (64 hex chars + null)
|
|
void sha256_hash_to_hex(const uint8_t* data, size_t len, char* out_hex);
|
|
|
|
// Get currently used implementation name
|
|
const char* sha256_impl_name(void);
|
|
int sha256_has_hardware_accel(void);
|