From vaptvupt-codec tag v2.65.3. Output is byte-identical to 2.65.0 (same ratio, wire format v1.6 unchanged) but extreme-mode encode is ~1.6-2x faster (Sprint 132 optimal-parser speedup) and the extreme prepass window allocation is capped at wlog=20 = 8 MiB virtual instead of up to 128 MiB (Sprint 133 memory hygiene). Our AVX2 offset-read decoder guard is now UPSTREAM (dropped from the local patch set); the ANS safe-zone 2*SAFEZONE_MAX_RUN reserve is re-applied on top (still not upstream). make check 16/16, KAT 16/16, cross- version roundtrip with 5.1.0 archives verified.
49 lines
1.7 KiB
C
49 lines
1.7 KiB
C
/*
|
||
* Zupt — Backup-oriented compression with AES-256 encryption
|
||
* Copyright (c) 2026 Cristian Cezar Moisés
|
||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||
*
|
||
* Keccak-f[1600] sponge: SHA3-256, SHA3-512, SHAKE-128, SHAKE-256
|
||
* Required by ML-KEM-768 (FIPS 203).
|
||
* Pure C11, zero dependencies, no dynamic allocation.
|
||
*/
|
||
#ifndef ZUPT_KECCAK_H
|
||
#define ZUPT_KECCAK_H
|
||
|
||
#include <stdint.h>
|
||
#include <stddef.h>
|
||
|
||
/* Sponge state: 25 × 64-bit lanes = 200 bytes */
|
||
typedef struct {
|
||
uint64_t st[25];
|
||
uint8_t buf[200]; /* absorption buffer */
|
||
size_t rate; /* rate in bytes */
|
||
size_t pt; /* position in buf */
|
||
uint8_t dsuf; /* domain suffix: 0x06 for SHA3, 0x1F for SHAKE */
|
||
} zupt_keccak_ctx;
|
||
|
||
/* SHA3-256: 32-byte output */
|
||
void zupt_sha3_256(const uint8_t *data, size_t len, uint8_t out[32]);
|
||
|
||
/* SHA3-512: 64-byte output */
|
||
void zupt_sha3_512(const uint8_t *data, size_t len, uint8_t out[64]);
|
||
|
||
/* SHAKE-128: extendable output */
|
||
void zupt_shake128(const uint8_t *data, size_t dlen, uint8_t *out, size_t olen);
|
||
|
||
/* SHAKE-256: extendable output */
|
||
void zupt_shake256(const uint8_t *data, size_t dlen, uint8_t *out, size_t olen);
|
||
|
||
/* Incremental SHAKE-128 for ML-KEM sampling */
|
||
void zupt_shake128_init(zupt_keccak_ctx *ctx);
|
||
void zupt_shake128_absorb(zupt_keccak_ctx *ctx, const uint8_t *data, size_t len);
|
||
void zupt_shake128_finalize(zupt_keccak_ctx *ctx);
|
||
void zupt_shake128_squeeze(zupt_keccak_ctx *ctx, uint8_t *out, size_t len);
|
||
|
||
/* Incremental SHAKE-256 */
|
||
void zupt_shake256_init(zupt_keccak_ctx *ctx);
|
||
void zupt_shake256_absorb(zupt_keccak_ctx *ctx, const uint8_t *data, size_t len);
|
||
void zupt_shake256_finalize(zupt_keccak_ctx *ctx);
|
||
void zupt_shake256_squeeze(zupt_keccak_ctx *ctx, uint8_t *out, size_t len);
|
||
|
||
#endif
|