Some checks failed
CI / build-and-test (clang) (push) Has been cancelled
CI / build-and-test (gcc) (push) Has been cancelled
CI / strict-warnings (clang, -Wall -Wextra -Wpedantic -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnull-dereference -O2 -std=c11 -Werror) (push) Has been cancelled
CI / strict-warnings (gcc, -Wall -Wextra -Wpedantic -Wshadow -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnull-dereference -Wformat-security -Wlogical-op -Wjump-misses-init -Wdouble-promotion -O2 -std=c11 -Werror) (push) Has been cancelled
CI / sanitizers (push) Has been cancelled
CI / pie-hardening (push) Has been cancelled
CI / cross-aarch64 (push) Has been cancelled
CI / dist-reproducibility (push) Has been cancelled
CI / packaging-syntax (push) Has been cancelled
CI / release (push) Has been cancelled
Major release. Highlights: - Codec: vendored VaptVupt codec moves to canonical 2.60.4 security release. Fixes a high-severity OOB heap write in the AVX2 decode fast path (reachable on a valid stream sized to exactly content_size, both tail variants). Brings CBMC-formally-verified BCJ filters with automatic ELF/PE/Mach-O detection. Compressed output stays byte-identical (ratio gate Δ 0.00%); wire format unchanged at v1.6. - New --pq-box sealed-box recipient mode (vendored libpqvaptvupt 0.6.0): ML-KEM-768 + X25519 combined via HKDF-SHA256 with domain separation, AES-256-CTR + HMAC-SHA256 EtM. Legacy --pq and --pq-sdk stay readable. - F-16: discloses and fixes a pre-existing data-loss defect in the <= 3.8.0 in-tree BCJ encoder. Full back-compat matrix decodes byte-exact under 4.0.0; every readable pre-4.0 archive remains readable. Repository hygiene: - Sync full 4.0.0 source tree (codec, crypto, SDK, GUI, packaging, tests). - Remove internal scratch files (PROMPT.md, FORMAL_AUDIT_PROMPT.md) and superseded version-specific docs (INTEGRATION_PROTOCOL_2.60.4.md, docs/FINDINGS-2.x.md) and a stray test binary. - Refresh README download/install section to real 4.0.0 release assets; bump version badge to 4.0.0. - Add .gitignore for build outputs (keeps vendored prebuilt libraries).
70 lines
2.4 KiB
C
70 lines
2.4 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
|
|
*
|
|
* ML-KEM-768 (FIPS 203, formerly CRYSTALS-Kyber).
|
|
* Post-quantum key encapsulation mechanism.
|
|
*
|
|
* Parameters (ML-KEM-768):
|
|
* k = 3, η₁ = 2, η₂ = 2, d_u = 10, d_v = 4
|
|
* Public key: 1184 bytes
|
|
* Secret key: 2400 bytes
|
|
* Ciphertext: 1088 bytes
|
|
* Shared secret: 32 bytes
|
|
*
|
|
* SECURITY NOTE: This implementation must undergo independent review
|
|
* before deployment in high-assurance contexts. It targets correctness
|
|
* against NIST test vectors and constant-time operation.
|
|
*/
|
|
#ifndef ZUPT_MLKEM_H
|
|
#define ZUPT_MLKEM_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#define MLKEM_K 3
|
|
#define MLKEM_N 256
|
|
#define MLKEM_Q 3329
|
|
#define MLKEM_ETA1 2
|
|
#define MLKEM_ETA2 2
|
|
#define MLKEM_DU 10
|
|
#define MLKEM_DV 4
|
|
|
|
#define MLKEM_PUBLICKEYBYTES 1184
|
|
#define MLKEM_SECRETKEYBYTES 2400
|
|
#define MLKEM_CIPHERTEXTBYTES 1088
|
|
#define MLKEM_SSBYTES 32
|
|
|
|
/* KeyGen: generate public/secret keypair.
|
|
* pk: output public key (1184 bytes)
|
|
* sk: output secret key (2400 bytes)
|
|
* Returns 0 on success. */
|
|
int zupt_mlkem768_keygen(uint8_t pk[MLKEM_PUBLICKEYBYTES],
|
|
uint8_t sk[MLKEM_SECRETKEYBYTES]);
|
|
|
|
/* Encapsulate: produce ciphertext and shared secret from public key.
|
|
* ct: output ciphertext (1088 bytes)
|
|
* ss: output shared secret (32 bytes)
|
|
* pk: input public key (1184 bytes)
|
|
* Returns 0 on success. */
|
|
int zupt_mlkem768_encaps(uint8_t ct[MLKEM_CIPHERTEXTBYTES],
|
|
uint8_t ss[MLKEM_SSBYTES],
|
|
const uint8_t pk[MLKEM_PUBLICKEYBYTES]);
|
|
|
|
/* Decapsulate: recover shared secret from ciphertext and secret key.
|
|
* ss: output shared secret (32 bytes)
|
|
* ct: input ciphertext (1088 bytes)
|
|
* sk: input secret key (2400 bytes)
|
|
* Returns 0 on success.
|
|
* CT-REQUIRED: Implicit rejection — invalid ciphertext produces a
|
|
* pseudorandom shared secret (no distinguishable failure). */
|
|
int zupt_mlkem768_decaps(uint8_t ss[MLKEM_SSBYTES],
|
|
const uint8_t ct[MLKEM_CIPHERTEXTBYTES],
|
|
const uint8_t sk[MLKEM_SECRETKEYBYTES]);
|
|
|
|
/* Self-test: NTT/iNTT roundtrip + CBD-sampler range invariants.
|
|
* Returns 1 on pass, 0 on fail. Called from test_vectors.c case 14
|
|
* (F-04, Zupt 2.2.4). */
|
|
int zupt_mlkem768_selftest(void);
|
|
|
|
#endif
|