The text of a manual · part 14 of 23
PINpad 1000SE Reference and Programmers Guide, pages 131 to 140
Pages 131 to 140 of 229
The original document is the PDF (8.4 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the VeriFone PINPad 1000SE
Page 131
CHAPTER 7 MAC Packets This section describes the master-session MAC generation of message packets by the PINpad 1000SE device.
Preauthorization Packets
Message
Description
Z66
Z66 Request MAC
Z67
Z67 Return MAC
There are two kinds of MAC algorithms to be used. One is ANSI (Standard - ANSI is the industry standard) and another is BPI (Customer - BPI, Bank of Philippine Islands, is the customer’s name; this algorithm is specified by BPI).
PINPAD 1000SE REFERENCE AND PROGRAMMERS GUIDE
129
Page 132
MAC P ACKETS Z66 Request MAC
Z66 Request MAC Directs the PINpad device to generate the Message Authentication Code (MAC) of the current packet.
Category Support Mode
Comments
Custom Communication Packet PINpad 1000
PINpad 1000SE
D
D
This packet is used by the master device to direct the PINpad to generate the MAC of the current packet. If it is the first Z66 packet, the PINpad starts the MAC generation. If it is the last Z66 packet, the PINpad completes the MAC calculation from the current packet and returns the MAC to the master device with a Z67 packet. Otherwise, the PINpad calculates the MAC from the current packet and keeps it in memory. VeriFone imposes the following size rules on the [message for MAC] field.
Packet Type
Size of X
Maximum Message Size
Apply to Message Sequence
Key-only Format mode
• ASCII: X = 0, 1, 2 – 27, 28
224 bytes
00 – 99
• Binary: X = 0, 2, 4 – 26, 28
224 bytes
GISKE Key Block Format mode
• ASCII: X = 0, 1, 2 – 14, 15
120 bytes
• Binary: X = 0, 2, 4 – 12, 14
112 bytes
Packet Format
130
00 – 99
Comments
Due to of the size of GISKE Key Block, the size of message is reducing to 120 bytes.
<STX> Z66[packet flag] [sequence no.] [master key pointer] <FS> [working key] <FS> [second key] <FS> [message for MAC] <ETX>{LRC}
PINPAD 1000SE REFERENCE AND PROGRAMMERS GUIDE
Page 133
MAC P ACKETS Z66 Request MAC
Elements Type
Field
Length
Description
<STX> start of packet
1
ASCII Start of Text Control Character; Value: `02h'
Z66 message
3
Request MAC
[packet flag] message parameter
1
Packet flags identify whether the packet uses BPI or ANSI algorithm, whether the data is ASCII or binary, as well as packet position. • 0 = BPI-specific, ASCII, last packet • 1 = BPI-specific, ASCII, first/middle packet • 2 = BPI-specific, binary, last packet • 3 = BPI-specific, binary, first/middle packet • 4 = ANSI standard, ASCII, last packet • 5 = ANSI standard, ASCII, first/middle packet • 6 = ANSI standard, binary, last packet • 7 = ANSI standard, binary, first/middle packet [sequence #] numeric
2
Range: 00-99
[master key pointer] numeric
1
Optional; Range: 0-9
<FS> message parameter
1
Field separator
[working key] message parameter
16 or 120
Optional when PINpad is in PP1000 mode • 16AH - 1DES mode for single length key • 120AH - GISKE mode for Double/Triple
Length Key. See GISKE Key Block Specification VPN - 22986. <FS> message parameter
1
Field separator
[second key] numeric
1
Optional Second Master Key Pointer; Range: 0-9
<FS> message parameter
1
Field separator
[message for MAC] message parameter
0-64
ASCII message or ASCII-coded Binary data
8*X
• For ASCII data, X= 0 - 28 • For Binary data, X= 0, 2, 4, 6,..., 26, 28
(See Notes and Remark, below, for detail) <ETX> end of packet character
1
ASCII End of Text Control Character, Value:`03h'
{LRC} block code check
1
Error Check Character
Packet Length: maximum 255 characters, minimum 12 characters
PINPAD 1000SE REFERENCE AND PROGRAMMERS GUIDE
131
Page 134
MAC P ACKETS Z66 Request MAC
Example NOTE
<STX> Z66 3 00 2 <FS> 0123456789123456 <FS> <FS> 0123456789ABCDEF <ETX>{LRC} 1 For PINpad 1000 and PINpad 1000SE modes, there is no limit on the number of packets. The packet sequence increments the numeric sequence counter inside the packet for the first 100 packets, 0-99, and then keeps sending the 99 numeric sequence counter, with no errors. Thus, a 103-packet sequence would cycle through the following counters: 0, 1, 2, 3, 4, 5... 97, 98, 99, 99, 99, 99. 2 8*X in [message for MAC] represents the number of 8-byte (or character) blocks. For
ASCII data, all values of X from 0 - 28 are allowed. For Binary data, only 0, 2, 4, 6,...., 26, 28 are permitted. (X = 2 * N, where N = 0 to 14). For example, •X = 0 - no message data •X = 1 - 8 bytes of message data •X = 2 - 16 bytes of message data •X = 3 - 24 bytes of message data •... •X = 27 - 216 bytes of message data •X = 28 - 224 bytes of message data
For Binary data, only 0, 2, 4, 6,...., 26, 28 are permitted. (X = 2 * N, where N = 0 to 14). Do not use ASCII messages for Mac-ing that include ETX(0x03)or SO(0x0E). These can’t use these combinations in the [message] because they are reserved control characters that will trigger control functions 3 If the length of [message for MAC] is not multiple of 8 in the final Z66 packet, then the
PINpad will automatically pad it with zeros (ASCII 30h) internally. 4 An example of 8 bytes data block for an ASCII message "AMT$1.99" is
"414D5424312E3939". 5 ASCII-coded binary message is two HEX digits represent a byte value, like above conversion result. 6 If the Working Key is loaded in 1DES Key-only Format, either ANSI (standard) MAC or
BPI (customer's) MAC is used (which is depending on the status of the flag in the Z66 packet). 7 If the Working Key is loaded in the GISKE format, the PINpad uses the MAC algorithm that is specified in the Key Usage Attributes of GISKE key block. 8 When the Key Length and the MAC Algorithm do not match, an error code (key attribute
/ usage error) is returned. Example: a single length key is used with a 3DES MAC algorithm. 9 MAC Algorithms used: ISO 9797-1 MAC Algorithm 1 - 56 bits, MAC Algorithm 1 - 112 bits, MAC Algorithm 2 - 112 bits, MAC Algorithm 3 - 112 bits, MAC Algorithm 4 - 112 bits, MAC Algorithm 5 - 56 bits, MAC Algorithm 5 - 112 bits. 10 The GISKE working key can only be a single or double length key. Master key used to encrypt the working key can be a single, double or triple length key (GISKE Length Encryption Rule still applied here). If a triple length GISKE working key is used in Z66, the work key error is returned. 11 The GISKE working key can not be used in BPI MAC request, because the MAC algorithm used by the BPI is not part of the ANSI ISO MAC Standard. Working Key Error is returned if BPI MAC-Request uses GISKE working key.
Protocol
132
The communication protocol sequence is included in Message Authentication Code (MAC) under Z66/Z67 Protocol, with examples for both Normal Condition and Error Condition.
PINPAD 1000SE REFERENCE AND PROGRAMMERS GUIDE
Page 135
MAC P ACKETS Z67 Return MAC
Z67 Return MAC Signals the controller in response to Z66 Request MAC.
Category Comments
Packet Format
Custom Communications Packet Packet Z67 sends three types of messages to the controller:
•
A signal that the PINpad is ready for the next Z66 packet
•
An error code if there is any error during the MAC session
•
The MAC value
<STX> Z67[process code] [MAC field] <ETX>{LRC}
Elements Packet
Field
Length
Description
<STX> start of packet
1
ASCII Start of Text Control Character; Value: `02h'
Z67 message
3
Return MAC
[process code] message parameter
1
Process Code; Range: 0-9 • 0 = no error and MAC follows • 1 = ready for next Z66 packet and no
MAC follows • 2 = out-of-order error and no MAC follows • 3 = [pointer] error and no MAC follows • 4 = [second key] error and no MAC follows • 5 = packet frame error and no MAC follows • 6 = [flag] error • 7 = [message] error • 8 = [working key] error / GISKE Key
Usage, Algorithm, Mode of Use or Key Length Error • 9 = incorrect key attributes of the master key (first or second) MAC field message parameter
16
Optional MAC Value, only sent when no error
<ETX> end of packet character
1
ASCII End of Text Control Character, Value:`03h'
{LRC} block code check
1
Error Check Character
Packet Length: maximum 23 characters, minimum 7 characters
PINPAD 1000SE REFERENCE AND PROGRAMMERS GUIDE
133
Page 136
MAC P ACKETS Z67 Return MAC
Example
<STX> Z671 <ETX>{LRC}
Ready for next Z66 packet; no MAC follows.
Protocol
134
The communication protocol sequence is included in Message Authentication Code (MAC) under Z66/Z67 Protocol, with examples for both Normal Condition and Error Condition.
PINPAD 1000SE REFERENCE AND PROGRAMMERS GUIDE
Page 137
MAC P ACKETS Message Authentication Code (MAC)
Message Authentication Code (MAC)
The Message Authentication Code (MAC) module operates in conjunction with custom communication packets Z66 Request MAC and Z67 Return MAC and is used between the PINpad device and controller. MAC-ing is supported when the PINpad is set as "Master/Session" or master and DUKPT. MAC utilizes some techniques of DES to ensure that the message sent is an authentic message and has not been fraudulently changed. The algorithm used to calculate the MAC is fully compatible with the ANSI X9.19 standard, based on Financial Institution Retail Message Authentication. There are two modes of operation within this standard:
•
Cipher Block Chaining (CBC)
•
64-bit Cipher Feedback (CFB-64)
The Cipher Block Chaining (CBC) mode of operation is used for MAC calculation in PINpad device implementation.
ANSI (Standard) MAC Algorithms
The algorithm used to calculate the MAC is fully compatible with ANSI X9.19 1986 (ANSI 1DES MAC), Financial Institution Retail Message Authentication. Within this standard, there are two modes of operation, Cipher Block Chaining (CBC) and 64 bit Cipher Feedback (CFB-64). In the PINpad 1000SE implementation, the Cipher Block Chaining (CBC) will be used for MAC calculation. The master key and the working key for MAC calculation can be downloaded with Packet Z66 if necessary. The selection of these keys depends on the first Z66 packet configurations within each MAC session, they are summarized as following: [pointer]
[working key]
Selection present present
Master key selected by the [pointer] is used to decrypt the working key.
present absence
Master key selected by [pointer] is used as the working key. • PP1000SE mode: Working key is no longer optional due to security concerns. • PP1000 mode: Working key can be an optional entry absence present
Current active master key is used to decrypt the working key.
absence absence
Current Active Master Key is used as the working key. • PP1000SE mode: Working key is no longer optional due to security concerns. • PP1000 mode: Working key can be an optional entry
PINPAD 1000SE REFERENCE AND PROGRAMMERS GUIDE
135
Page 138
MAC P ACKETS Message Authentication Code (MAC)
After the MAC calculation, there is one more optional procedure that can be used for increased protection against exhaustive key determination. This operational procedure can be turned on or off by the second key field of the initial Z66 packet. If this second key was provided with the initial Z66 packet, the optional procedure generates the final MAC using the second key as the master key pointer. If there is no second key provided, no optional procedure will take place on the current MAC. NOTE
The second key is used on a session-by-session basis. Each second key field of the initial Z66 packet defines its own optional procedure ON/OFF status during that MAC session. For more details about the MAC optional procedure, refer to Section 2.4.4.5 of the ANSI X9.19 standard. After the MAC calculation process is complete, a 64-bit MAC is generated. This MAC value will be return to the master device with the Z67 packet. If there is any error during the MAC process session, Packet Z67 will be returned with an error code set in [code].
BPI (Customer) MAC Algorithms
The algorithm used to calculate the MAC is fully compatible with BPI's specification that is summarized as following:
1 The message stream is divided into 64-bit (8byte) block. 2 If the length of the last block is less than 8 bytes, pad it with binary 0 to make it 8 bytes long.
3 EXOR-ed the first block with the second block. 4 EXOR-ed the previous step result with next block. 5 Repeat Step 4 till the last block been EXOR-ed. 6 Encrypt the final result with DES key. 7 The encrypted result is the MAC. The master key and the working key for MAC calculation can be downloaded with Packet Z66 if necessary. The selection of these keys depends on the first Z66 packet configurations within each MAC session. They are summarized as following: [pointer]
[working key]
Selection present present
Master key selected by the [pointer] is used to decrypt the working key.
present absence
Master key selected by [pointer] is used as the working key. • PP1000SE mode: Working key is no longer optional due to security concerns. • PP1000 mode: Working key can be an optional entry 136
PINPAD 1000SE REFERENCE AND PROGRAMMERS GUIDE
Page 139
MAC P ACKETS Message Authentication Code (MAC)
[pointer]
[working key]
Selection absence present
Current active master key is used to decrypt the working key.
absence absence
Current Active Master Key is used as the working key. • PP1000SE mode: Working key is no longer optional due to security concerns. • PP1000 mode: Working key can be an optional entry
After the MAC calculation, there is one more optional procedure that can be used for increased protection against exhaustive key determination. This optional procedure can be turn on/off by the [second key] field of the initial Z66 packet. If this second key was provided with the initial Z66 packet, the optional procedure will be taken to generate the final MAC using the [second key] as the master key pointer. If there is no [second key] provided, no optional procedure will be taken on the current MAC. One thing to note is that this [second key] is used on sessionby-session basis. Each [second key] field of the initial Z66 packet defines its own optional procedure on/off status during that MAC session. The optional procedures are
1 The master key selected by [second key] will be used to decrypt the MAC result.
2 The previous result is encrypted with original DES key, the result is the final MAC. After the MAC calculation process is complete, a 64-bit MAC is generated. This MAC value will be return to the controller with the Z67 packet. If there is any error during the MAC process session, Packet Z67 will be returned with an error code set in [code].
MAC Process Session
NOTE
When the first Z66 packet is received, the PINpad device enters the MAC process session. If this packet is also the last packet, the Z67 packet is returned to the master device and the PINpad reverts back to the non-MAC state and all the MAC working data in memory will be erased. If the Z67 packet is not the last packet, the PINpad calculates the MAC from the current Z66 packet then returns the Z67 packet to signal the master device that the PINpad is ready for next Z66 packet. This MAC process session continues for every Z66 packet received until the last Z66 packet is received. When the last Z66 is received, the PINpad calculates the MAC from this packet and generates and returns the Z67 packet. If any other packet is received during the MAC session, the entire MAC process aborts and no packet is returned. All MAC working data in memory is erased and the newly received packet will be processed normally.
PINPAD 1000SE REFERENCE AND PROGRAMMERS GUIDE
137
Page 140
MAC P ACKETS Message Authentication Code (MAC)
During the MAC process session, all Z66 packets are checked for correct sequence as they are received. The correct sequence should be 00, 01, 02,....,99, with a maximum of one hundred Z66 packets in one MAC session. If any Z66 packet is received out of sequence during a MAC session, that packet is ignored and the PINpad still returns the Z67 packet to signal the master device to send the next Z66 packet. If the last Z66 packet is received out of sequence, no MAC will be generated; the Z67 packet returns to the master device with an "Out of Order" error code, and the PINpad device returns to its idle state. The following are normal and error condition sequences for a MAC session. Normal Condition Controller
Transmission Direction
PINpad
Send first Z66 MAC request
---Z66--->
Receive
Wait
Process
Receive
<---Z67---
Send Ready Packet
Send next Z66 MAC request
---Z66--->
Receive
Wait
Process
Receive
<---Z67---
Send another Ready Packet
...
...
...
Send last Z66 MAC request
---End Z66--->
Receive
Wait Receive
Calculate MAC <---Z67---
Send MAC
Controller
Transmission Direction
PINpad
Send first Z66 MAC request
---Z66--->
Receive
Error Condition
Wait
Process
Receive
<---Z67---
Send Ready Packet
Send next Z66 MAC request
---Z66--->
Receive
Wait
138
Process
Receive
<---Z67---
Send another Ready Packet
...
...
...
Send last Z66 MAC request
---End Z66--->
Receive out of order
PINPAD 1000SE REFERENCE AND PROGRAMMERS GUIDE