# Data Format

Multi-byte values like command and data lengths are always big-endian.

### Message Types <a href="#toc156981689" id="toc156981689"></a>

#### Data <a href="#toc156981690" id="toc156981690"></a>

Data Messages are formed in response to a cardholder event such as swiping a card or pressing a button.  These messages are formatted as a block of ASCII text and compatible with all interfaces.

#### Commands <a href="#toc156981691" id="toc156981691"></a>

Commands consist of a 2-byte command, a 2-byte Parameter Data Length, and Parameter Data as needed.

### Table - Command Structure

<table data-header-hidden><thead><tr><th width="135"></th><th></th><th></th></tr></thead><tbody><tr><td>Command</td><td>Parameter Data Len</td><td>Parameter Data</td></tr><tr><td>2-bytes</td><td>2-bytes</td><td>0…n bytes</td></tr></tbody></table>

#### Responses <a href="#toc156981692" id="toc156981692"></a>

Responses consist of a 2-byte return code, a 2-byte response data length, and response data as needed.

### Table - Response Structure

| Return Code | Response Data Len | Response Data |
| ----------- | ----------------- | ------------- |
| 2-bytes     | 2-bytes           | 0...n bytes   |

#### Notifications <a href="#toc156981693" id="toc156981693"></a>

Notifications consist of a 2-byte notification code, a 2-byte notification data length, and notification data when needed. They are sent asynchronously due to device events.  They can also be used as delayed responses for commands that take longer to process.

### Table - Notification Structure

| Notification ID | Notification Data Len | Notification Data |
| --------------- | --------------------- | ----------------- |
| 2-bytes         | 2-bytes               | 0...n bytes       |

### Data Output <a href="#toc156981695" id="toc156981695"></a>

#### MSR Track Data

**Sentinels**

Data for each card track is typically bracketed by a start and end sentinel.  The sentinel characters can be changed by setting properties. The start sentinel can also indicate what format was used to encode the track.

\[SS] Track Data \[ES]

If a property value is set to 0, then no character will be sent.

### Table - Track Data Sentinel Properties

<table data-header-hidden><thead><tr><th width="98.99996948242188"></th><th></th><th width="88.66668701171875"></th><th></th><th></th></tr></thead><tbody><tr><td>Name</td><td>Description</td><td>Length</td><td>Property</td><td>Default</td></tr><tr><td>T1ISO</td><td>Tk1 SS if ISO</td><td>1</td><td>0x24</td><td>0x25 ‘%’</td></tr><tr><td>T2ISO</td><td>Tk2 SS if ISO</td><td>1</td><td>0x25</td><td>0x3B ‘;’</td></tr><tr><td>T3ISO</td><td>Tk3 SS if ISO</td><td>1</td><td>0x26</td><td>0x2B ‘+’</td></tr><tr><td>T3AMV</td><td>Tk3 SS if AAMVA</td><td>1</td><td>0x27</td><td>0x23 ‘#’</td></tr><tr><td>T27BT</td><td>Tk2 SS if 7bit</td><td>1</td><td>0x28</td><td>0x40 ‘@’</td></tr><tr><td>T37BT</td><td>Tk3 SS if 7bit</td><td>1</td><td>0x29</td><td>0x26 ‘&#x26;’</td></tr><tr><td>ES</td><td>End sentinel</td><td>1</td><td>0x2B</td><td>0x3F ‘?’</td></tr></tbody></table>

**Masking**

The PAN field must always be partially masked.  The device can be configured to expose the 0-8 leading characters and 0-4 trailing characters. The 8-digit limit for leading characters automatically drops to 6 for cards where the PAN length is less than 16 (e.g. American Express).

Properties 0x07 and 0x08 are used to configure PAN masking.

{% hint style="info" %}
**Note:** PCI Requirement – SCR devices that can be used with consumer devices must fully mask cardholder name, expiration date, and service code with no exceptions.
{% endhint %}

### PCI/Non-PCI Masking

{% hint style="info" %}
**Note:** The description in this section is for non-PCI device case. The following table shows the difference between non-PCI device and PCI device masking rule.
{% endhint %}

<table data-header-hidden><thead><tr><th width="166.272705078125"></th><th></th><th></th></tr></thead><tbody><tr><td><strong>M001/M002 Message</strong></td><td><strong>Non-PCI</strong></td><td><strong>PCI</strong></td></tr><tr><td>PAN masking</td><td>Can be configured using Property 0x07 and 0x08.</td><td><p>Can be configured using Property 0x07 or 0x08 with the following exceptions.</p><p>·  Masking Character, ‘V’, is not supported in Property 0x07/0x08.</p><p>·  Not allowed to unmask leading PAN digits more than 6 digits when PAN length is 15 digits.</p></td></tr><tr><td>Name masking</td><td>Always fully unmasked.</td><td>Always fully masked with ‘*’.</td></tr><tr><td><p>ISO Only:</p><p>Expiration Date masking</p></td><td>Always fully unmasked (4 digits).</td><td>Always masked with 5th character from Property 0x07.</td></tr><tr><td><p>ISO Only:</p><p>Service Code masking</p></td><td>Can be enabled or disabled using Property 0x6E (3 digits).</td><td>Always masked with 5th character from Property 0x07.</td></tr><tr><td><p>AAMVA Only:</p><p>Expiration Date and Birth Date</p></td><td>Always fully unmasked (12 digits).</td><td>Always masked with 5th character from Property 0x08.</td></tr><tr><td>Discretionary Data masking</td><td>Unmasked if error. Otherwise, masked with 5th character from Property 0x07 or 0x08.</td><td>Unmasked if error. Otherwise, masked with 5th character from Property 0x07 or 0x08.</td></tr></tbody></table>

## **DUKPT Key Info for Encrypted Data Output**

Data messages include DUKPT KEY information fields so the host can derive the correct decryption or MAC key.

### Table - DUKPT Key Derivation Information

<table data-header-hidden><thead><tr><th width="59.9090576171875"></th><th width="59.27276611328125"></th><th width="114.45458984375"></th><th width="310.272705078125"></th><th width="220.09088134765625"></th></tr></thead><tbody><tr><td>Byte</td><td>Len</td><td>Description</td><td>Values</td><td>Notes</td></tr><tr><td>1</td><td>1</td><td>DUKPT Key Info Version</td><td><p>0x00 – Legacy DUKPT</p><p>0x01 – Current (AES) DUKPT</p></td><td> </td></tr><tr><td>2</td><td>1</td><td>For Data Item</td><td><p>0x01 – RFU</p><p>0x01 – Message MAC</p><p>0x02 – MSR Data</p><p>0x03 – MP Token</p><p>0x04 – Qwantum Token</p><p>0x05 – Qwantum Data</p></td><td> </td></tr><tr><td>3</td><td>1</td><td>Using Mode/Operation</td><td><p>0x00 – RFU</p><p>0x01 – ENC-CBC-0</p><p>0x02 – ENC-CBC-SECURE</p><p>0x03 – ENC-CTR</p><p> </p><p>0x10 – MAC-CBC-0</p><p>0x11 – CMAC</p><p>0x12 – HMAC</p><p>0x13 – GMAC</p></td><td> </td></tr><tr><td>4</td><td>1</td><td>Derived Key Algorithm</td><td><p>0x00 – 2-key TDEA</p><p>0x01 – 3-key TDEA</p><p>0x02 – AES 128-bit</p><p>0x03 – AES 192 bit</p><p>0x04 – AES 256 bit</p><p>0x05 – HMAC</p></td><td> </td></tr><tr><td>5-6</td><td>2</td><td>Generated Key Length (bits)</td><td><p>0x0100 – 256 bits</p><p>0x0080 – 128 bits</p></td><td> </td></tr><tr><td>7-8</td><td>2</td><td>Derived Key Usage</td><td><p>0x2002 – MAC, both ways</p><p>0x3002 – Data Encryption, both ways</p><p>0xFF00 – Legacy PIN Variant</p><p>0xFF01 – Legacy MAC, both ways</p><p>0xFF02 – Legacy Data Encryption</p></td><td>AES DUKPT: Use “Legacy: FFnn”, which means “shift FF left nn bytes”.</td></tr></tbody></table>

Example:&#x20;

```
00 02 01 00 0080 FF02 MSR encrypt CBC zero pad with legacy DUKPT 128-bit TDEA data variant.
```

{% hint style="info" %}
**Note:** Derived key algorithm, length, and usage information will be needed to generate the correct AES-DUKPT decryption key.
{% endhint %}

## Data Messages

Data messages will always be made up of ASCII text characters regardless of the interface for compatibility purposes.  Text is used to address limitations when using keyboard emulation.

## **Normal Operation – Financial Card Read Message**

Any Field with no value will be empty between separator characters.

### Table - Data Message M001 Definition

<table data-header-hidden><thead><tr><th></th><th width="94.33331298828125"></th><th width="77.9697265625"></th><th width="89.66668701171875"></th><th></th></tr></thead><tbody><tr><td>Field Description</td><td>Prot</td><td>Type</td><td>Txt Len</td><td>Notes</td></tr><tr><td>Message ID = “M001”</td><td>Clear</td><td>ASCII</td><td>4</td><td>MSR Data Message</td></tr><tr><td>Track 1 Masked Data</td><td>Clear</td><td>ASCII</td><td>var</td><td>Per masking configuration</td></tr><tr><td>Track 2 Masked Data</td><td>Clear</td><td>ASCII</td><td>var</td><td>Per masking configuration</td></tr><tr><td>Track 3 Masked Data</td><td>Clear</td><td>ASCII</td><td>var</td><td>Per masking configuration</td></tr><tr><td>Track 1 Data</td><td>Encrypt</td><td>HEX</td><td>var</td><td>Encrypted with MSR key.</td></tr><tr><td>Track 2 Data</td><td>Encrypt</td><td>HEX</td><td>var</td><td>Encrypted with MSR key.</td></tr><tr><td>Track 3 Data</td><td>Encrypt</td><td>HEX</td><td>var</td><td>Encrypted with MSR key.</td></tr><tr><td>MP Status Code</td><td>Clear</td><td>HEX</td><td>8</td><td> </td></tr><tr><td>MP Token</td><td>Encrypt</td><td>HEX</td><td>var</td><td>Encrypted with MSR or MP key as configured (see Property 0x15).</td></tr><tr><td>Session ID</td><td>Encrypt</td><td>HEX</td><td>16/32</td><td>Encrypted with MSR key. Session ID = RTC value.</td></tr><tr><td>KSN (MSR)</td><td>Clear</td><td>HEX</td><td>20/24</td><td> </td></tr><tr><td>DUKPT Key Info (MSR)</td><td>Clear</td><td>HEX</td><td>16</td><td> </td></tr><tr><td>KSN (MP)</td><td>Clear</td><td>HEX</td><td>0/20/24</td><td>Empty when MSR key is used</td></tr><tr><td>DUKPT Key Info (MP)</td><td>Clear</td><td>HEX</td><td>16</td><td>Empty when MSR key is used</td></tr><tr><td>Device Serial Number</td><td>Clear</td><td>ASCII</td><td>7</td><td><p>Indicates valid range of each hex digit – </p><ul><li>‘0’ ~ ‘9’ (0x30 ~ 0x39), </li><li>’A’ ~ ‘F’ (0x41 ~ 0x46)</li></ul></td></tr><tr><td>DUKPT Key Info (MAC)</td><td>Clear</td><td>HEX</td><td>16</td><td>Using MSR Key</td></tr><tr><td>Message Length</td><td>Clear</td><td>HEX</td><td>4</td><td>Include all of message except for MAC. Length required for MAC security. High byte first.</td></tr><tr><td>MAC</td><td>Clear</td><td>HEX</td><td>16/32 </td><td><p>MAC variant of MSR encryption key is used to calculate MAC.</p><ul><li>CBC MAC if MSR DUKPT key is TDES</li><li>CMAC if MSR DUKPT key is AES</li></ul></td></tr></tbody></table>

{% hint style="info" %}
**Note:** Text length may vary depending on the key type that is being used.
{% endhint %}

## **Normal Operation – Financial Card Read Message with Selectable Card Data Encryption Enabled**

### Table - Data Message M002 Definition

<table data-header-hidden><thead><tr><th></th><th width="118.727294921875"></th><th width="80.8182373046875"></th><th width="105.636474609375"></th><th></th></tr></thead><tbody><tr><td>Field Description</td><td>Prot</td><td>Type</td><td>Txt Len</td><td>Notes</td></tr><tr><td>Message ID = “M002”</td><td>Clear</td><td>ASCII</td><td>4</td><td>MSR Data Message</td></tr><tr><td>Track 1 Masked Data</td><td>Clear</td><td>ASCII</td><td>var</td><td>Per masking configuration</td></tr><tr><td>Track 2 Masked Data</td><td>Clear</td><td>ASCII</td><td>var</td><td>Per masking configuration</td></tr><tr><td>Track 3 Masked Data</td><td>Clear</td><td>ASCII</td><td>var</td><td>Per masking configuration</td></tr><tr><td>Track 1 Data</td><td>Encrypt</td><td>HEX</td><td>var</td><td>Encrypted with MSR key.</td></tr><tr><td>Track 2 Data</td><td>Encrypt</td><td>HEX</td><td>var</td><td>Encrypted with MSR key.</td></tr><tr><td>Track 3 Data</td><td>Encrypt</td><td>HEX</td><td>var</td><td>Encrypted with MSR key.</td></tr><tr><td>MP Status Code</td><td>Clear</td><td>HEX</td><td>8</td><td> </td></tr><tr><td>MP Token</td><td>Encrypt</td><td>HEX</td><td>var</td><td>Encrypted with MSR or MP key as configured (see Property 0x15).</td></tr><tr><td>Session ID</td><td>Encrypt</td><td>HEX</td><td>16/32</td><td>Encrypted with MSR key. Session ID = RTC value.</td></tr><tr><td>KSN (MSR)</td><td>Clear</td><td>HEX</td><td>20/24</td><td> </td></tr><tr><td>DUKPT Key Info (MSR)</td><td>Clear</td><td>HEX</td><td>16</td><td> </td></tr><tr><td>KSN (MP)</td><td>Clear</td><td>HEX</td><td>0/20/24</td><td>Empty when MSR key is used</td></tr><tr><td>DUKPT Key Info (MP)</td><td>Clear</td><td>HEX</td><td>0/16</td><td>Empty when MSR key is used</td></tr><tr><td>Device Serial Number</td><td>Clear</td><td>ASCII</td><td>7</td><td>Indicates valid range of each hex digit – ‘0’ ~ ‘9’ (0x30 ~ 0x39), ‘A’ ~ ‘F’ (0x41 ~ 0x46)</td></tr><tr><td>DUKPT Key Info (MAC)</td><td>Clear</td><td>HEX</td><td>16</td><td>Using MSR Key</td></tr><tr><td>Message Length</td><td>Clear</td><td>HEX</td><td>4</td><td>Include all of message except for MAC. Length required for MAC security. High byte first.</td></tr><tr><td>MAC</td><td>Clear</td><td>HEX</td><td>16/32 </td><td><p>MAC variant of MSR encryption key is used to calculate MAC.</p><ul><li>CBC MAC if MSR DUKPT key is TDES</li><li>CMAC if MSR DUKPT key is AES</li></ul></td></tr><tr><td>Encrypted SCDE</td><td>Encrypt</td><td>HEX</td><td>var</td><td> </td></tr><tr><td>KSN (SCDE)</td><td>Clear</td><td>HEX</td><td>20/24</td><td> </td></tr><tr><td>DUKPT Key Info (SCDE)</td><td>Clear</td><td>HEX</td><td>16</td><td> </td></tr></tbody></table>

{% hint style="info" %}
**Note:**

* Text length may vary depending on the key type that is being used.
* The three SCDE fields at the bottom of the message are not part of the MAC calculation.
  {% endhint %}

The device transmits an M002 message with three new data fields: Encrypted SCDE, KSN (SCDE) and DUKPT Key Info (SCDE) to the host instead of an M001 message when the following four conditions are satisfied. Selectable Card Data Encryption is enabled through Property 0x78.

* Any of the defined property 0x78 bits are set to 1 (enabled),
* Card Encode Type is ISO (a.k.a. financial card),
* SCDE DUKPT key is injected or present in the device, and
* SCDE DUKPT future keys are available (not exhausted)

If any one of the four conditions is not met, an M001 message will be returned to the host instead of an M002 message.

The encrypted SCDE field in the M002 message, \[Encrypted SCDE], includes six data fields, field\_1 \~ field\_6. The six data fields are placed in a buffer prior to encryption. The selectable card data element starts with a field separator (FS) followed by a data field, and the last field separator is appended following the sixth data field (field\_6) as shown below (total seven FS characters). The field separator used in the SCDE is the same FS used in the M001 or M002 message, which may be changed using Property 0x23.

Each data field in the SCDE is defined as follows.

### Table - SCDE Data Fields

<table data-header-hidden><thead><tr><th width="100.3636474609375"></th><th></th><th width="89.9090576171875"></th><th width="134.9090576171875"></th><th></th></tr></thead><tbody><tr><td> </td><td>Description</td><td>Type</td><td>Length (bytes)</td><td>Property 0x78</td></tr><tr><td>field_1</td><td>Cardholder Name from Track 1</td><td>AN</td><td>var (max 26)</td><td>bit 0</td></tr><tr><td>field_2</td><td>PAN from Track 1or Track 2 (padding nibble=F)</td><td>CN</td><td>var (max 19)</td><td>bit 1</td></tr><tr><td>field_3</td><td>Expiration Date from Track 1 or Track 2</td><td>4N</td><td>2</td><td>bit 2</td></tr><tr><td>field_4</td><td>Service Code from Track 1 or Track 2</td><td>3N</td><td>2</td><td>bit 3</td></tr><tr><td>field_5</td><td>T1 discretionary data</td><td>AN</td><td>var</td><td>bit 4</td></tr><tr><td>field_6</td><td>T2 discretionary data (padding nibble=F)</td><td>CN</td><td>var</td><td>bit 5</td></tr></tbody></table>

The SCDE DUKPT key (DKPTM1F) is used to encrypt the six data fields (| field\_1 | field\_2 | field\_3 | field\_4 | field\_5 | field\_6 |)only. No other keys should be used for the SCDE.

The encrypted SCDE field in the M002 message is an encrypted blob holding six card data fields selected with Property 0x78 bits. If a defined bit is set to zero, the corresponding data field will be empty in the clear-text SCDE. The clear-text SCDE including enabled data fields will be encrypted with an SCDE DUKPT future key.

When all defined bits in the property 0x78 are set to zeros, the encrypted SCDE is disabled. As a result, the M001 message should be transmitted to the host instead of the M002 message.

Encrypt( | field\_1 | field\_2 | field\_3 | field\_4 | field\_5 | field\_6 | )

**Field Separation**

This device uses configurable properties to define characters that get inserted into the message for parsing purposes. The simplest option is to have characters for start of message (SOM), end of message (EOM), and field separation (FS) only.

### Table - Separating text fields for host parsing.

<table data-header-hidden><thead><tr><th width="92.6666259765625"></th><th></th><th width="99"></th><th width="113"></th><th width="109"></th><th></th></tr></thead><tbody><tr><td>Name</td><td>Description</td><td>Length</td><td>Property</td><td>Default</td><td>To Disable</td></tr><tr><td>SOM</td><td>Start of Message</td><td>0-7</td><td>0x1E</td><td>0</td><td>0</td></tr><tr><td>EOM</td><td>End of Message</td><td>0-7</td><td>0x22</td><td>‘\r’ (0x0D)</td><td>0</td></tr><tr><td>FS</td><td>Field Separator</td><td>1</td><td>0x23</td><td>‘|’ (0x7C)</td><td>0</td></tr></tbody></table>

{% hint style="info" %}
**Note:** Portion in bold shows the data included in the output MAC calculations.
{% endhint %}

```
[SOM] M001
[FS] [Track 1 Masked Data]
[FS] [Track 2 Masked Data]
[FS] [Track 3 Masked Data]
[FS] [Track 1 Encrypted Data]
[FS] [Track 2 Encrypted Data]
[FS] [Track 3 Encrypted Data]
[FS] [MP Status]
[FS] [Encrypted MP Data]
[FS] [Encrypted Session ID]
[FS] [MSR DUKPT Key Serial Number]
[FS] [MSR DUKPT Key Info]
[FS] [MP DUKPT Key Serial Number]
[FS] [MP DUKPT Key Info]
[FS] [Device Serial Number]
[FS] [MAC DUKPT Key Info]
[FS] [MAC message length] 
[FS] [MAC]
[EOM]
[FS] [MAC][EOM]

[SOM] M002
[FS] [Track 1 Masked Data]
[FS] [Track 2 Masked Data]
[FS] [Track 3 Masked Data]
[FS] [Track 1 Encrypted Data]
[FS] [Track 2 Encrypted Data]
[FS] [Track 3 Encrypted Data]
[FS] [MP Status]
[FS] [Encrypted MP Data]
[FS] [Encrypted Session ID]
[FS] [MSR DUKPT Key Serial Number]
[FS] [MSR DUKPT Key Info]
[FS] [MP DUKPT Key Serial Number]
[FS] [MP DUKPT Key Info]
[FS] [Device Serial Number]
[FS] [MAC DUKPT Key Info]
[FS] [MAC message length] 
[FS] [MAC]
[FS] [Encrypted SCDE]
[FS] [SCDE DUKPT Key Serial Number]
[FS] [SCDE DUKPT Key Info]
[EOM]

[SOM] Q001
[FS] [Token DUKPT Key Serial Number]
[FS] [Token DUKPT Key Info]
[FS] [QWANTUM Status]
[FS] [QWANTUM Token]
[FS] [Encrypted Session ID]
[FS] [QWANTUM Card ID]
[FS] [Device Serial Number]
[FS] [MAC DUKPT Key Info]
[FS] [MAC message length]
[FS] [MAC]
[EOM]

[SOM] Q002
[FS] [Token DUKPT Key Serial Number]
[FS] [Token DUKPT Key Info]
[FS] [Encrypted Session ID]
[FS] [Encrypted Qwantum Data Buffer]
[FS] [Device Serial Number]
[FS] [MAC DUKPT Key Info]
[FS] [MAC message length]
[FS] [MAC]
[EOM]
 
[SOM] Q003
[FS] [Message Code]
[FS] [Message]
[EOM]
```

## Qwantum Card Read/Qwantum Mode All Card Read

This is the message format for Qwantum cards, or for any card when Qwantum Mode is on.

### Table - Data Message Q001 Definition

<table data-header-hidden><thead><tr><th width="198.727294921875"></th><th width="88.09088134765625"></th><th width="83.0909423828125"></th><th width="84.72723388671875"></th><th></th></tr></thead><tbody><tr><td>Description</td><td>Prot</td><td>Type</td><td>Txt Len</td><td>Notes</td></tr><tr><td>Message ID = “Q001”</td><td>Clear</td><td>ASCII</td><td>4</td><td>Qwantum Card message</td></tr><tr><td>KSN (Token)</td><td>Clear</td><td>HEX</td><td>20/24</td><td>TDES or AES</td></tr><tr><td>DUKPT Key Info (Token)</td><td>Clear</td><td>HEX</td><td>16</td><td> </td></tr><tr><td>Qwantum Status</td><td>Clear</td><td>HEX</td><td>8</td><td>from ASIC</td></tr><tr><td>Qwantum Token</td><td>Encrypt</td><td>HEX</td><td>var</td><td><ul><li>Encrypted with Qwantum Token Key</li><li>Padded with zeros</li></ul></td></tr><tr><td>Session ID</td><td>Encrypt</td><td>HEX</td><td>16/32</td><td>Encrypted with MSR key. Session ID = RTC value</td></tr><tr><td>Qwantum Card ID</td><td>Clear</td><td>HEX</td><td>64</td><td>32-byte SHA256 hash of TK1 name, TK2 PAN and TK2 Expiration Date</td></tr><tr><td>Device Serial Number</td><td>Clear</td><td>ASCII</td><td>7</td><td>Indicates valid range of each hex digit – ‘0’ ~ ‘9’ (0x30 ~ 0x39), ‘A’ ~ ‘F’ (0x41 ~ 0x46)</td></tr><tr><td>DUKPT Key Info (MAC)</td><td>Clear</td><td>HEX</td><td>16</td><td>for Qwantum Token Key</td></tr><tr><td>Message Length</td><td>Clear</td><td>HEX</td><td>4</td><td>Includes all of message fields except for MAC (High byte first)</td></tr><tr><td>MAC</td><td>Clear</td><td>HEX</td><td>16/32</td><td><p>MAC variant of MSR encryption key is used to calculate MAC.</p><ul><li>CBC MAC if MSR DUKPT key is TDES</li><li>CMAC if MSR DUKPT key is AES</li></ul></td></tr></tbody></table>

## Quantum Buffer Output

This message is used when the device sends out encrypted data from the Secure Buffer.

### Table - Qwantum Buffer Output Q002 Data Message

<table data-header-hidden><thead><tr><th width="174.727294921875"></th><th width="85.3636474609375"></th><th width="61.3636474609375"></th><th width="76.36358642578125"></th><th></th></tr></thead><tbody><tr><td>Description</td><td>Prot</td><td>Type</td><td>Txt Len</td><td>Notes</td></tr><tr><td>Message ID = “Q002”</td><td>Clear</td><td>ASCII</td><td>4</td><td>Qwantum Buffer Message</td></tr><tr><td>KSN (Token)</td><td>Clear</td><td>HEX</td><td>20/24</td><td>TDES or AES</td></tr><tr><td>DUKPT Key Info (Token)</td><td>Clear</td><td>HEX</td><td>16</td><td> </td></tr><tr><td>Session ID</td><td>Encrypt</td><td>HEX</td><td>16/32</td><td>Encrypted with MSR key. Session ID = RTC value</td></tr><tr><td>Qwantum Buffer</td><td>Encrypt</td><td>HEX</td><td>1-2K</td><td><ul><li>Encrypted with Qwantum Token Key</li><li>Padded with pad length</li></ul></td></tr><tr><td>Device Serial Number</td><td>Clear</td><td>ASCII</td><td>7</td><td>Indicates valid range of each hex digit – ‘0’ ~ ‘9’ (0x30 ~ 0x39), ‘A’ ~ ‘F’ (0x41 ~ 0x46)</td></tr><tr><td>DUKPT Key Info (MAC)</td><td>Clear</td><td>HEX</td><td>16</td><td>for Qwantum Token Key</td></tr><tr><td>Message Length</td><td>Clear</td><td>HEX</td><td>4</td><td>Includes all of message fields except for MAC (High byte first)</td></tr><tr><td>MAC</td><td>Clear</td><td>HEX</td><td>16/32</td><td><p>MAC variant of MSR encryption key is used to calculate MAC.</p><ul><li>CBC MAC if MSR DUKPT key is TDES</li><li>CMAC if MSR DUKPT key is AES</li></ul></td></tr></tbody></table>

## Empty Qwantum Buffer Output

This message is used when the device sends out when Qwantum Secure Data is empty.

### Table - Qwantum Buffer Output Q003 Data Message

<table data-header-hidden><thead><tr><th width="148.727294921875"></th><th width="81.72723388671875"></th><th width="88.72723388671875"></th><th width="84.72723388671875"></th><th></th></tr></thead><tbody><tr><td>Description</td><td>Prot</td><td>Type</td><td>Txt Len</td><td>Notes</td></tr><tr><td>Message ID = “Q003”</td><td>Clear</td><td>ASCII</td><td>4</td><td>Qwantum Buffer Message</td></tr><tr><td>Message Code</td><td>Clear</td><td>ASCII</td><td>2</td><td>Text characters indicating message code</td></tr><tr><td>Message</td><td>Clear</td><td>ASCII</td><td>36</td><td>Message for empty buffer</td></tr></tbody></table>

#### Example:

```
Q003|01|No Data Stored. Nothing to Transmit.|
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.magtek.com/hardware/card-readers/magnetic-stripe-readers/idynamo-5-gen-iii/documentation/developers-manuals/programmers-manual-commands/data-format.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
