4447 Commits

Author SHA1 Message Date
github-actions[bot]
7830bac871 Merge remote-tracking branch 'upstream/master' 2026-05-25 09:45:00 +00:00
J8k3
db1e72d05c docs: standardize Session Start and Commit Scope in AGENTS.md
Align wording with the shared standard used across all four repos in
this project family. No behavioral change — same rules, consistent text.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 14:07:46 -04:00
J8k3
16a893e70a test(payment): add 5 golden-value tests for AES ECB, AES CTR, DUKPT TDES CBC
Covers the remaining untested cipher profiles in PaymentEncryptData /
PaymentDecryptData. Values are pinned from a clean run against the forge
upstream library, catching regressions in mode selection, IV wiring,
and padding behaviour without re-deriving cryptographic outputs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 14:05:23 -04:00
J8k3
60a89aa64f test(payment): add 7 new test cases covering json output shape and TDES cipher profiles
JSON output shape (covering recent ksn/bdk additions):
  - DUKPT Derive AES Key: IK JSON output includes ksn, iki, counter
  - DUKPT Derive TDES Key: IPEK JSON output includes ksn and bdk

Payment cipher coverage (previously only AES CBC was tested):
  - Payment Encrypt/Decrypt Data: TDES ECB (APC cross-validated block 1)
  - Payment Encrypt/Decrypt Data: TDES CBC (derived from passing re-encrypt chain)
  - Payment Encrypt Data: DUKPT TDES ECB Data variant (ANSI X9.24-1; APC variant
    mismatch documented in test comment and PAYMENT_RECIPES.md)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 13:03:31 -04:00
J8k3
4ce7860a19 fix(dukpt): add KSN/BDK to JSON output for AES and TDES DUKPT derive operations
AES DUKPT IK JSON was missing ksn, iki, counter; working key was missing ksn.
TDES DUKPT IPEK and session key JSON were missing ksn and bdk.
Both now mirror the full derivation context, making json=true self-contained for debugging and cross-validation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 10:52:43 -04:00
Blank0120
6a3a370bb1
update bson (#2425)
Co-authored-by: GCHQDeveloper581 <63102987+GCHQDeveloper581@users.noreply.github.com> (update of dependabot excluded packages)
2026-05-23 12:42:40 +01:00
dependabot[bot]
fba4a0a0af
chore (deps): bump webpack from 5.106.2 to 5.107.1 (#2428)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-23 11:47:11 +01:00
dependabot[bot]
ad51a17482
chore (deps): bump protobufjs from 7.5.8 to 7.6.0 (#2429)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-23 11:40:20 +01:00
dependabot[bot]
9b6619c45a
chore (deps): bump sql-formatter from 15.7.4 to 15.8.0 (#2430)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-23 11:25:31 +01:00
dependabot[bot]
50d5798c1f
chore (deps): bump docker/build-push-action from 7.1.0 to 7.2.0 (#2431)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-23 11:16:44 +01:00
J8k3
d7a32d1293 docs: trim PAYMENT_RECIPES.md to dev reference, update AGENTS.md
PAYMENT_RECIPES.md was duplicating content now maintained in
J8k3/CyberChef-Payments (recipe catalog, chaining patterns, validation
status). Trimmed to: naming conventions, operation registry, raw APC
comparison test vectors + results. Added pointer to CyberChef-Payments.

AGENTS.md updated:
- Pre-commit checklist now says: update PAYMENT_RECIPES.md operation
  registry + CyberChef-Payments README if op appears in catalog
- Added paragraph clarifying the two-file split (dev vs. user-facing)
- Naming convention step now explicitly calls out CyberChef-Payments

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 00:20:59 -04:00
J8k3
a50b1f6faf README: reframe as implementation repo, redirect recipe catalog to CyberChef-Payments
- Update opening: workflow-oriented tooling for engineering, debugging,
  interoperability, development, QA — replaces narrow regulated-env framing
- Add explicit links to CyberChef-Payments (workflow catalog) and Payments (KB)
  near the top
- Replace verbose recipe list (24 entries) with 7 representative examples;
  redirect to J8k3/CyberChef-Payments for the full catalog and screenshots
- Fix typo: "Current coverage includes:h" -> "Current coverage includes:"
- Rewrite validation section: remove "unfinished product" and "best validation
  we can do" — replace with scoped statement on standards, vectors, and APC
  comparison where APIs are comparable
- Restructure: What this fork adds / Scope / Validation / Non-goals / Recipes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 00:18:01 -04:00
J8k3
c7a4b6358a Rename Parse EMV TLV → EMV Parse TLV (naming convention)
Domain prefix must come first per AGENTS.md convention. All references
updated: op file, Categories.json, tests, PAYMENT_RECIPES.md, lib comment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 04:25:28 -04:00
Jacob Marks
040da1fd92
Modify EMV recipes in README.md
Updated EMV-related recipes in the README.
2026-05-21 22:33:08 -04:00
J8k3
a44fc20da0 Fix lint: comma-spacing in Payment.mjs test; document full lint command
eslint:tests catches Payment.mjs too — document that npx grunt eslint runs
all five targets, not just eslint:core.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 20:03:37 -04:00
J8k3
8e0c192973 Fix lint: brace-style, comma-spacing, key-spacing, JSDoc, operator-linebreak
11 ESLint errors across 6 files introduced in the ARQC/ARPC/TLV/Script ops.
Also document the constructor-JSDoc and operator-linebreak rules in AGENTS.md
to prevent recurrence.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 19:44:13 -04:00
J8k3
32622a01de AGENTS.md: add reciprocal knowledge loop rule to APC cross-reference
The one-way rule (CyberChef gaps → GitHub issue) didn't cover the return path.
New paragraph: discoveries from CyberChef sessions (PCI rules, algorithm edge cases,
HSM commands) must be written back into the MCP server in the same session.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 19:28:29 -04:00
J8k3
2b9c92bae6 Enforce same-commit docs + APC check rule in AGENTS.md
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 19:28:28 -04:00
J8k3
a35b5aa23c Docs: add EMV Build Script Data ops to PAYMENT_RECIPES.md
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 19:28:27 -04:00
J8k3
eeb16eaaa8 Add EMV Build Script Data and Build PIN Change Script Data operations
Also fixes expectedError test format (OperationErrors surface as result
strings, not result.error) and updates PAYMENT_RECIPES.md docs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 19:28:25 -04:00
J8k3
259b9740a7 Add EMV Build/Parse ARPC Data operations
- EMV Build ARPC Data: assembles ARPC preimage from named fields; Method 1 (Visa/Amex/Discover: ARQC+ARC, 10 bytes) and Method 2 (Mastercard: ARQC+CSU+optional PAD, 12-20 bytes); outputs hex (chainable into EMV Generate ARPC), JSON, or annotated
- EMV Parse ARPC Data: inverse; parses hex preimage back into named fields by method
- Shared lib EmvArpc.mjs with build/parse/format functions
- 6 new tests in Payment.mjs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 19:28:24 -04:00
J8k3
10bb87b320 Add EMV Build/Parse ARQC Data and Parse EMV TLV operations (issues #11)
- EMV Build ARQC Data: assembles 10-field CDOL1 preimage from args; outputs hex (chainable into EMV Generate ARQC), JSON, or annotated TLV
- EMV Parse ARQC Data: inverse; parses flat 33-byte CDOL1 hex back into named fields
- Parse EMV TLV: BER-TLV parser with 102-entry EMV tag dictionary; handles constructed/nested tags, 1- and 2-byte tags, long-form lengths; dictionary mode lists all known tags
- Shared libs: EmvCdol.mjs (CDOL1 field defs), EmvTlv.mjs (parser), EmvTlvDictionary.mjs (tag dict)
- 12 new tests in Payment.mjs covering all three operations

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 19:28:23 -04:00
Jacob Marks
f90fba92fd
Fix typos and enhance README clarity
Corrected typos and improved clarity in the README.
2026-05-21 12:42:49 -04:00
Jacob Marks
a87e24cad5
Revise README for CyberChef Payments focus
Updated the README to reflect the focus on payment cryptography operations, clarified the development status, and modified section headings.
2026-05-21 12:30:50 -04:00
Jacob Marks
8d45d908e6
Revise CyberChef recipes in README
Updated links for PIN and EMV generation recipes.
2026-05-21 07:59:53 -04:00
J8k3
c44873ab3f Fix lint: expand inline try/catch in KeyComponentCombine; add brace-style rule to AGENTS.md
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 22:22:51 -04:00
J8k3
28cda9bad9 Add Key Component Split and Combine operations (issue #2)
XOR key ceremony helpers: split a key into 2-8 components and recombine.
Chains cleanly with Key Generate and wrap/encrypt operations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 22:06:32 -04:00
J8k3
79ac440b14 Docs: AGENTS.md, PAYMENT_RECIPES.md, README.md updates
- AGENTS.md: add APC cross-reference, security constraint, ESLint, and gap-filing instructions
- PAYMENT_RECIPES.md: DUKPT AES key status to Externally cross-checked; VISA PVV APC results updated with second key cross-check
- README.md: PIN Block Translate Encrypted in coverage list and recipe links

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 21:49:34 -04:00
J8k3
ffc5fcbf41 Add PIN Block Translate Encrypted; fix CBOR v9 encode; fix EMV MAC tests; fix bcrypt node test
- PIN Block Translate Encrypted: new operation with 5 tests; registered in Payments category
- CBOR v9: fix Encoder streaming/Buffer pool issue; JSDoc on helpers
- EMV Generate MAC: fix empty-input hex parse, stale 3-arg test, missing padding method in verify test
- parseHexBytes: accept empty string as valid 0-byte hex
- bcrypt node test: accept $2a prefix from bcryptjs v2.4.3

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 19:04:35 -04:00
J8k3
c628207471 Add DUKPT session key variant, PIN block edge case, and EMV MAC boundary tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 15:44:34 -04:00
Leon Zandman
ad20c91f5b
Fix flaky npm run testui (#2412) 2026-05-20 18:33:40 +01:00
GCHQ Developer 85297
2cf778c253
Include git ref in website download zip name (#2339) 2026-05-20 15:32:46 +01:00
J8k3
31310d5d57 PAYMENT_RECIPES: explain ISO9797 Method 1/2; update EMV MAC APC comparison row 2026-05-19 21:13:12 -04:00
J8k3
9015ea9f40 EMV Generate/Verify MAC: add padding method selector (default Method 2) 2026-05-19 20:43:25 -04:00
J8k3
0d08681d55 PAYMENT_RECIPES: add APC comparison results; fix PIN translation note 2026-05-19 19:40:23 -04:00
J8k3
e09d6df31e Fix AES DUKPT derivation: use AES-ECB, 32-bit tree, usage 0x8000
X9.24-3 uses AES_Encrypt_ECB for all derivation steps, not AES-CMAC.
Intermediate tree nodes use key usage 0x8000 (not 0x0000), and the
binary tree traversal must cover all 32 counter bits (not 21).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 15:06:58 -04:00
J8k3
2dbccc613f AGENTS: explicit ban on running npm build/start on Windows
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 11:22:13 -04:00
J8k3
8ac6cc1980 Add PIN Generate op: random PIN with optional clear PIN block output
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 10:16:19 -04:00
J8k3
af84b44117 AGENTS: grunt task alias, IBM 3624 naming example, end-of-cycle review prompt
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 09:37:59 -04:00
J8k3
292f4afbb8 Rename IBM 3624 ops to PIN-domain-first; use crypto.getRandomValues in PAN generator
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 09:34:51 -04:00
J8k3
b724fc4b8c Fix AES DUKPT derivation data format; add X9.24-3 test vectors
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 23:02:01 -04:00
J8k3
e864259c1e Fix VISA PVV decimalization: use two-pass algorithm per Visa spec
decimalizePvv() was using a single-pass that immediately mapped A-F to
0-5. The Visa PVV spec (matching ANSI X9.8 and jPOS behavior) requires
two-pass: collect all decimal digits (0-9) first; only then re-scan
mapping A=0 B=1 C=2 D=3 E=4 F=5. This matches decimalizeCvvHex() which
was already correct. Bug produced wrong PVV whenever a hex letter appeared
before the first decimal digit in the encrypted output.

Test vectors updated from "6077" (single-pass result) to "6776" (correct
two-pass result) for the encrypted PVV hex 6A77E65CFE349D60.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 21:53:28 -04:00
J8k3
a2880a4dfc Add Format 1/3 PIN block tests and Generate→Verify chain tests
PIN block coverage:
- PIN Block Build: ISO Format 1 deterministic (fill 0xF, no PAN)
- PIN Block Parse: ISO Format 1
- PIN Block Build: ISO Format 3 deterministic (fill 0xA, PAN-bound)
- PIN Block Parse: ISO Format 3

Chain tests (exercises the input/arg swap work and confirms output flows correctly):
- VISA PVV Generate → Verify
- IBM 3624 Generate PIN Offset → Verify PIN
- EMV Generate ARQC → Verify ARQC

Closes part of issue #12 (testing gaps).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 21:33:06 -04:00
J8k3
0d08b2fc04 Update README and PAYMENT_RECIPES for shipped AES DUKPT and removed op
README:
- Added DUKPT AES key derivation to current coverage (ANSI X9.24-3, 12-byte KSN, AES-128)
- Expanded DUKPT TDES line to include standard/KSN details for clarity
- Removed AES DUKPT from Future extensions (it shipped)

PAYMENT_RECIPES:
- Replaced "deprecated" with "removed" for Translate Payment PIN Data (issue #4 was resolved)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 20:33:34 -04:00
J8k3
5709c11be3 Add build commands to AGENTS.md; document CVV2/iCVV service-code forcing in card validation ops
AGENTS.md:
- Added npm start (dev server), npm run build (prod), and NODE_OPTIONS heap-size tip from upstream Getting-started wiki

Card Validation Data Generate/Verify:
- Added Profile behaviour note to both descriptions: CVV2 forces service code 000, iCVV forces 999, the arg is ignored for those profiles

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 20:25:52 -04:00
J8k3
f4bd260363 Absorb PAYMENT_VALIDATION_AUDIT.md into PAYMENT_RECIPES.md; tighten AGENTS.md
PAYMENT_RECIPES.md:
- Removed stale AWS_PAYMENT_CRYPTOGRAPHY_RECIPES.md and PAYMENT_VALIDATION_AUDIT.md cross-references
- Added Validation Status section: class legend, full op matrix (current names, includes DUKPT Derive AES Key, HSM parse ops; removes deprecated Translate Payment PIN Data), release posture, references

AGENTS.md:
- Added Code Style section pointing to CONTRIBUTING.md conventions
- Merged "When Docker is unavailable" rule into Test And Debugging Baseline
- Removed now-redundant Current Project Preference section

PAYMENT_VALIDATION_AUDIT.md deleted (content absorbed above)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 20:24:48 -04:00
J8k3
09040b6bb7 Semantic/usability fixes across four payment operations
- PIN Data Verify: add Output as JSON toggle (was always returning JSON with no way to get plain boolean; all other verify ops have this toggle)
- EMV Verify MAC: fix inlineHelp to say "session integrity key" (was "session key", inconsistent with arg name and description body)
- DUKPT Derive TDES Key: replace stale "AES DUKPT not implemented" note with pointer to DUKPT Derive AES Key operation
- EMV Generate MAC (PIN Change): replace "Emulation helper" / "This emulation" with "Test helper" / "This operation" throughout description, inlineHelp, and arg comment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 15:53:49 -04:00
J8k3
be3af3ab48 Add payment recipe example URLs to README; remove stale AWS branding doc; add squash rule to AGENTS.md
- Appended 23 pre-built payment recipe chain URLs (p01-p23) to README
- Removed link to AWS_PAYMENT_CRYPTOGRAPHY_RECIPES.md from README (replaced by PAYMENT_RECIPES.md)
- Deleted AWS_PAYMENT_CRYPTOGRAPHY_RECIPES.md (stale pre-debranding artifact)
- Added squash/amend guidance to Commit Scope in AGENTS.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 15:45:25 -04:00
J8k3
a312c23fbc Swap input/arg on all Verify operations for recipe chaining
PVV Verify, IBM 3624 Verify PIN, and EMV Verify ARQC all previously took
the long preimage data as input and the short cryptogram/offset as an arg,
which broke natural recipe chaining from their Generate counterparts.

Swapped each: the short output (PVV, offset, ARQC) now flows in as input;
the preimage/PIN data moves to an arg. Also added an Output as JSON toggle
to EMV Verify ARQC for consistency with other verify operations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 15:45:12 -04:00
J8k3
cb0f535aec Add syntax-only scope note to both HSM Parse operations
Both HSM Parse Thales Command and HSM Parse Futurex Command parse
message framing and field structure only; they do not interpret,
validate, or execute command payloads. Added a prominent Scope note
to this.description and this.inlineHelp on both operations so users
see the limitation before relying on the output for semantic analysis.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 14:42:46 -04:00