scp81: queue explicit commands, expanded-format output for the RAM chain (v2.1.14)

- POST /api/scp81/queue takes an explicit APDU list (or single APDU) and
  queues it as the SCP81 script; entries that already are Command Scripting
  templates (AA.../AE80..., the expanded format) are sent verbatim instead of
  being wrapped again
- Remote APDU -> RAM chain: "To expanded" builds each command in the
  TS 102 226 expanded form (AA definite / AE80 indefinite selector) and
  "Queue in SCP81" queues the built commands for the next card POST, so the
  full-featured RAM/INSTALL [for install] form (AIDs, privileges, TK/STK
  parameters) can drive the HTTP OTA install
- RU strings; api.md; service worker v151
This commit is contained in:
2026-09-16 08:05:57 +03:00
parent e32a6e17e4
commit b811906751
6 changed files with 131 additions and 7 deletions
+29
View File
@@ -813,3 +813,32 @@ class ScriptBodyLengthTest(unittest.TestCase):
body = _scp81_command_body(apdu, definite=True)
# AA 81 85 22 81 82 <130 bytes> (outer 1+2+130 = 133 = 0x85)
self.assertEqual(body[:6].hex().upper(), 'AA8185228182')
class VerbatimScriptTest(unittest.TestCase):
def test_expanded_templates_sent_verbatim(self):
server._SCP81_SCRIPT = ['AA0B2208 80CAFF2100'.replace(' ', '')]
server._SCP81_SCRIPT_SENT = 0
server._SCP81_SCRIPT_RESULTS = []
server._SCP81_SCRIPT_INSERTED = []
server._SCP81_PAGES = 0
try:
status, headers, body = server._scp81_script_responder(
'POST', '/api/scp81', {}, b'')
self.assertEqual(status, 200)
# Sent as-is (no AE80/22 wrapper added)
self.assertEqual(body.hex().upper(), 'AA0B220880CAFF2100')
finally:
server._SCP81_SCRIPT = list(server._SCP81_SCRIPTS['explore'])
server._SCP81_SCRIPT_SENT = 0
def test_plain_apdu_still_wrapped(self):
server._SCP81_SCRIPT = ['80CAFF2100']
server._SCP81_SCRIPT_SENT = 0
try:
status, headers, body = server._scp81_script_responder(
'POST', '/api/scp81', {}, b'')
self.assertEqual(body.hex().upper(), 'AE80220580CAFF21000000')
finally:
server._SCP81_SCRIPT = list(server._SCP81_SCRIPTS['explore'])
server._SCP81_SCRIPT_SENT = 0