PayEx IFSF H2H Security specification

Last modified by Pål-Eirik Askerød on 2023/02/22 11:29

Key schemes

PayEx  support fixed H2H Shared keys for MAC, PIN and Data Encryption or a ZKA scheme.

This fixed key solution defines three different keys which are shared with the 3rd party that integrates the PayEx H2H IFSF protocol.

The ZKA scheme defines a master ZKA key used to derive an Pin and Mac key unique per transaction. The data encryption key is used the same way as the fixed key solution.

Test keys

 H2H Key versionComponent 1 KCV Component 2 KCVTotal Key KCV
Encryption Key01007686 D6CB 708F 2319 108A 7AB6 9E8C 64161 B7DB 12602D30 6353 8E47 C074 6A9F AA53 84C9 3F0A 25B5 7BF74C12B4
MAC Key 010007C8 A734 29BA 2A437C76 C8BC 4551 7607 6224 DE35AC1E CA72 9927 7D74 ED65 EED4 0065 097B 6320 95D1 7CC660 
PIN Key 0100F210 F201 7A3E 3D89 20D9 B53D 1C49 13EF 10EC E3C47133 9066 2BF9 5F8D 2863 D2B4 1E17 7D5C F116 767E866C07
ZKA Key 0200F210 F201 7A3E 3D89 20D9 B53D 1C49 13EF 10EC E3C47133 9066 2BF9 5F8D 2863 D2B4 1E17 7D5CF116 767E 866C07
ZKA Data Encryption Key02007686 D6CB 708F 2319 108A 7AB6 9E8C 64161 B7DB 12602D30 6353 8E47 C074 6A9F AA53 84C9 3F0A 25B5 7BF74C12B4

Procedure to create complete keys:
Component1 Xor Component2 = key. Then copy the first 8 bytes of key to the end of key to a total of 24 bytes.

Check key against total KCV.
Create 8 byte array with zero bytes and encrypt with Triple-DES ECB and compare 4 first bytes to total KCV. If they match key is genereated correctly

Security Related Control Information

This information is transported in field P-53 towards PayEx Host. For scheme H2H Shared keys only 53-1 needs to be populated with the version of keys.

This field (53-1) needs to be present in all request that have MAC, PIN or encrypted data. Field P-53 is binary with LLVAR length. 

ElementNameFormatAttributeDescription
53 n2LLVAR length field
53-1H2H Key versionb2Version of keys shared by PayEx with 3rd party. E.g "0100" when using the test keys or "0200" when using ZKA keys
53-2MAC random valueb16

 ZKA MAC random value.

53-3PAC random valueb16ZKA PAC random value.

PayEx shared key scheme

PayEx supplies key version to be sent in 53-1. This scheme defines 3 different keys for MAC, PIN and Data encryption which will be shared between PayEx and 3rd party. 

ZKA scheme 

PayEx supplies key version to be sent in 53-1. Note that a set of different values are defined for both test and production. Also values are unique for every third party (host).

For optimal security it is a good practice to use different random values for the MAC and PAC. However the security impact of having the same random number for PAC and MAC is very limited. Especially because in the MK/SK security scheme an XOR of the Master key with a fixed Control Mask is done, where the Control Mask value is different for PIN and MAC. So even if the MAC session key would be compromised the PIN session key still cannot be determined even when the same random number is used. It is important to assure that different random numbers are used for every transaction.

Message Authentication Code (MAC)

We use ISO/IEC 9797-1 MAC algorithm 3 also known as Retail Mac.

PayEx uses a double-length key. (128 bit)

The input for the MAC calculation/verification will be the SHA-256 of the IFSF message. The message length header and the MAC block itself are not included, however the MAC bit in the bitmap is part of the message and is already set when calculating the MAC.

Mac calculation method:

3-Figure1-1.png

1. The incoming message is padded with 0x00 until the message length is multiple of 8 bytes.
2. The 128 bit key is divided into two sub-keys. Left part is called K1, and right part K2.
3. Data is encrypted as DES CBC with K1
4. Take the last blocks output data and DES encrypt again with K1
5. Take the output data and decrypt DES with K2
6. Take the output data and encrypt DES with K1
7. For ZKA MAC use the 8 bytes of output data as MAC. For fixed key MAC take the first 4 bytes of output data and pad with 0x00 again to 8 bytes. 

Transport of MAC

MAC value is transported in P-64 or P-128 towards PayEx. P-128 is used when P-127 is present. Field is binary with a length of 8.

Personal Identification Number (PIN)

Pin enciphered block is transported in P-52 towards PayEx. Format is binary, length 8.

PIN-block format is ISO-0 (same as ANS X9.8, VISA-1, and ECI-1).

Pin encryption key must be used to encrypt pin block sent to PayEx.

PIN Encryption Methodology

This information is transported in P-48.14 field towards PayEx Host. 

ElementNameFormatAttributeDescription
48 n3LLLVAR length field
48-14PIN Encryption Methodologyans2Identifies the PIN encryption scheme used for pin block encryption. Supported values listed below.

 ‘13’: PayEx H2H shared keys

 ‘33’: ZKA MS/SK PAC H2H

When P-52 is present in request, this field must also be present. When field P-52 is NOT present, field 48-14 should also NOT be present.

PayEx H2H shared key scheme defines a pin encryption key that is used to encrypt the pin block.

Data encryption

Encrypted card data (track2) is transported in P-127 field towards PayEx. Format is LLLBinary 

Data must be encrypted with Triple-DES CBC mode using the data encryption key provided by PayEx.

This field has TLV format. 

Tag (3 hex chars) is field number in BCD. Eks: P-35='035'

Length (2 hex chars) is the length of the data field in hex.

Value encrypted field value in hex

Complete TLV data is packed to binary and padded to a multiple of 8 bytes.

Track2 eksempel in hex:

035257071557105754509915D19034000040000000F00000 (24 bytes)

Tag: 035

Length: 25x = 37

Value: 7071557105754509915D19034000040000000

Padding: F00000 ( Padding contains an end sentinel)

Tags:
Created by Helge Dahl on 2020/04/02 10:11