Skip to content

HSM commands

The host commands the HSM simulator answers, its error codes and its key type tables, as the simulator itself defines them. How it compares with a payShield is in the overview.

A command is a 2 byte length, a header (4 characters unless the install sets another length) that the answer repeats, the 2 character command code and its fields. The answer’s code advances the command’s second character (NC is answered with ND), followed by a 2 digit error code. A command not listed here is answered with error 68, so the caller doesn’t wait for a timeout.

Command Answer What it does Notes
B2 B3 Echo The data sent, returned unchanged: how host applications check the link.
NC ND Perform diagnostics The LMK check value (16 digits) and the firmware number (9 characters).
Command Answer What it does Notes
A0 A1 Generate a key Mode 0 returns the key under the LMK; mode 1 also under a ZMK (or TMK).
A6 A7 Import a key A key received under a ZMK, re-encrypted under the LMK for its key type.
A8 A9 Export a key A key held under the LMK, encrypted under a ZMK to send to another party.
BU BV Generate a key check value The 16 digit check value of a key held under the LMK.
Command Answer What it does Notes
CA CB Translate a PIN from TPK to ZPK encryption
CC CD Translate a PIN from one ZPK to another
DA DB Verify a terminal PIN using the IBM offset method
DC DD Verify a terminal PIN using the Visa PVV method
EA EB Verify an interchange PIN using the IBM offset method
EC ED Verify an interchange PIN using the Visa PVV method
G0 G1 Translate a PIN from DUKPT (BDK) to ZPK encryption
Command Answer What it does Notes
CW CX Generate a card verification code/value
CY CZ Verify a card verification code/value
Command Answer What it does Notes
M6 M7 Generate a MAC Mode 0 MACs a whole message. Modes 1 to 3 MAC a long one in parts, passing an IV between them.
M8 M9 Verify a MAC
Code Meaning
00 No error
01 Verification failure
02 Key inappropriate length for algorithm
04 Invalid key type code
05 Invalid key length flag
10 Source key parity error
11 Destination key parity error or key all zeros
13 Invalid LMK identifier
15 Invalid input data
20 PIN block does not contain valid values
22 Invalid account number
23 Invalid PIN block format code
24 PIN is fewer than 4 or more than 12 digits in length
25 Decimalization table error
26 Invalid key scheme
27 Incompatible key length
28 Invalid key type
29 Key function not permitted
41 Internal error
51 Invalid message header
68 Command has been disabled
80 Data length error

A key type is three hex digits: the LMK pair and the variant it’s encrypted under. The install chooses the classic table or the PCI HSM one, which gives TPKs and TMKs codes of their own.

Key type Classic PCI HSM
BDK 009 009
BDK-2 609 609
BDK-3 809 809
CVK 402 402
DEK 00B 00B
MK-AC 109 109
MK-CVC3 709 709
MK-DAC 409 409
MK-DN 509 509
MK-SMC 309 309
MK-SMI 209 209
PVK 002 002
TAK 003 003
TEK 30B 30B
TMK 002 80D
TPK 002 70D
WWK 006 006
ZAK 008 008
ZEK 00A 00A
ZMK 000 000
ZPK 001 001