identity: the SD-JWT form of an AERE hybrid identity is judged on its ML-DSA-65 half by default, the Ed25519 half only on explicit request, and every verdict says postQuantum (rule sdjwt.hybrid-half); pq-pki: the signature algorithm a certificate or a revocation list declares must be its issuer key's (ALG_KEY, CRL_ALG_KEY); agents: an equivocation proof requires the agent's ML-DSA-65 key; pq-gateway: the status names the path to the backend and hybrid-only refuses a plain-HTTP backend; conformance 241 rules, 631 vectors
This commit is contained in:
1 parent
3ff21f7758
commit
0c8f1de3fd
122 files changed
+1205
-262
No files matched your search
@@ -18,6 +18,13 @@
|
||||
// client), deci gateway-ul nu spune per conexiune ce grup s-a folosit. In hybrid-only nu are nevoie (e singurul grup);
|
||||
// in hybrid-preferred punctul de stare spune explicit ca nu poate spune, si nu numara conexiuni "hibride".
|
||||
//
|
||||
// DRUMUL CATRE SERVICIUL DIN SPATE (2026-10-19, AIP-25 constatarea C8): aici gateway-ul e CLIENT, deci isi poate citi
|
||||
// strangerile de mana. Pana atunci drumul prefera hibridul cu TLS 1.2 minim (sau era HTTP simplu) si starea nu spunea nimic
|
||||
// despre el. Acum: (1) starea spune, sub `upstream`, modul, versiunea minima, grupurile oferite, garantia (sau lipsa ei) si
|
||||
// strangerile de mana numarate pe protocol si grup; (2) AERE_PQGW_UPSTREAM_MODE=hybrid-only ofera serviciului NUMAI
|
||||
// X25519MLKEM768 peste TLS 1.3 (un serviciu fara el primeste 502), si refuza sa porneasca cu un UPSTREAM http. Implicitul ramane
|
||||
// hybrid-preferred, comportamentul de dinainte.
|
||||
//
|
||||
// Configuratie: variabile AERE_PQGW_* (lista in CHEI, mai jos, si in README), optional un fisier JSON dat prin
|
||||
// AERE_PQGW_CONFIG; mediul are prioritate fata de fisier. O cheie necunoscuta in fisier e o eroare, nu o tacere.
|
||||
//
|
||||
@@ -57,6 +64,7 @@ const CHEI = {
|
||||
AERE_PQGW_KEY: 'key',
|
||||
AERE_PQGW_UPSTREAM: 'upstream',
|
||||
AERE_PQGW_UPSTREAM_CA: 'upstreamCa',
|
||||
AERE_PQGW_UPSTREAM_MODE: 'upstreamMode',
|
||||
AERE_PQGW_MODE: 'mode',
|
||||
AERE_PQGW_CONNECT_TIMEOUT_MS: 'connectTimeoutMs',
|
||||
AERE_PQGW_REQUEST_TIMEOUT_MS: 'requestTimeoutMs',
|
||||
@@ -124,12 +132,17 @@ export function citesteConfig(env = process.env) {
|
||||
if (u.protocol !== 'http:' && u.protocol !== 'https:') throw new Error('UPSTREAM must start with http:// or https://');
|
||||
if (u.username || u.password) throw new Error('UPSTREAM must not contain credentials');
|
||||
if (u.search || u.hash) throw new Error('UPSTREAM must not contain a query string or fragment');
|
||||
// AIP-25 C8: modul drumului catre upstream; hybrid-only nu are inteles pe HTTP simplu (acolo nu exista niciun schimb de chei)
|
||||
const upstreamMode = v('AERE_PQGW_UPSTREAM_MODE', 'hybrid-preferred');
|
||||
if (!Object.prototype.hasOwnProperty.call(GRUPURI, upstreamMode)) throw new Error('UPSTREAM_MODE must be hybrid-only or hybrid-preferred');
|
||||
if (upstreamMode === 'hybrid-only' && u.protocol !== 'https:') throw new Error('UPSTREAM_MODE hybrid-only requires an https:// UPSTREAM (plain http has no key exchange at all)');
|
||||
const { host, port } = citesteAdresa(v('AERE_PQGW_LISTEN', ':8443'));
|
||||
const maxHeaderSize = v('AERE_PQGW_MAX_HEADER_SIZE', null);
|
||||
return {
|
||||
host, port, cert, key, mode,
|
||||
upstream: u.href,
|
||||
upstreamCa: v('AERE_PQGW_UPSTREAM_CA', null),
|
||||
upstreamMode,
|
||||
connectTimeoutMs: intreg('CONNECT_TIMEOUT_MS', v('AERE_PQGW_CONNECT_TIMEOUT_MS', 5000), 100, 600000),
|
||||
requestTimeoutMs: intreg('REQUEST_TIMEOUT_MS', v('AERE_PQGW_REQUEST_TIMEOUT_MS', 60000), 100, 3600000),
|
||||
handshakeTimeoutMs: intreg('HANDSHAKE_TIMEOUT_MS', v('AERE_PQGW_HANDSHAKE_TIMEOUT_MS', 10000), 100, 600000),
|
||||
@@ -250,10 +263,24 @@ export function pornesteGateway(cfg, { jurnal = scrieJurnal } = {}) {
|
||||
if (susHttps && cfg.upstreamCa) {
|
||||
try { caSus = fs.readFileSync(cfg.upstreamCa); } catch (e) { throw new Error(`cannot read UPSTREAM_CA (${e.code || 'error'})`); }
|
||||
}
|
||||
// Si drumul catre upstream, cand e https, prefera hibridul; nu se afirma nimic despre el in stare.
|
||||
// Drumul catre upstream, cand e https (AIP-25 C8): hybrid-preferred (implicit, ca pana acum) ofera intai hibridul si primeste
|
||||
// TLS 1.2; hybrid-only ofera numai X25519MLKEM768 peste TLS 1.3. Ce s-a negociat se numara (numaraStrangereSus) si se spune in stare.
|
||||
const modSus = cfg.upstreamMode || 'hybrid-preferred';
|
||||
const minSus = modSus === 'hybrid-only' ? 'TLSv1.3' : 'TLSv1.2';
|
||||
const agent = susHttps
|
||||
? new https.Agent({ keepAlive: true, minVersion: 'TLSv1.2', ecdhCurve: GRUPURI['hybrid-preferred'], ...(caSus ? { ca: caSus } : {}) })
|
||||
? new https.Agent({ keepAlive: true, minVersion: minSus, ecdhCurve: GRUPURI[modSus], ...(caSus ? { ca: caSus } : {}) })
|
||||
: new http.Agent({ keepAlive: true });
|
||||
const strangeriSus = new Map();
|
||||
// Node numeste pe client X25519 si P-256 (getEphemeralKeyInfo) si NU numeste grupul hibrid (masurat 2026-09-25: {}), deci o
|
||||
// strangere TLS 1.3 fara nume e X25519MLKEM768, singurul alt grup oferit; in TLS 1.2 nu exista hibrid.
|
||||
function numaraStrangereSus(s) {
|
||||
let protocol = null, eki = null;
|
||||
try { protocol = s.getProtocol(); eki = s.getEphemeralKeyInfo(); } catch { /* socket deja inchis */ }
|
||||
const grup = eki && eki.name ? (eki.name === 'prime256v1' ? 'P-256' : eki.name) : protocol === 'TLSv1.3' ? 'X25519MLKEM768' : 'unnamed';
|
||||
const k = `${protocol || 'unknown'} ${grup}`;
|
||||
strangeriSus.set(k, (strangeriSus.get(k) || 0) + 1);
|
||||
}
|
||||
const numarSus = (pq) => [...strangeriSus].filter(([k]) => /MLKEM/.test(k) === pq).reduce((a, [, n]) => a + n, 0);
|
||||
const caUpgrade = caSus ? { ca: caSus } : {};
|
||||
|
||||
const c = {
|
||||
@@ -288,7 +315,17 @@ export function pornesteGateway(cfg, { jurnal = scrieJurnal } = {}) {
|
||||
negotiatedGroupPerConnection: 'not reported: the Node.js TLS server API does not expose the negotiated group (getEphemeralKeyInfo is client-side only), so this gateway makes no per-connection claim',
|
||||
certificate: { sha256: x509.fingerprint256, subject: x509.subject, notAfter: x509.validTo,
|
||||
authentication: lantCert.autentificare, chain: lantCert.lant },
|
||||
upstream: { scheme: susHttps ? 'https' : 'http', encrypted: susHttps },
|
||||
// AIP-25 C8: drumul catre serviciul din spate, din ce a masurat gateway-ul (strangerile numarate), nu din ce spera
|
||||
upstream: susHttps
|
||||
? {
|
||||
scheme: 'https', encrypted: true, mode: modSus, minTlsVersion: minSus, groupsOffered: grupuriOferite(modSus), groupPreference: GRUPURI[modSus],
|
||||
guarantee: modSus === 'hybrid-only'
|
||||
? { hybridKeyExchangeOnEveryConnection: true, basis: 'structural: X25519MLKEM768 over TLS 1.3 is the only key exchange offered to the service, so a connection that does not use it fails (502)' }
|
||||
: { hybridKeyExchangeOnEveryConnection: false, basis: 'X25519MLKEM768 is offered first; a service without it gets X25519 or P-256, and TLS 1.2 is accepted: the handshakes below say what happened' },
|
||||
handshakes: Object.fromEntries(strangeriSus), postQuantumHandshakes: numarSus(true), classicalHandshakes: numarSus(false),
|
||||
handshakeGroupBasis: 'read on each new TLS connection to the service: Node names X25519 and P-256 (getEphemeralKeyInfo) and names no hybrid group, so a TLS 1.3 handshake whose group it does not name is X25519MLKEM768, the only other group offered',
|
||||
}
|
||||
: { scheme: 'http', encrypted: false, mode: null, guarantee: { hybridKeyExchangeOnEveryConnection: false, basis: 'plain HTTP: the leg from the gateway to the service is not encrypted at all; keep it on the same host or a private network, or use https with UPSTREAM_MODE hybrid-only' } },
|
||||
runtime: { node: process.version, openssl: process.versions.openssl },
|
||||
startedAt: pornitLa,
|
||||
counters: {
|
||||
@@ -356,7 +393,7 @@ export function pornesteGateway(cfg, { jurnal = scrieJurnal } = {}) {
|
||||
method: req.method, path: req.url === '*' ? '*' : prefix + req.url,
|
||||
headers: anteturi, setHost: false,
|
||||
agent: peUpgrade ? false : agent,
|
||||
...(peUpgrade && susHttps ? { minVersion: 'TLSv1.2', ecdhCurve: GRUPURI['hybrid-preferred'], ...caUpgrade } : {}),
|
||||
...(peUpgrade && susHttps ? { minVersion: minSus, ecdhCurve: GRUPURI[modSus], ...caUpgrade } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -369,6 +406,7 @@ export function pornesteGateway(cfg, { jurnal = scrieJurnal } = {}) {
|
||||
const expirat = (tip) => Object.assign(new Error(`upstream ${tip} timeout`), { aereTimeout: tip });
|
||||
upReq.on('socket', (s) => {
|
||||
if (!s.connecting) return;
|
||||
if (susHttps) s.once('secureConnect', () => numaraStrangereSus(s)); // AIP-25 C8: fiecare conexiune noua, o data
|
||||
tConectare = setTimeout(() => upReq.destroy(expirat('connect')), cfg.connectTimeoutMs);
|
||||
s.once(susHttps ? 'secureConnect' : 'connect', () => { clearTimeout(tConectare); tConectare = null; });
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user