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>
This commit is contained in:
J8k3 2026-05-18 21:33:06 -04:00
parent 0d08b2fc04
commit a2880a4dfc

View File

@ -381,6 +381,66 @@ TestRegister.addTests([
} }
] ]
}, },
{
name: "PIN Block Build: ISO Format 1 deterministic",
input: "1234",
expectedOutput: "141234FFFFFFFFFF",
recipeConfig: [
{
op: "PIN Block Build",
args: ["ISO Format 1", "", false]
}
]
},
{
name: "PIN Block Parse: ISO Format 1",
input: "141234FFFFFFFFFF",
expectedOutput: JSON.stringify({
format: "ISO Format 1",
pin: "1234",
pinLength: 4,
pinFieldHex: "141234FFFFFFFFFF",
panFieldHex: null,
blockHex: "141234FFFFFFFFFF",
fillDigitsHex: "FFFFFFFFFF"
}, null, 4),
recipeConfig: [
{
op: "PIN Block Parse",
args: ["ISO Format 1", ""]
}
]
},
{
name: "PIN Block Build: ISO Format 3 deterministic",
input: "1234",
expectedOutput: "341215AB89EFCD23",
recipeConfig: [
{
op: "PIN Block Build",
args: ["ISO Format 3", "5432101234567890", false]
}
]
},
{
name: "PIN Block Parse: ISO Format 3",
input: "341215AB89EFCD23",
expectedOutput: JSON.stringify({
format: "ISO Format 3",
pin: "1234",
pinLength: 4,
pinFieldHex: "341234AAAAAAAAAA",
panFieldHex: "0000210123456789",
blockHex: "341215AB89EFCD23",
fillDigitsHex: "AAAAAAAAAA"
}, null, 4),
recipeConfig: [
{
op: "PIN Block Parse",
args: ["ISO Format 3", "5432101234567890"]
}
]
},
{ {
name: "Card Validation Data Generate: known CVV2 sample", name: "Card Validation Data Generate: known CVV2 sample",
input: "0123456789ABCDEFFEDCBA9876543210", input: "0123456789ABCDEFFEDCBA9876543210",
@ -842,5 +902,80 @@ TestRegister.addTests([
args: ["PEM", "P-256", "PEM", ecdhPeerPublicKey, "None", 32, "", "Hex"] args: ["PEM", "P-256", "PEM", ecdhPeerPublicKey, "None", 32, "", "Hex"]
} }
] ]
},
{
name: "Chain: VISA PVV Generate → Verify",
input: "1234",
expectedOutput: JSON.stringify({
pinVerificationKeyHex: "0123456789ABCDEFFEDCBA9876543210",
pan: "5432101234567890",
pinVerificationKeyIndex: 1,
pin: "1234",
pvvInput: "1012345678911234",
encryptedPvvInputHex: "6A77E65CFE349D60",
pvv: "6077",
expectedPvv: "6077",
valid: true
}, null, 4),
recipeConfig: [
{
op: "VISA PVV Generate",
args: ["0123456789ABCDEFFEDCBA9876543210", "5432101234567890", 1, false]
},
{
op: "VISA PVV Verify",
args: ["0123456789ABCDEFFEDCBA9876543210", "5432101234567890", 1, "1234", true]
}
]
},
{
name: "Chain: IBM 3624 Generate PIN Offset → Verify PIN",
input: "1234",
expectedOutput: JSON.stringify({
pinVerificationKeyHex: "0123456789ABCDEFFEDCBA9876543210",
pinValidationData: "5432101234567890",
pinValidationDataPadCharacter: "F",
pinLength: 4,
validationBlockHex: "5432101234567890",
encryptedValidationBlockHex: "8A3712EE04F010A0",
decimalized: "8037124404501000",
naturalPin: "8037",
pin: "1234",
pinOffset: "3207",
expectedPinOffset: "3207",
valid: true
}, null, 4),
recipeConfig: [
{
op: "IBM 3624 Generate PIN Offset",
args: ["0123456789ABCDEFFEDCBA9876543210", "0123456789012345", "5432101234567890", "F", false]
},
{
op: "IBM 3624 Verify PIN",
args: ["0123456789ABCDEFFEDCBA9876543210", "0123456789012345", "5432101234567890", "F", "1234", true]
}
]
},
{
name: "Chain: EMV Generate ARQC → Verify ARQC",
input: "000102030405060708090A0B0C0D0E0F",
expectedOutput: JSON.stringify({
inputHex: "000102030405060708090A0B0C0D0E0F",
outputBytes: 8,
fullMacHex: "C1F732B52FB20CAAB58D5B6C78CBD514",
cryptogramHex: "C1F732B52FB20CAA",
expectedArqcHex: "C1F732B52FB20CAA",
valid: true
}, null, 4),
recipeConfig: [
{
op: "EMV Generate ARQC",
args: ["00112233445566778899AABBCCDDEEFF", 8, false]
},
{
op: "EMV Verify ARQC",
args: ["00112233445566778899AABBCCDDEEFF", 8, "000102030405060708090A0B0C0D0E0F", true]
}
]
} }
]); ]);