Ambimat GroupAmbimatAmbiSecureSIMAuthAmbiAutomationEngineering BlogAhmedabad · India · Est. 1981
Smart card utility

SCP03 Helper

An educational companion to the SCP03 walkthrough: derive the S-ENC, S-MAC, and S-RMAC session keys plus the host and card cryptograms from static keys and challenges, using AES-CMAC and the SP 800-108 KDF entirely in your browser.

Client-sideAES-CMACGP Amendment DTest keys only

Input

SAMPLE-FORMAT values only. Never paste a real production key into a webpage.

Derived values

Enter static keys and challenges, or load the sample-format values.
All AES-CMAC and key derivation runs locally in your browser via Web Crypto. Nothing is uploaded. This is a teaching aid — use throwaway test keys only.

What this tool does

SCP03 is GlobalPlatform's AES-based Secure Channel Protocol: the handshake a host (a card-management tool or backend) and a secure element run to agree on fresh session keys before exchanging confidential, integrity-protected APDUs. This helper reproduces the cryptographic core of that handshake so you can follow the maths with concrete numbers. Given the two static base keys and the two challenges, it computes the three session keys and both cryptograms exactly as GlobalPlatform Amendment D specifies.

Under the hood, every value is produced by a NIST SP 800-108 counter-mode key-derivation function whose pseudo-random function is AES-CMAC. Because the Web Crypto API ships AES but no CMAC, the tool implements RFC 4493 itself — generating the K1/K2 subkeys and the MAC on top of crypto.subtle AES-CBC with a zero IV. The CMAC implementation reproduces the published RFC 4493 AES-128 test vectors, so the building block underneath the KDF is verifiable rather than hand-waved.

When to use it

Reach for this when you are learning or debugging an SCP03 flow: checking why a card rejected your EXTERNAL AUTHENTICATE, confirming that your own KDF produces the same session keys as a reference, or teaching the difference between S-ENC, S-MAC, and S-RMAC. It pairs naturally with the step-by-step SCP03 walkthrough, which narrates the protocol exchange, while this page gives you the numbers. If you only need the MAC-length or padding rules, the CMAC length reference is lighter weight.

Inputs and outputs

The four inputs are all hexadecimal. K-ENC and K-MAC are the static base keys provisioned on the card; each is a 16-, 24-, or 32-byte AES key (AES-128/192/256) and both must be the same length. The host challenge and card challenge are each exactly 8 bytes — the host generates one, the card returns the other, and their concatenation (host || card) forms the KDF context.

Session keys

S-ENC (constant 0x04), S-MAC (0x06), and S-RMAC (0x07), each derived to the base-key length.

Cryptograms

Card cryptogram (0x00) and host cryptogram (0x01), each 8 bytes, derived under the freshly computed S-MAC.

Context

The 16-byte host || card challenge concatenation that ties every derivation to this one session.

Common mistakes

Related tools

SCP03 walkthrough

Step-by-step narration of the SCP03 protocol exchange and APDUs.

Open SCP03 walkthrough →

CMAC length

Rules for AES-CMAC tag and padding lengths in secure messaging.

Open CMAC length →

Key diversification

How per-card keys are derived from a master key in a SAM.

Open key diversification →