4447 Commits

Author SHA1 Message Date
J8k3
b345d5b8e9 Fix DUKPT TDES counter accumulation in deriveSessionBaseKey
The per-bit loop was setting the FULL counter value on every hit instead
of OR-ing in one bit at a time. For any counter with more than one set
bit the two calls to nonReversibleKeyGen received the same ksnReg and
produced wrong derived keys. The existing test vector used counter 0x08
(one set bit), which masked the bug.

Fix: accumulate bits with |= so ksnReg grows one bit per iteration:
  ksnReg[7] |= (bit >> 16) & 0x1F
  ksnReg[8] |= (bit >> 8) & 0xFF
  ksnReg[9] |= bit & 0xFF

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 14:41:42 -04:00
J8k3
17cc3f9cb9 Fix SHA-224 KCV bug, simplify DUKPT variant logic, add AGENTS.md rules
- CalculatePaymentKCV: fix HMAC SHA-224 using SHA-512/224 (forge.md.sha512.sha224)
  instead of standard SHA-224 (now uses "sha224" string, consistent with other HMAC methods)
- PaymentMac: collapse 3-clause DUKPT variant ternary to single expression; the
  ISO 9797-1 fallback to "MAC Request" was already correct and is now explicit
- AGENTS.md: renumber steps 1-7 sequentially; add step 6 — review and update
  this.description/inlineHelp/testDataSamples whenever changing a recipe

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 14:27:27 -04:00
J8k3
0da4c99a0c Fix PAN generation: random prefix within range, Mastercard series option
Two bugs in generateBrandPan:
1. For networks with multiple prefix rules, always picked the same rule
   (Mastercard always 2-series, AmEx always 37, Discover always 6011)
2. Always used the start of the range as the prefix, so Mastercard
   generated 51xxxxx or 2221xxxxxx every time instead of any value
   in 51-55 or 2221-2720

Fix both: pick a random prefix rule and a random prefix within start..end.

Add a "Mastercard series" arg to PAN Generate so callers can explicitly
request 5-series (51-55), 2-series (2221-2720), or leave it random.
The curated sample path is unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 14:18:22 -04:00
J8k3
eba7e37185 Fix TR-31/TR-34 op names and sort Payments category alphabetically
Rename two ops to follow the domain-prefix-first convention:
  "Parse TR-31 Key Block"    -> "TR-31 Parse Key Block"
  "Parse TR-34 Key Transport" -> "TR-34 Parse Key Transport"

Sort all 33 Payments category entries alphabetically in Categories.json.
With domain-prefix names the prefixes cluster related ops naturally, so
alphabetical order is also logical order.

Update PAYMENT_RECIPES.md UI Arrangement section to document alphabetical
ordering. Fix stale lowercase references in AWS_PAYMENT_CRYPTOGRAPHY_RECIPES.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 14:11:06 -04:00
J8k3
c6d530348e Document generated config files in Payment Operation Maintenance
After the op-rename batch, the runtime threw 'f[e.module][e.name] is not
a constructor' for every renamed op because Payment.mjs and index.mjs are
gitignored generated files that were never regenerated after this.name
was updated.

Add a rule to AGENTS.md step 6 naming the three generated files, the
symptom of a stale registry, and the two-command fix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 12:35:41 -04:00
dependabot[bot]
37a92460f0
Bump nginxinc/nginx-unprivileged from 808f784 to b9f7ba1 (#2389)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-18 15:51:56 +01:00
J8k3
fc6ac7806e Improve testDataSamples: random placeholders and recipeConfig chains
Replace six static inputs that held hardcoded keys or PINs with the
appropriate __RANDOM_*__ placeholder so the populate button delivers a
fresh value each time rather than a fixed test vector:
  - PIN Data Generate, IBM 3624 Generate PIN Offset, VISA PVV Generate
    → __RANDOM_PIN_4__
  - DUKPT Derive TDES Key, AS2805 Generate KEK Validation
    → __RANDOM_TDES_16_HEX__
  - DUKPT Derive AES Key → __RANDOM_AES_128_HEX__

Add a recipeConfig chain sample to two ops where the output of
Key Generate flows directly into the next op as input:
  - Card Validation Data Generate: Key Generate → Card Validation Data Generate
  - Payment Calculate KCV: Key Generate → Payment Calculate KCV

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 10:01:31 -04:00
J8k3
634c835dfd Rename payment ops to domain-prefix-first; remove upstream ops from Payments category
All 31 payment operation display names now lead with their domain prefix
(EMV, DUKPT, PIN Block, PAN, etc.) so they sort and scan by topic in the
UI list. 8 upstream CyberChef ops (AES Encrypt/Decrypt, Triple DES,
AES Key Wrap/Unwrap, HMAC, CMAC) removed from the Payments category.

Updated: op this.name fields, Categories.json, Payment.mjs tests,
PAYMENT_RECIPES.md, AWS_PAYMENT_CRYPTOGRAPHY_RECIPES.md, AGENTS.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 09:29:52 -04:00
GCHQ Developer 85297
b090482bd0
Series Chart HTML Formatting fix (#2403) 2026-05-18 11:57:16 +01:00
GCHQ Developer 85297
7ca4b3a13d
Parse Ethernet Frame HTML formatting fix (#2402) 2026-05-18 11:54:13 +01:00
GCHQ Developer 85297
1baef27e9b
Parse IPv4 Header HTML formatting fix (#2401) 2026-05-18 11:52:10 +01:00
GCHQDeveloper581
cf6912f640
Update chromedriver, and install corresponding chrome in workflows (fixes build) (#2387) 2026-05-18 10:38:11 +01:00
github-actions[bot]
32ef373485 Merge remote-tracking branch 'upstream/master' 2026-05-18 09:37:11 +00:00
J8k3
f246a7dcf9 Rename Derive DUKPT Key to Derive DUKPT TDES Key
Mirrors the naming convention of Derive DUKPT AES Key.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 21:56:03 -04:00
Jacob Marks
01f396d121 Fix #4: delete TranslatePaymentPINData (duplicate of TranslatePINBlock) 2026-05-17 20:34:52 -04:00
Jacob Marks
0aadfb94e3 Fix GenerateTestPAN: random fills, suppress cardType when unknown 2026-05-17 13:33:28 -04:00
Jacob Marks
c405326f03 Fix 3 test assertions: TR-31 compliance fields, PAN card-type fields 2026-05-17 08:24:13 -04:00
Jacob Marks
cd4442cc62 Fix 3 test assertions: TR-31 compliance fields, PAN card-type fields 2026-05-17 08:23:10 -04:00
Jacob Marks
6fc1c26b24 Fix Payment.mjs: correct 4 op names (payShield/Futurex uppercase C, TR-31 Key Block, TR-34 Key Transport) and TR-34 expected output 2026-05-17 08:16:56 -04:00
Jacob Marks
43d8a03a5b Fix Categories.json: add new ops, fix renamed op names, move ECDH to Ciphers 2026-05-16 23:42:29 -04:00
Jacob Marks
7081361db7 Fix Pan.mjs: add missing trailing newline (eol-last) 2026-05-16 23:38:20 -04:00
Jacob Marks
35e2f0a2d8 Fix ParseTR31KeyBlock lint: add constructor JSDoc 2026-05-16 23:35:52 -04:00
Jacob Marks
6bbafe7ff3 Fix ParseTR34B9Envelope lint: JSDoc on parseAsnLength, hexStr, constructor 2026-05-16 23:35:31 -04:00
Jacob Marks
0dda2fe08a Fix GenerateKey lint: JSDoc on helper functions and constructor 2026-05-16 23:35:27 -04:00
Jacob Marks
7a4b47fa6b Fix DeriveDUKPTAESKey lint: JSDoc on helpers, constructor, dot-notation 2026-05-16 23:35:24 -04:00
Jacob Marks
b2e3100886 Fix DeriveECDHKeyMaterial lint: brace-style, indentation, operator-linebreak, constructor JSDoc 2026-05-16 23:35:21 -04:00
Jacob Marks
718824a42f Fix Pan.mjs: operator-linebreak for cardTypeNote ternary 2026-05-16 23:35:01 -04:00
Jacob Marks
e08d401956 Add DeriveECDHKeyMaterial tests: P-256 raw secret, Concat KDF SHA-256, missing key error 2026-05-16 23:24:20 -04:00
Jacob Marks
550d0b7ec6 Fix DeriveECDHKeyMaterial: real test vectors, None KDF fix, P-521 comment, module=Ciphers 2026-05-16 23:21:51 -04:00
Jacob Marks
89e39a8642 Move DeriveECDHKeyMaterial from Payment to Ciphers module 2026-05-16 23:08:39 -04:00
Jacob Marks
2a5b1deb2e Add Payment Operation Maintenance rules to AGENTS.md 2026-05-16 23:04:55 -04:00
Jacob Marks
5e473899ea Update PAYMENT_RECIPES.md: fix stale names, add new operations, naming convention section 2026-05-16 23:04:54 -04:00
Jacob Marks
c32be5a5c5 Capitalise display name: "Parse TR-34 Key Transport" 2026-05-16 23:02:54 -04:00
Jacob Marks
ff90e41269 Capitalise display name: "Parse TR-31 Key Block" 2026-05-16 23:02:52 -04:00
Jacob Marks
c268dd3a1e Capitalise display name: "Parse Futurex Excrypt Command" 2026-05-16 23:02:51 -04:00
Jacob Marks
e19bfacd4d Capitalise display name: "Parse Thales payShield Command" 2026-05-16 23:02:49 -04:00
Jacob Marks
517a56e826 Add card type classification and MII description to parsePan 2026-05-16 22:50:41 -04:00
Jacob Marks
062b60e0c6 Revert "Encode PIN Block" back to "Build PIN Block" 2026-05-16 22:50:03 -04:00
Jacob Marks
340db6122d Revert "Decode PIN Block" back to "Parse PIN Block" 2026-05-16 22:49:53 -04:00
Jacob Marks
9590eccd41 Rename "Build PIN Block" to "Encode PIN Block" 2026-05-16 22:48:35 -04:00
Jacob Marks
91d8d0ec37 Rename "Parse PIN Block" to "Decode PIN Block" 2026-05-16 22:48:21 -04:00
Jacob Marks
dd7a26aa1f Broaden ParseTR34B9Envelope to TR-34 key transport: message type table, error codes, ASN.1 envelope peek 2026-05-16 22:45:40 -04:00
Jacob Marks
cf3023bc82 Add GenerateKey operation for random payment keys and IVs 2026-05-16 22:45:30 -04:00
Jacob Marks
4451ddbee3 Enhance ParseTR31KeyBlock with full X9.143 field decoding and compliance checks 2026-05-16 22:45:22 -04:00
Jacob Marks
9207d79356 Add Derive DUKPT AES Key operation (ANSI X9.24-3 AES-128) 2026-05-16 22:37:36 -04:00
J8k3
46228977d6 Update repo agent guidance 2026-05-16 10:39:46 -04:00
J8k3
17c004a66b Add Futurex Excrypt command parser 2026-05-16 10:38:09 -04:00
J8k3
5cc38496bd Allow overriding test timeout 2026-05-16 10:21:26 -04:00
J8k3
1aa54684d8 Add Thales payShield command parser 2026-05-16 10:18:33 -04:00
J8k3
9e9904870c Update payment metadata and restore Docker test baseline 2026-05-16 09:26:39 -04:00