Danie Schutte (CEO of Erlang Financial Systems) stumbled upon my blog recently (thanks for reading, Danie). I'm thankful for this happenstance, because Danie is super-sharp on data encryption and other matters pertaining to the implementation of financial payment systems. Danie mentioned that my post about Creating an IPEK from a given KSN and BDK would pertain specifically to situations in which a Single DES PIN Encrypting Key is in play. For situations in which a Triple DES PIN Encrpyting Key is in play, Danie passes along the following methodology:
Just for interest sake - the process of deriving the initial key (KEK) for the pos according to the ANSI specifications (This is for TDES)
Derivation of Initial Key (IPEK) from Base Derivation Key (BDK) The initial PIN Entry Device key (the key initially loaded into the PIN Entry
Device) is generated by the following process:
- Copy the entire key serial number, including the 21-bit encryption counter, right-justified into a 10-byte register. If the key serial number is less than 10 bytes, pad to the left with hex “FF” bytes.
- Set the 21 least-significant bits of this 10-byte register to zero.
- Take the eight most-significant bytes of this 10-byte register, and encrypt/decrypt/encrypt these eight bytes using the double-length derivation key.
- Use the ciphertext produced by Step 3 as the left half of the Initial Key.
- Take the 8 most-significant bytes from the 10-byte register of Step 2 and encrypt/decrypt/encrypt these 8 bytes using as the key the double-length derivation key XORed with hexadecimal C0C0 C0C0 0000 0000 C0C0 C0C0 0000 0000.
- Use the ciphertext produced by Step 5 as the right half of the Initial Key.
That also brings up a corresponding clarification required on my earlier piece entitled Doing PIN Translation (DUKPT to Triple DES). That post did a field-by-field breakdown of the CI/CJ command exchange with the Thales HSM. The Thales Host Command Reference Manual then follows that up with the G0/GI. [Note that it's G-zero, not G-Oh.] It's this second command exchange that should be employed should you be working with Triple DES DUKPT. The CI/CJ is for Single DES DUKPT only.