90fe409dec
The RAM explorer's ramFmtPrivileges used a private table with wrong bits and
invented names ("Cum Deletion Ctr", "GSM Card Binding", "Global PIN",
"RFM"/"CFM") and no case for 0x80: a live ISD 9E printed four wrong names
and dropped Security Domain. Per GP Card Spec v2.3.1 11.1.2 Tables
11-7/8/9, 9E = Security Domain, Card Lock, Card Terminate, Card Reset, CVM
Management.
- ramFmtPrivileges now delegates to decodePrivileges (one spec table).
- decodePrivileges decodes byte 1's DAP pair per Table 11-7: b8+b7 = DAP
Verification, b8+b7+b1 = Mandated DAP Verification; the flag bits alone
are no privilege.
- The file had two decodePrivileges copies (the runtime used the later one,
the C-APDU parser test the earlier); the duplicate and its private table
are gone - the single implementation plus PRIVILEGE_NAMES live in the
parser section, which the test evaluates (converted to var like PARSE_INS).
- Tests: 9E/9A live values, the DAP pair, byte 2/3 spot checks; the
PRIVILEGE_NAMES spec pin moved to apdu_parse.
659 frontend / 504 Python green; version 3.6.28; sw simple-v301.
61 lines
2.5 KiB
JavaScript
61 lines
2.5 KiB
JavaScript
const { test } = require('node:test');
|
|
const assert = require('node:assert');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const html = fs.readFileSync(path.join(__dirname, '..', 'index.html'), 'utf8');
|
|
|
|
function extractBlock(startMarker, endMarker) {
|
|
const start = html.indexOf(startMarker);
|
|
const end = html.indexOf(endMarker, start);
|
|
if (start < 0 || end < 0) throw new Error('block not found');
|
|
return html.slice(start, end);
|
|
}
|
|
|
|
// Response parser maps + lookupSw live between SW_MAP and updateRespCmd.
|
|
// Rewrite top-level const -> var so the maps leak out of sloppy-mode eval.
|
|
eval(extractBlock('const SW_MAP = {', 'function updateRespCmd').replace(/^const /gm, 'var '));
|
|
|
|
test('lookupSw wildcard 91XX resolves proactive pending (any length)', () => {
|
|
const desc = lookupSw('91', '14', 'uicc');
|
|
assert.ok(desc.includes('proactive'), desc);
|
|
assert.ok(!desc.includes('no response data'));
|
|
});
|
|
|
|
test('lookupSw 63CX extracts retry counter', () => {
|
|
const desc = lookupSw('63', 'C3', 'uicc');
|
|
assert.ok(desc.includes('3'), desc);
|
|
});
|
|
|
|
test('SW_MAP.generic covers ISO 6A85/6A89/6A8A', () => {
|
|
assert.ok(SW_MAP.generic['6A85']);
|
|
assert.ok(SW_MAP.generic['6A89']);
|
|
assert.ok(SW_MAP.generic['6A8A']);
|
|
});
|
|
|
|
test('gp 6310 label does not reference removed P2=42 option', () => {
|
|
assert.ok(!SW_MAP.gp['6310'].includes('42'));
|
|
});
|
|
|
|
test('LIFECYCLE_MAP per GPC v2.3 life cycles', () => {
|
|
assert.strictEqual(LIFECYCLE_MAP['01'], 'OP_READY (card) / LOADED (ELF)');
|
|
assert.strictEqual(LIFECYCLE_MAP['03'], 'INSTALLED');
|
|
assert.strictEqual(LIFECYCLE_MAP['07'], 'SELECTABLE');
|
|
assert.strictEqual(LIFECYCLE_MAP['0F'], 'SECURED (card)');
|
|
assert.strictEqual(LIFECYCLE_MAP['1F'], 'PERSONALIZED (SD)');
|
|
assert.strictEqual(LIFECYCLE_MAP['7F'], 'CARD_LOCKED');
|
|
assert.strictEqual(LIFECYCLE_MAP['FF'], 'TERMINATED');
|
|
assert.strictEqual(LIFECYCLE_MAP['83'], 'LOCKED (SD)');
|
|
});
|
|
|
|
test('TS 51.011 SIM families resolve (94xx/98xx/92xx/9Exx/9Fxx)', () => {
|
|
assert.ok(lookupSw('94', '04', 'uicc').includes('not found'));
|
|
assert.ok(lookupSw('94', '00', 'uicc').includes('No EF selected'));
|
|
assert.ok(lookupSw('94', '08', 'uicc').includes('inconsistent with the command'));
|
|
assert.ok(lookupSw('98', '40', 'uicc').includes('blocked'));
|
|
assert.ok(lookupSw('92', '40', 'uicc').includes('Memory problem'));
|
|
assert.ok(lookupSw('98', '50', 'gp').includes('max value'));
|
|
assert.ok(lookupSw('9E', '15', 'uicc').includes('download'));
|
|
assert.ok(lookupSw('9F', '20', 'uicc').includes('GET RESPONSE'));
|
|
});
|