fetch_ml/native/dataset_hash/crypto/sha256_hasher.h
Jeremie Fraeys 43d241c28d
feat: implement C++ native libraries for performance-critical operations
- 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
2026-02-16 20:38:04 -05:00

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);