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:
Aere Network committed 2026-10-19 05:19:21 +03:00
1 parent 3ff21f7758
commit 0c8f1de3fd
122 files changed
+1205 -262

No files matched your search

+48 -4
View File
@@ -318,8 +318,9 @@ function laUpgrade(req, sock, head) {
if (head && head.length) sock.write(head);
sock.on('data', (d) => sock.write(d));
}
function pornesteUpstreamHttps() {
const srv = https.createServer({ key: CHEIE_PEM, cert: CERT_PEM }, ecou);
// extra (2026-10-19, AIP-25 C8): un upstream care stie numai grupuri clasice (ecdhCurve) sau numai TLS 1.2 (maxVersion)
function pornesteUpstreamHttps(extra = {}) {
const srv = https.createServer({ key: CHEIE_PEM, cert: CERT_PEM, ...extra }, ecou);
srv.on('upgrade', laUpgrade);
deInchis.push(srv);
return new Promise((r) => srv.listen(0, GAZDA, () => r(srv.address().port)));
@@ -720,8 +721,48 @@ await test('(q) upstream https cu AERE_PQGW_UPSTREAM_CA: cererea trece, iar drum
cere(final && final.grup === HIBRID, `drumul catre upstream: ${descrieSH(f.sh)}`);
const s = await stare(GS.port);
cere(s.upstream && s.upstream.scheme === 'https' && s.upstream.encrypted === true, `starea: ${JSON.stringify(s.upstream)}`);
cere(JSON.stringify(Object.keys(s.upstream)) === '["scheme","encrypted"]', `starea spune despre upstream mai mult decat schema: ${JSON.stringify(s.upstream)}`);
return `drum catre upstream: ${descrieSH(f.sh)}`;
// 2026-10-19 (AIP-25 C8): starea spune si drumul catre upstream, din ce a MASURAT gateway-ul (strangerile de mana numarate), nu din ce
// spera: implicit hybrid-preferred, TLS 1.2 minim, fara garantie; strangerea de aici, citita de pe fir drept hibrid, e numarata hibrid
const u = s.upstream;
cere(u.mode === 'hybrid-preferred' && u.minTlsVersion === 'TLSv1.2' && u.guarantee && u.guarantee.hybridKeyExchangeOnEveryConnection === false, `starea drumului catre upstream: ${JSON.stringify(u).slice(0, 300)}`);
cere(u.handshakes && u.handshakes['TLSv1.3 X25519MLKEM768'] >= 1 && u.postQuantumHandshakes >= 1 && u.classicalHandshakes === 0, `strangerile catre upstream numarate: ${JSON.stringify(u.handshakes)} pq ${u.postQuantumHandshakes} clasice ${u.classicalHandshakes}`);
return `drum catre upstream: ${descrieSH(f.sh)}; starea: ${JSON.stringify(u.handshakes)}`;
});
await test('(q3) AIP-25 C8: drumul catre upstream in starea gateway-ului: http -> necriptat, fara garantie; hybrid-preferred catre un upstream numai X25519 -> 200 si strangerea CLASICA numarata (starea nu mai tace)', async () => {
const sh = await stare(GH.port);
cere(sh.upstream && sh.upstream.scheme === 'http' && sh.upstream.encrypted === false && sh.upstream.guarantee && sh.upstream.guarantee.hybridKeyExchangeOnEveryConnection === false && /plain HTTP/.test(sh.upstream.guarantee.basis), `starea unui upstream http: ${JSON.stringify(sh.upstream)}`);
const portClasic = await pornesteUpstreamHttps({ ecdhCurve: 'X25519' });
const g = await pornesteGw('gateway catre upstream numai X25519', { AERE_PQGW_LISTEN: `${GAZDA}:0`, AERE_PQGW_CERT: CALE_CERT, AERE_PQGW_KEY: CALE_CHEIE, AERE_PQGW_MODE: 'hybrid-only', AERE_PQGW_UPSTREAM: `https://${GAZDA}:${portClasic}`, AERE_PQGW_UPSTREAM_CA: CALE_CERT });
const r = await cerere({ port: g.port, cale: '/q3' });
cere(r.status === 200 && json(r).url === '/q3', `status ${r.status}`);
const s = await stare(g.port); const u = s.upstream;
cere(u.handshakes && u.handshakes['TLSv1.3 X25519'] >= 1 && u.classicalHandshakes >= 1 && u.postQuantumHandshakes === 0, `strangerea clasica nu e numarata: ${JSON.stringify(u.handshakes)} pq ${u.postQuantumHandshakes} clasice ${u.classicalHandshakes}`);
return `upstream http: ${sh.upstream.guarantee.basis.slice(0, 60)}...; upstream numai X25519: ${JSON.stringify(u.handshakes)}`;
});
await test('(q4) AIP-25 C8: UPSTREAM_MODE hybrid-only: catre un upstream cu hibrid -> 200, pe fir X25519MLKEM768, starea cu garantie; catre unul numai X25519 sau numai TLS 1.2 -> 502, nicio strangere clasica numarata', async () => {
const baza = { AERE_PQGW_LISTEN: `${GAZDA}:0`, AERE_PQGW_CERT: CALE_CERT, AERE_PQGW_KEY: CALE_CHEIE, AERE_PQGW_MODE: 'hybrid-only', AERE_PQGW_UPSTREAM_MODE: 'hybrid-only', AERE_PQGW_UPSTREAM_CA: CALE_CERT };
const [portClasic, port12] = await Promise.all([pornesteUpstreamHttps({ ecdhCurve: 'X25519' }), pornesteUpstreamHttps({ maxVersion: 'TLSv1.2' })]);
const [gh, gc, g12] = await Promise.all([
pornesteGw('gateway UPSTREAM_MODE hybrid-only catre upstream cu hibrid', { ...baza, AERE_PQGW_UPSTREAM: `https://${GAZDA}:${TS.port}` }),
pornesteGw('gateway UPSTREAM_MODE hybrid-only catre upstream numai X25519', { ...baza, AERE_PQGW_UPSTREAM: `https://${GAZDA}:${portClasic}` }),
pornesteGw('gateway UPSTREAM_MODE hybrid-only catre upstream numai TLS 1.2', { ...baza, AERE_PQGW_UPSTREAM: `https://${GAZDA}:${port12}` }),
]);
const inainte = TS.conexiuni.length;
const r = await cerere({ port: gh.port, cale: '/q4' });
cere(r.status === 200 && json(r).url === '/q4', `catre upstream cu hibrid: status ${r.status}`);
const f = citesteFir(TS.conexiuni[inainte] || { c2s: [], s2c: [] });
cere(f.ch.length >= 1 && f.ch[0].grupuri.join() === String(HIBRID) && !f.ch[0].versiuni.includes(0x0303), `gateway-ul a oferit upstream-ului ${f.ch[0] ? f.ch[0].grupuri.map(numeGrup) + ' / ' + f.ch[0].versiuni.map((x) => x.toString(16)) : '-'}`);
const sh = await stare(gh.port);
cere(sh.upstream.mode === 'hybrid-only' && sh.upstream.minTlsVersion === 'TLSv1.3' && sh.upstream.guarantee.hybridKeyExchangeOnEveryConnection === true && sh.upstream.postQuantumHandshakes >= 1, `starea: ${JSON.stringify(sh.upstream).slice(0, 300)}`);
const note = [];
for (const [g, nume] of [[gc, 'numai X25519'], [g12, 'numai TLS 1.2']]) {
const rr = await cerere({ port: g.port, cale: '/q4-refuz' });
cere(rr.status === 502 && json(rr).error === 'bad_gateway', `catre upstream ${nume}: status ${rr.status}`);
const s = await stare(g.port);
cere(s.upstream.classicalHandshakes === 0 && s.counters.responses502 >= 1, `catre upstream ${nume}: ${JSON.stringify(s.upstream.handshakes)} 502=${s.counters.responses502}`);
const rand = g.jurnal.filter((j) => j.event === 'upstream_error').pop(); note.push(`${nume}: 502 (${rand ? rand.code : '?'})`);
}
return `catre upstream cu hibrid: ${descrieSH(f.sh)}; ${note.join('; ')}`;
});
await test('(q2) upstream https cu certificat pe care gateway-ul nu il poate verifica (fara UPSTREAM_CA): 502, nicio incredere oarba', async () => {
@@ -833,6 +874,9 @@ await test('(p) configuratie gresita: refuza sa porneasca, cu motivul numit, si
['MODE necunoscut', { ...baza, AERE_PQGW_MODE: 'classic' }, 2, /MODE must be/],
['cheie in fisier gresita', { ...baza, AERE_PQGW_MODE: 'hybrid-only', AERE_PQGW_CONFIG: fisRau }, 2, /unknown key in config file: upstrem/],
['cheia nu se potriveste cu certificatul', { ...baza, AERE_PQGW_MODE: 'hybrid-only', AERE_PQGW_KEY: caleAlta }, 1, /KEY does not match/],
// 2026-10-19 (AIP-25 C8): modul drumului catre upstream
['UPSTREAM_MODE necunoscut', { ...baza, AERE_PQGW_MODE: 'hybrid-only', AERE_PQGW_UPSTREAM_MODE: 'classic' }, 2, /UPSTREAM_MODE must be/],
['UPSTREAM_MODE hybrid-only cu un upstream http', { ...baza, AERE_PQGW_MODE: 'hybrid-only', AERE_PQGW_UPSTREAM_MODE: 'hybrid-only' }, 2, /UPSTREAM_MODE hybrid-only requires an https/],
];
const note = [];
for (const [nume, env, codAsteptat, motiv] of cazuri) {