4400 Commits

Author SHA1 Message Date
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
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
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
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