device-identity: third adversarial review and its repairs (with the release left out of a bundle, the firmware the device attests is still judged against the manufacturer's policies; a verifier clock and every time read strictly as RFC 3339 UTC, days that do not exist refused; C1, DEL and direction marks escaped on the terminal; a key file is never overwritten); probe 372/372, negative control 220/220. conformance: the halves of the device verifier mapped again (263/263 under the negative control) and the present-tense counts brought to the measurement of 2026-10-14 (467 vectors, 467/467 with the AIP-23 verifier as served)

This commit is contained in:
Aere Network committed 2026-10-15 02:43:18 +03:00
1 parent ed4d3d79d8
commit 86779c8334
8 files changed
+263 -100

No files matched your search

+9 -3
View File
@@ -47,13 +47,19 @@ const toate = (f) => rest.flatMap((a, i) => (a === f && rest[i + 1] != null ? [r
const cere = (f) => { const v = get(f); if (v == null) throw new Folosire(`${cmd}: ${f} is required`); return v; };
const numar = (f, imp = null) => { const v = get(f); if (v == null) { if (imp === null) throw new Folosire(`${cmd}: ${f} is required`); return imp; } const n = Number(v); if (!Number.isInteger(n) || n < 0) throw new Folosire(`${cmd}: ${f} is a whole number`); return n; };
const citeste = (f) => { try { return JSON.parse(fs.readFileSync(f, 'utf8')); } catch (e) { throw new Folosire(`cannot read ${f}: ${e.message}`); } };
const scrie = (o, f, { secret = false } = {}) => { if (!f) throw new Folosire(`${cmd}: --out is required`); fs.writeFileSync(f, JSON.stringify(o, null, 1) + '\n', secret ? { mode: 0o600 } : {}); };
// A key file is CREATED, never written over: the mode 0600 is given only to a file that is created (an existing file keeps its own), and
// the key a file already holds would be lost, with nothing to rotate or recover it.
const scrie = (o, f, { secret = false } = {}) => {
if (!f) throw new Folosire(`${cmd}: --out is required`);
try { fs.writeFileSync(f, JSON.stringify(o, null, 1) + '\n', secret ? { mode: 0o600, flag: 'wx' } : {}); }
catch (e) { if (secret && e && e.code === 'EEXIST') throw new Folosire(`${cmd}: ${f} exists; a key file is never written over (the key it holds would be lost)`); throw e; }
};
const identitate = (f) => ID.importKeys(citeste(f));
/** what a file given to verify holds: one object, a list of them, or a registry { records: [...] }; flattened, every element is handed over */
const netezeste = (x, adancime = 0) => (adancime > 8 ? [x] : Array.isArray(x) ? x.flatMap((y) => netezeste(y, adancime + 1)) : x && typeof x === 'object' && Array.isArray(x.records) && x.statement === undefined ? netezeste(x.records, adancime + 1) : [x]);
const elemente = (f) => netezeste(citeste(f));
/** the public keys of an identity: a keys file, a { id, public } file, or the public keys object itself */
const publice = (f) => { const j = citeste(f); const p = j && j.public ? j.public : j; ID.publicKeyObjects(p); return p; };
const publice = (f) => { const j = citeste(f); const p = j && j.public ? j.public : j; try { ID.publicKeyObjects(p); } catch (e) { throw new Folosire(`${f} holds no public keys: ${e.message}`); } return p; };
const inOre = (h) => new Date(Date.now() + h * 3600000).toISOString();
const lant = () => ({ m: citeste(cere('--manufacture')), t: toate('--transfer').map(citeste) });
@@ -102,7 +108,7 @@ async function main() {
if (get('--software')) o.softwareAttestation = citeste(get('--software'));
const pachet = citeste(cere('--bundle')); let r;
try { r = D.verifyDevice(pachet, o); } catch (e) { if (/^verifyDevice: /.test(String(e && e.message))) throw new Folosire(e.message); throw e; } // the verifier's own configuration cannot be read: no verdict
if (rest.includes('--json')) console.log(JSON.stringify(r, null, 1));
if (rest.includes('--json')) console.log(D.visibleJson(r, 1));
else { for (const x of r.rows) spune(`${x.pass === true ? 'ok ' : x.pass === false ? 'FAIL' : '-- '} ${x.name}${x.pass === true || !x.detail ? '' : ': ' + x.detail}`);
console.log('');
spune(r.verdict + (r.rules.length ? ` (refused by: ${r.rules.join(', ')})` : '') + (r.verdict === 'PARTIAL' ? ` (not judged: ${r.unjudged.filter((c) => D.PARTIALE.includes(c)).join(', ')})` : ''));