identity: verify-sdjwt on the command line (an SD-JWT+KB checked with the issuer key you give; Aere Cloud runs it behind POST /v1/identity/sd-jwt/verify)
The issuer key (a public JWK, or the public keys of an AERE identity) is checked first: one that cannot be read, is private, or is not a key for the algorithm asked exits 2 with the reason, instead of reporting the token INVALID. --json prints compact JSON (indented output grew with the square of the claims' nesting depth). --at judges at a given time, as for verify. Test on the RFC 9901 example presentation: valid at its own time, invalid now, a private key refused. Tests: SD-JWT 23/23, negative control 28/28; identity 44/44, negative control 49/49.
This commit is contained in:
1 parent
4ffec8d7e3
commit
5f1e60b8d2
6 files changed
+54
-6
No files matched your search
@@ -4,6 +4,8 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import crypto from 'node:crypto';
|
||||
import os from 'node:os';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import * as I from './identity.mjs';
|
||||
import * as J from './sdjwt.mjs';
|
||||
@@ -193,5 +195,17 @@ test('REVIZUIRE: crit (orice forma), base64url necanonic al semnaturii, KB expir
|
||||
cere(refuz(judeca(baza + kbExp), /key binding: expired/), 'KB expirat a trecut');
|
||||
});
|
||||
|
||||
test('linia de comanda: verify-sdjwt pe prezentarea RFC 9901 s.5.2 -> 0 VALID la momentul ei (--at), 1 INVALID acum (KB vechi); o cheie privata -> 2', () => {
|
||||
const T = fs.mkdtempSync(path.join(os.tmpdir(), 'aere-sdjwt-cli-'));
|
||||
try {
|
||||
fs.writeFileSync(path.join(T, 'p.txt'), F.presentation); fs.writeFileSync(path.join(T, 'k.json'), JSON.stringify(F.issuerJwk));
|
||||
const run = (...a) => spawnSync(process.execPath, [path.join(AICI, 'identity-cli.mjs'), 'verify-sdjwt', '--sd-jwt', 'p.txt', '--issuer-key', 'k.json', '--issuer-alg', 'ES256', '--audience', KB.aud, '--nonce', KB.nonce, ...a], { cwd: T, encoding: 'utf8' });
|
||||
const a = run('--at', new Date(KB.iat * 1000).toISOString(), '--json'); cere(a.status === 0 && JSON.parse(a.stdout).valid === true, 'la iat: ' + a.status + ' ' + a.stderr);
|
||||
const b = run(); cere(b.status === 1 && /outside 300 s/.test(b.stdout), 'acum: ' + b.status + ' ' + b.stdout);
|
||||
fs.writeFileSync(path.join(T, 'k.json'), JSON.stringify(crypto.generateKeyPairSync('ec', { namedCurve: 'P-256' }).privateKey.export({ format: 'jwk' })));
|
||||
const c = run(); cere(c.status === 2 && /private JWK/.test(c.stderr), 'cheia privata: ' + c.status + ' ' + c.stderr);
|
||||
} finally { fs.rmSync(T, { recursive: true, force: true }); }
|
||||
});
|
||||
|
||||
console.log(`\naere-sd-jwt: ${treceri}/${treceri + esecuri.length} cum trebuia`);
|
||||
process.exitCode = esecuri.length ? 1 : 0;
|
||||
Reference in new issue
Block a user