About Encryption And Decryption; How To Determine The Key; How To Decrypt Data - Magtek DynaFlex II Go Programmer's Manual

Secure card reader
Hide thumbs Also See for DynaFlex II Go:
Table of Contents

Advertisement

5 - Security
type of key is injected into the key slot that is being used by the operation being performed or the data
being passed.
When the device and host are using TDES keys, the Key Serial Number (KSN) is an 80-bit value. The
rightmost 21 bits are the current value of the encryption counter associated with that key. The leftmost 59
bits are the Initial KSN for that key, which is specified during key injection and is a combination of the
Key Set ID that identifies the Base Derivation Key (BDK) injected into the device during manufacture,
and the device's serial number (DSN); how those two values are combined into the 59 bit Initial KSN is
defined by a convention the customer defines when architecting the solution, with support from MagTek.
For example, one common scheme is to concatenate a 7 hex digit (28 bit) Key Set ID, a 7 hex digit (28
bit) Device Serial Number, and a 3 bit Initial Key Load Counter the injecting host increments each time
the same key is re-loaded into the device. In these cases, the key can be referenced by an 8-digit MagTek
part number ("key ID") consisting of the 7 hex digit Key Set ID plus a trailing "0."
5.3

About Encryption and Decryption

Some data exchanged between the device and the host is encrypted. This includes parts of the EMV
ARQC Type and the EMV Batch Data Type. To decrypt this data, the host must first determine what
key to use, then decrypt the data. The following sections explain each of those steps in detail.
5.4

How to Determine the Key

When the device and the host are using TDES DUKPT key and the device is encrypting data, the host
software must do the following to generate a key (the "derived key") to use for decryption:
1) Determine the value of the Initial Key loaded into the device. The lookup methods the host
software uses depend on the overall solution architecture, and are outside the scope of this document.
However, most solutions do this in one of two ways, both of which use the Initial Key Serial Number
that arrives with the encrypted data:
a) Look up the value of the Base Derivation Key using the Initial KSN portion of the current KSN
as an index value, then use TDES DUKPT algorithms to calculate the value of the Initial Key; or
b) Look up the value of the Initial Key directly, using the Initial KSN portion of the current KSN as
an index value.
2) Derive the current key. Apply TDES DUKPT algorithms to the Initial Key value and the encryption
counter portion of the KSN that arrives with the encrypted data.
3) Determine which variant of the current key the device used to encrypt. The variants are defined
in ANS X9.24-1:2009 Annex A, which programmers of host software must be familiar with. Which
variant the host should use depends on the type of data the host is decrypting. The encrypted portions
of EMV ARQC and EMV Batch Data both use the Data Encryption, Request or Both Ways variant.
4) Use the variant algorithm with the current key to calculate that variant.
5) Decrypt the data according to the steps in section 5.5 How to Decrypt Data.
5.5

How to Decrypt Data

For EMV ARQC and EMV Batch Data, the device begins by TDES encrypting the first 8 bytes of clear
text data. The 8-byte result of this encryption is placed in an encrypted data buffer. The process
continues using the TDES CBC (Cipher Block Chaining) method with the encrypted 8 bytes XORed with
the next 8 bytes of clear text. That result is placed in next 8 bytes of the encrypted data buffer, and the
device continues until all clear text bytes have been encrypted. If the final block of clear text contains
fewer than 8 bytes, the device pads the end of the block to make 8 bytes. After the final clear text block is
DynaFlex II Go| Secure Card Reader | Programmer's Manual (COMMANDS)
Page 91 of 301 (D998200597-102)

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the DynaFlex II Go and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents