UKPT Encryption

Introduction

UKPT (Unique Key Per Transaction) is a key derivation method for host-to-host integrations in which a new cryptographic key is created for each transaction.

A master key is securely exchanged between the merchant/PSP host and the payment gateway during the key setup process. For each transaction, both systems derive a transaction-specific key using the configured UKPT algorithm and transaction-specific derivation data.

UKPT can be used to protect:

  • card data, including SRED-protected card data;
  • PIN blocks;
  • message authentication using a MAC.

Roles and key derivation

UKPT distinguishes between the roles of NSP (Network Service Provider) and Acquirer. The relevance of these roles depends on whether TDES or AES is used.

For TDES, both communication parties are treated as NSPs. Therefore, no separate Acquirer-to-NSP key derivation takes place.

For AES, the roles are explicitly separated:

PartyRole
Message senderNSP
Message recipientAcquirer

The party sending the encrypted message is the NSP, while the gateway, as the receiving party, is the Acquirer.

AES therefore uses an Acquirer key, an NSP key, and an NSP ID. The NSP key is derived from the Acquirer key using the NSP ID:

NSP key = KDF(Acquirer key, NSP ID)

where KDF means Key Derivation Function.

This establishes an NSP-specific key hierarchy:

Acquirer key → + NSP ID → NSP key → UKPT key derivation

Supported UKPT algorithms

Two UKPT key derivation algorithms are supported:

derivationAlgoDescription
UKPTTDESTDES-based ZKA key derivation
UKPTAESAES-256-based ZKA key derivation

Both algorithms derive a new key for each transaction.

The UKPT variant used by your integration must correspond to the master key and cryptographic configuration established during onboarding.

How UKPT works

UKPT uses two inputs to identify and derive the transaction key:

  • Key ID identifies the master key.
  • RNDI provides the transaction-specific input to the key derivation process.

The transaction key is derived independently by both the merchant/PSP host and the payment gateway.

Conceptually:

Merchant Host                         Payment Gateway
      |                                      |
      |     Master key established           |
      |<------------------------------------>|
      |                                      |
      |              RNDI                    |
      |                |                     |
      |                v                     |
      |      Master Key + RNDI               |
      |                |                     |
      |                v                     |
      |     UKPT Key Derivation              |
      |                |                     |
      |                v                     |
      |      Transaction Key                 |
      |                                      |
      |                                      | Master Key + RNDI
      |                                      |        |
      |                                      |        v
      |                                      | UKPT Key Derivation
      |                                      |        |
      |                                      |        v
      |                                      | Transaction Key
      |                                      |
      |   Protected transaction data         |
      |   + Key ID                           |
      |   + RNDI                             |
      |------------------------------------->|
      |                                      |

Because both parties possess the applicable master key and receive the same RNDI, they can independently derive the same transaction-specific key.

The master key itself is never included in the transaction request.


Key Index

For UKPT, the key.index identifies both the master key and the transaction-specific derivation information.

The value has the following format:

<key-id>,<RNDI>

Where:

ComponentEncodingDescription
key-idDecimal stringIdentifies the master key
RNDIBase64-encoded binaryTransaction-specific input used for UKPT key derivation

Example:

123456,<base64-encoded-RNDI>

The two components are separated by a comma:

key-id,RNDI

The RNDI must correspond to the transaction key used to protect the data contained in the request.


Card Data Encryption

UKPT can be used to protect card data transmitted in:

paymentMethod.paymentCardProtected

The clear-text representation that would otherwise be provided in:

paymentMethod.paymentCard

is encrypted and transported as encryptedData.

The protected structure contains the encrypted data together with information describing how the transaction key and encrypted data must be processed.

Conceptual example:

{
  "paymentMethod": {
    "paymentCardProtected": {
      "key": {
        "derivationAlgo": "UKPTAES",
        "encryptionAlgo": "AES256CBC",
        "index": "<key-id>,<RNDI>"
      },
      "encryptedData": "<base64-encrypted-data>"
    }
  }
}

The example is illustrative. The actual encryption and derivation algorithms must match the cryptographic configuration established for your integration.

Data encryption algorithms

The following data encryption algorithms are available:

encryptionAlgoCipherModeBlock size
DES112CBCTriple DES, double-length keyCBC8 bytes
AES256CBCAES-256CBC16 bytes

The initialization vector (IV) for CBC encryption is a null vector:

00 00 ... 00

with a length corresponding to the cipher block size.

Before encryption, the data is padded by appending:

0x80

followed by:

0x00

bytes until the total data length is a multiple of the applicable cipher block size.

The resulting encrypted binary data is Base64-encoded before being provided as encryptedData.


PIN Block Encryption

UKPT can also be used to protect an online PIN block.

PIN information is provided in:

terminalRequestData.pin

The structure contains:

  • the UKPT key derivation algorithm;
  • the PIN encryption algorithm;
  • the UKPT key index;
  • the encrypted PIN block;
  • the PIN block format.

Conceptual structure:

{
  "terminalRequestData": {
    "pin": {
      "key": {
        "derivationAlgo": "UKPTTDES",
        "encryptionAlgo": "TDES_ECB",
        "index": "<key-id>,<RNDI>"
      },
      "value": "<base64-encrypted-pin-block>",
      "formatCode": "ISO0"
    }
  }
}

The encrypted PIN block in value is Base64-encoded.

Supported PIN block formats

The PIN block format determines which encryption algorithms can be used.

formatCodeAllowed encryption algorithmsDescription
ISO0DES112ECB, TDES_ECBISO-0 PIN block. The PAN is used to construct the PIN block.
ISO1DES112ECB, TDES_ECBISO-1 PIN block. The PAN is not used to construct the PIN block.
ISO4AES256ECBISO-4 PIN block. The PAN is used to construct the PIN block.

TDES example

A TDES-based UKPT configuration can therefore use:

{
  "key": {
    "derivationAlgo": "UKPTTDES",
    "encryptionAlgo": "TDES_ECB",
    "index": "<key-id>,<RNDI>"
  },
  "value": "<base64-encrypted-pin-block>",
  "formatCode": "ISO0"
}

AES example

An AES-based UKPT configuration can use an AES PIN block configuration such as:

{
  "key": {
    "derivationAlgo": "UKPTAES",
    "encryptionAlgo": "AES256ECB",
    "index": "<key-id>,<RNDI>"
  },
  "value": "<base64-encrypted-pin-block>",
  "formatCode": "ISO4"
}

The exact combination of key derivation, encryption algorithm, and PIN block format must match the configuration established for your integration.


Message Authentication

UKPT can also be used to derive transaction-specific keys for message authentication.

The MAC protects the complete HTTP request body.

HTTP headers are not included in the MAC calculation.

The request body must consist of the JSON message encoded as UTF-8.

MAC length

The MAC transmitted through the REST API is:

8 bytes

or:

16 hexadecimal digits

If the underlying MAC algorithm produces a longer result, the first 8 bytes are used.

The resulting 8-byte MAC is then Base64-encoded.

MAC algorithms

Depending on the cryptographic key type, the following MAC algorithms are available:

MAC algorithmDescriptionKey type
RetailSHA256MACRetail-CBC-MAC with SHA-256 (Secure Hash standard) -(ASN.1 Object Identifier: id-retail-cbc-mac-sha-256).TDES
SHA256CMACwithAES128CMAC (Cipher based Message Authentication Code) defined by the National Institute of Standards and Technology (NIST 800-38B -May 2005), using the block cipher Advanced
Encryption Standard with a 128 bits cryptographic key, approved by the Federal Information Processing Standards (FIPS 197 -November 6, 2001 -Advanced Encryption Standard). The CMAC algorithm is computed on the SHA-256 digest of the message.
AES-128
CMACwithAES128CMAC directly applied to the data. Same as SHA256CMACwithAES128, but no SHA-256 calculation.AES-128
SHA256CMACwithAES256CMAC (Cipher based Message Authentication Code) defined by the National Institute of Standards and Technology (NIST 800-38B -May 2005), using the block cipher Advanced
Encryption Standard with a 256 bits cryptographic key, approved by the Federal Information Processing Standards (FIPS 197 -November 6, 2001 -Advanced Encryption Standard). The CMAC algorithm is computed on the SHA-256 digest of the message.
AES-256
CMACwithAES256 CMAC directly applied to the data. Same as SHA256CMACwithAES256, but no SHA-256 calculationAES-256

SHA256CMACwithAES128 and SHA256CMACwithAES256 calculate the CMAC over the SHA-256 digest of the message.

CMACwithAES128 and CMACwithAES256 calculate the CMAC directly over the message data without first calculating a SHA-256 digest.

MAC HTTP header

The MAC is provided in the HTTP header:

message-authentication-value

Conceptually, the header contains:

<base64-MAC>;<derivation-algo>;<mac-algo>;<key-id,RNDI>;<key-name>;<key-version>

where

ParameterDescription
base-64(MAC)The calculated MAC (8 bytes) encoded as base64 string.
derivation-algoUse 'UKPTTDES' or 'UKPTAES'
mac-algoOne of:
"RetailSHA256MAC", "SHA256CMACwithAES128" or "CMACwithAES128"
ksn"key-id,RNDI"

- 'key-id' identifies the UKPT master key;
- 'RNDI' is the Base64-encoded binary value used for transaction key derivation.
key-nameCurrently only for information purpose. This is the name of the key. In future, it may be used
to find the key.
key-versionCurrently only for information purpose. This is the name of the key. In future, it may be used
to find the key.


UKPT Processing Summary

A typical UKPT transaction follows this process:

  1. A UKPT master key is securely established between the merchant/PSP host and the payment gateway.

  2. The merchant host creates the transaction-specific RNDI.

  3. The merchant host derives a transaction key using the configured UKPT algorithm.

  4. The derived key is used to protect the required transaction data.

  5. The request contains the protected data and the UKPT key index:

    ,

  6. The payment gateway identifies the master key from key-id.

  7. The payment gateway derives the same transaction-specific key from the master key and RNDI.

  8. The derived key is used to process the protected data.

Depending on your integration, UKPT-derived keys can be used for:

UKPT
  |
  +-- Card/SRED data encryption
  |
  +-- PIN block encryption
  |
  +-- Message authentication (MAC)

Each transaction uses a newly derived key.


Integration Requirements

Before using UKPT, ensure that:

  • a UKPT master key has been securely established;
  • you have received the corresponding Key ID;
  • either UKPTTDES or UKPTAES has been configured for your integration;
  • your system can generate and encode the required RNDI;
  • the index is constructed as key-id,RNDI;
  • card data uses an encryption algorithm compatible with your UKPT configuration;
  • PIN blocks use a supported PIN block format and compatible encryption algorithm;
  • the complete JSON body is used when calculating a request MAC;
  • MAC values sent through the REST API are truncated to 8 bytes and Base64-encoded;
  • cryptographic keys and clear-text PINs are never included in API requests or application logs.

Did this page help you?
Want a quick overview?