Chapter 21: Secure Elements and Smart Cards¶
Note: This chapter covers secure elements (SEs) and smart cards: ISO 7816, ISO 14443, JavaCard, GlobalPlatform, SCP03, EMV, PIV, ePassport (ICAO 9303), MIFARE Classic attacks, NFC security, and hardware including NXP JavaCard, STMicro ST31, Infineon SLE 97.
21.1 Secure Element Definition and Form Factors¶
A secure element (SE) is a tamper-resistant hardware platform with secure storage and cryptographic execution, isolated from the host processor. Key form factors:
-
ISO 7816 contact card (ID-1): Standard credit card size (85.6 x 54 mm), 6-8 gold contacts.
-
ISO 7816 ID-000 (SIM): Mini SIM plug (25 x 15 mm), same electrical interface.
-
ISO 14443 contactless: 13.56 MHz NFC interface, Type A or B modulation.
-
Embedded SE (eSE): Discrete chip soldered to PCB, I2C/SPI interface. NXP SE050.
-
iSIM/eSIM: SE IP block integrated into application processor SoC. GSMA SGP.22.
21.1.1 Smart Card Architecture¶
A smart card contains: CPU (8-bit 8051 or 32-bit ARM), ROM (OS code, 128 KB), EEPROM/Flash (applets + data, 64–640 KB), RAM (working memory, 4–32 KB), crypto coprocessor (DES, AES, RSA, ECC hardware engines), and I/O controller implementing ISO 7816 T=0 or T=1 protocol.
21.2 ISO 7816 Smart Card Standard¶
21.2.1 Physical Layer and ATR¶
ISO 7816-3 defines 8 contacts (C1–C8): C1=VCC (1.8/3/5V), C2=RST, C3=CLK (1–5 MHz), C4=RFU, C5=GND, C6=VPP (programming voltage, mostly unused), C7=I/O (half-duplex serial), C8=RFU. The Answer To Reset (ATR) is sent by the card after reset, conveying: supported protocols (T=0, T=1), historical bytes, and interface character bytes.
21.2.2 APDU Structure¶
Application Protocol Data Units (APDUs) are the communication language of smart cards.
| Field | Command APDU | Response APDU | Size (bytes) |
|---|---|---|---|
| CLA | Class byte | N/A | 1 |
| INS | Instruction byte | N/A | 1 |
| P1 P2 | Parameters | N/A | 2 |
| Lc | Data length | N/A | 0-3 |
| DATA | Command data | Response data | 0-255 |
| Le | Expected response length | N/A | 0-3 |
| SW1 SW2 | N/A | Status word | 2 |
/* Java: construct APDU to SELECT application by AID */
byte[] selectCmd = {
(byte)0x00, (byte)0xA4, (byte)0x04, (byte)0x00, /* CLA INS P1 P2 */
(byte)0x07, /* Lc: AID length */
(byte)0xA0,0x00,0x00,0x00,0x03,0x00,0x00, /* AID */
(byte)0x00 /* Le */
};
/* Python: pyscard (PC/SC) */
from smartcard.System import readers
r = readers()[0]
conn = r.createConnection()
conn.connect()
data, sw1, sw2 = conn.transmit(list(selectCmd))
print(f"SW: {sw1:02X}{sw2:02X}") /* 9000 = success */
21.3 JavaCard Platform¶
JavaCard is a subset of Java that executes on smart card CPUs. The JavaCard Virtual Machine (JCVM) provides bytecode interpretation and garbage collection. The JavaCard Runtime Environment (JCRE) manages applet lifecycle and inter-applet communication.
21.3.1 JavaCard Applet Lifecycle¶
-
install(): Called when applet is installed on the card. Create persistent objects.
-
select(): Called when host selects this applet via SELECT APDU. Initialize session state.
-
process(APDU): Called for each subsequent APDU. Main command handler.
-
deselect(): Called when another applet is selected. Clean up session state.
-
uninstall(): Called when applet is deleted. Remove all persistent objects.
/* JavaCard ECDH Key Agreement Applet */
import javacard.framework.*;
import javacard.security.*;
import javacardx.crypto.*;
public class ECDHApplet extends Applet {
private KeyPair kp;
private KeyAgreement ecdh;
private byte[] sharedSecret;
protected ECDHApplet() {
kp = new KeyPair(KeyPair.ALG_EC_FP, KeyBuilder.LENGTH_EC_FP_256);
kp.genKeyPair(); /* generate on-card ECC P-256 key */
ecdh = KeyAgreement.getInstance(KeyAgreement.ALG_EC_SVDP_DH_PLAIN, false);
sharedSecret = JCSystem.makeTransientByteArray((short)32, JCSystem.CLEAR_ON_DESELECT);
}
public void process(APDU apdu) {
byte[] buf = apdu.getBuffer();
if (apdu.isISOInterswitch()) return;
switch(buf[ISO7816.OFFSET_INS]) {
case (byte)0x10: /* GET PUBLIC KEY */
ECPublicKey pub = (ECPublicKey)kp.getPublic();
short len = pub.getW(buf, (short)0);
apdu.setOutgoingAndSend((short)0, len);
break;
case (byte)0x20: /* DO ECDH: Lc bytes = peer public key */
short lc = apdu.setIncomingAndReceive();
ecdh.init(kp.getPrivate());
ecdh.generateSecret(buf, ISO7816.OFFSET_CDATA, lc,
sharedSecret, (short)0);
break;
}
}
}
21.4 GlobalPlatform Security¶
GlobalPlatform (GP) defines the card management infrastructure for Java Card platforms, including Security Domains (ISD, SSD, DAP), Secure Channel Protocols (SCP02/SCP03), and Delegated Management (DAP).
21.4.1 GlobalPlatform Security Domain Hierarchy¶
21.4.2 SCP03: Secure Channel Protocol 3¶
SCP03 replaces SCP02 (3DES-based) with AES-128-based session key derivation and authenticated encryption. Three session keys derived from static base keys:
| Key | Static Base | Derivation | Purpose |
|---|---|---|---|
| S-ENC | Enc Key | AES-CMAC(Enc-Key, data) | Command/response encryption |
| S-MAC | MAC Key | AES-CMAC(MAC-Key, data) | Command MAC (C-MAC) |
| S-RMAC | RMAC Key | AES-CMAC(RMAC-Key, data) | Response MAC (R-MAC) |
# SCP03 session key derivation (Python)
from Crypto.Cipher import AES
from Crypto.Hash import CMAC
def scp03_derive(base_key, derivation_data, context):
"""Derive SCP03 session key using AES-CMAC derivation"""
# Derivation data: 12 bytes label + derivation constant + 2 bytes len
data = derivation_data + context
c = CMAC.new(base_key, ciphermod=AES)
c.update(data)
return c.digest() # 16-byte session key
# Host challenge: 8 bytes random
# Card challenge: 8 bytes from card
host_challenge = os.urandom(8)
# After mutual authentication:
S_ENC = scp03_derive(enc_base_key, b"\x04"+host_challenge+card_challenge, b"\x00\xc2\x80")
S_MAC = scp03_derive(mac_base_key, b"\x06"+host_challenge+card_challenge, b"\x00\xc2\x80")
S_RMAC = scp03_derive(rmac_base_key, b"\a"+host_challenge+card_challenge, b"\x00\xc2\x80")
21.5 EMV (Europay/Mastercard/Visa)¶
EMV 4.3 specification defines the global standard for chip-based payment cards.
| Method | Acronym | How it works | Online/Offline |
|---|---|---|---|
| Static Data Authentication | SDA | Card signs static data with issuer key | Offline only |
| Dynamic Data Authentication | DDA | Card signs terminal challenge dynamically | Offline only |
| Combined DDA/App Crypto | CDA | DDA combined with application cryptogram | Offline |
| Offline PIN | – | PIN verified by card chip, not network | Offline |
21.5.1 EMV DDA Verification¶
DDA (Dynamic Data Authentication) uses the card’s unique RSA private key to sign a challenge from the terminal. The terminal verifies with the card’s public key, certified by the issuer, certified by the scheme (Visa/Mastercard) certification chain.
# EMV DDA verification steps:
# 1. GET PROCESSING OPTIONS: card returns AIP+AFL
# 2. READ RECORD: card returns signed static data (SSD)
# 3. INTERNAL AUTHENTICATE: terminal sends 8-byte challenge
# Card returns SDAD = RSA_sign(card_priv, hash(challenge||data))
# 4. Terminal:
# a) Verify issuer cert chain (scheme CA -> issuer -> card pubkey)
# b) Verify SDAD using card public key
# c) Check SDAD contains terminal challenge
# Successful DDA proves card is genuine (not cloned)
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives import hashes
# Verify SDAD (RSA-2048 PKCS#1 v1.5 signature)
card_pubkey.verify(
sdad_bytes, challenge_and_data,
padding.PKCS1v15(), hashes.SHA1() # EMV uses SHA-1
)
21.6 PIV – Personal Identity Verification¶
PIV (FIPS 201-3) mandates smart card credentials for US federal employees and contractors. The card holds X.509 certificates in four key slots plus a retired-key store.
| Slot | Alias | Key Algorithm | Purpose |
|---|---|---|---|
| 9A | PIV Authentication | RSA-2048 / ECC P-384 | Authenticate card and cardholder |
| 9C | Digital Signature | RSA-2048 / ECC P-384 | Sign documents and emails |
| 9D | Key Management | RSA-2048 / ECC P-256 | Decrypt and key establishment |
| 9E | Card Authentication | ECC P-256 | Contactless authentication, no PIN required |
| 82-95 | Retired Key 1-20 | RSA-2048 / ECC P-384 | Historical key management records |
# Python PIV APDU: authenticate with slot 9A (ECC P-384)
# GENERAL AUTHENTICATE command
cla, ins = 0x00, 0x87
p1, p2 = 0x14, 0x9A # alg=ECC-P384, slot=9A
# Build Dynamic Authentication Template
dat = bytes([0x7C, len_challenge+4, 0x82, 0x00, 0x81, len_challenge]) + challenge
apdu = bytes([cla, ins, p1, p2, len(dat)]) + dat + bytes([0x00])
resp = card.transmit(apdu)
# Response: 7C tag contains 0x82 (response) with signature bytes
The CHUID (Card Holder Unique Identifier) contains a FASC-N (Federal Agency Smart Credential Number) encoded in BCD, a UUID, an expiration date, and an asymmetric signature over those fields for authenticity checking by physical access readers.
21.7 ePassport – ICAO Doc 9303¶
ICAO Doc 9303 defines the Machine Readable Travel Document (MRTD) standard used in over 150 countries. The chip stores DG1 (MRZ data), DG2 (facial image), DG7 (signature), DG14 (Active Authentication public key), and DG15 (AA public key for EAC).
| Protocol | Standard | Protection | Key Length |
|---|---|---|---|
| BAC | ICAO 9303 Part 11 | Basic Access Control (3DES) | 56-bit effective |
| PACE | ICAO 9303 Part 11 | Password Authn. Connection Estab. | AES-128/256 |
| AA | ICAO 9303 Part 11 | Active Authentication (RSA/ECDSA) | 1024-4096 bits |
| EAC v1 | BSI TR-03110 | Chip+Terminal Auth (EU) | AES-128 + ECC P-256 |
| EAC v2 | BSI TR-03110 | PACE + CA + TA | AES-128/256 + ECC |
| SAC | ICAO 9303 Part 11 | Supplemental AC (replaces BAC) | AES-128/256 |
# PACE protocol simplified flow (ICAO 9303 Part 11 Section 4.4):
# Step 1: Get Nonce -- encrypted with Kenc derived from MRZ
ENC_NONCE = card.sendAPDU(0x00,0x86,0x00,0x00, [0x7C,0x02,0x80,0x00])
# Step 2: Map Nonce -- ECDH ephemeral key exchange
# Step 3: Perform Key Agreement -- second ECDH
# Step 4: Mutual Authentication -- compute/verify auth tokens
# Result: session keys KSenc, KSmac for Secure Messaging
21.7.1 Logical Data Structure (LDS)¶
The LDS organises data groups DG1-DG16 plus SOD (Security Object Document). SOD contains hash values of all DGs signed by the issuing state DS (Document Signer) certificate, which chains to the CSCA (Country Signing CA) certificate.
Warning: Clone-resistant only with AA/EAC: BAC-only passports can be cloned because the chip does not prove its identity; AA adds a device-bound RSA/ECDSA key.
21.8 MIFARE Classic Attacks¶
MIFARE Classic (NXP) uses the proprietary CRYPTO1 stream cipher. Karsten Nohl reverse-engineered it in 2008; Garcia et al. published the full specification in 2009. A standard 1K card has 16 sectors x 4 blocks; each sector protected by 48-bit Key A and 48-bit Key B stored in Sector Trailer (block 3/7/11/...). A 6-byte UID is transmitted unencrypted; some cards use random 4-byte UIDs (anti-cloning).
21.8.1 CRYPTO1 Weaknesses¶
CRYPTO1 has a 48-bit LFSR state. Three published attacks break it:
-
Nested Authentication: knowing one sector key, recover adjacent sector keys using the nonce correlation. MFOC (Mifare OFfline Cracker) tool automates this.
-
Darkside Attack: obtain key from the tag error response when the random nonce leaks keystream bits through parity. Tools: mfkey32, Proxmark3 darkside.
-
Hardnested: works against cards with random UIDs; exploits LFSR linearity to recover keys with 50k authentication attempts.
# MFOC nested authentication -- simplified key recovery loop:
# Requires: one known key for any sector
# 1. Authenticate sector 0 with known key -> get encrypted nonce nt1
# 2. Predict nt2 (timing-correlated): brute-force 65536 candidates
# 3. For each candidate: solve CRYPTO1 state, derive target sector key
# Tool command line:
# mfoc -O dump.mfd
# Proxmark3 hf mf nested 1 0 A FFFFFFFFFFFF d
Warning: MIFARE Classic must not be used for physical access control: the attack tool Proxmark3 (open hardware) can clone most MIFARE Classic cards in under 20 seconds.
Tip: MIFARE DESFire EV3 uses AES-128 with mutual authentication (ISO 7816-4 / ISO 14443-4), transaction MAC, and proximity check (ISO 14443-3 timing). It is not vulnerable to CRYPTO1 attacks.
21.9 NFC Security¶
NFC (ISO 14443, ISO 15693, ISO 18092) operates at 13.56 MHz with typical read range 3-5 cm (ISO 14443-A) to 1 m (ISO 15693). Security threats include:
-
Eavesdropping: passive attacker captures reader-to-card RF field. Range up to 1 m with a directional antenna.
-
Relay Attack: NFC proxy (NFCGate, Proxmark3 relay) forwards commands between victim card and distant reader. Defeated by distance bounding (ISO 14443-3 frame timing <1 ms RTT = 22 cm).
-
Power Analysis (SPA/DPA): measuring power envelope during AES key schedule leaks key bytes. NXP P60 includes built-in SPA/DPA countermeasures (randomised scheduling, dual-rail logic).
-
Fault Injection: voltage/clock glitching or laser fault injection can skip PIN verification branches. CC EAL5+ evaluation requires resistance to fault attacks.
| Protocol | Frequency | Range | Authentication | Encryption |
|---|---|---|---|---|
| ISO 14443-A/B | 13.56 MHz | <10 cm | Challenge-Response | AES-128/TDES |
| ISO 15693 | 13.56 MHz | <1 m | None (basic) | None |
| ISO 18092 (NFCIP-1) | 13.56 MHz | <20 cm | Mutual (NFC-DEP) | AES-128 |
| FeliCa (JIS 6319-4) | 13.56 MHz | <10 cm | Mutual (SESN) | AES-128 |
| MIFARE DESFire EV3 | 13.56 MHz | <10 cm | Mutual ISO 7816 | AES-128+MAC |
21.10 Secure Element Hardware¶
21.10.1 NXP P60D080PVE¶
The NXP P60 family (SmartMX3) is a JavaCard 3.0.5 / GlobalPlatform 2.3.1 secure element with CC EAL 6+ (EN 419211) certification. The P60D080PVE variant integrates:
-
80 KB user EEPROM (expandable to 150 KB with extended memory model)
-
16 KB RAM + 640 KB ROM (JCRE + OS)
-
RSA-4096, ECC P-256/P-384/P-521, Ed25519, AES-256, DES/TDES, SHA-512 hardware accelerators
-
ISO 14443-A/B NFC interface at 848 kbps + ISO 7816 contact interface
-
Active shield mesh, voltage/frequency monitors, light sensor, temperature sensor
-
40 nm NXP process node; 25 mm2 die area
21.10.2 STMicroelectronics ST31G480¶
The ST31G480 (ST33G1M2 family) targets eGovernment/ePassport applications:
-
480 KB EEPROM, 32 KB RAM, 1.5 MB ROM; JavaCard 3.0.4 + GP 2.2.1
-
Hardware AES-128/256, RSA-4096, ECC, SHA-256/384/512
-
SWP (Single Wire Protocol) interface for UICC/SIM applications
-
CC EAL 5+ certified; 28 nm CMOS process; operating at 1.2 V core / 3 V I/O
21.10.3 Infineon SLE 97144¶
SLE 97 integrates a 16/32-bit security controller (Infineon SLE 9670) with 144 KB NVM:
-
Contact + contactless (ISO 14443-A/B, ISO 15693) dual interface
-
Public Key Unit (PKU): RSA-4096 in 300 ms, ECC-256 in 200 ms at 10 MHz
-
CC EAL 6+ with AVA_VAN.5 (vulnerability analysis); qualified for banking + ePassport
-
40 nm Infineon CMOS; I-block protocol for T=1 with EDC and anti-tearing support
21.10.4 NXP SE050¶
SE050 is a plug-and-play IoT secure element in 2.5 x 2.5 mm WLCSP package:
-
ECC P-256/P-384/P-521/Ed25519, RSA-2048/4096, AES-256, HMAC-SHA256
-
I2C interface (400 kHz / 3.4 MHz); 50 KB persistent memory
-
Arm M0+ core, CC EAL 6+; Python library: se05x (NXP EdgeLock)
-
Used in: Google Titan, NXP LPC55S69 dev boards, Raspberry Pi security hats
21.11 Smart Card Architecture TikZ Diagram¶
21.12 FPGA Smart Card Emulation¶
FPGA platforms enable protocol-level smart card emulation for research and testing.
21.12.1 Papilio Pro (Xilinx Spartan-6 LX9)¶
The Papilio Pro board hosts the ZPUino soft-processor with a BitBang ISO 7816 T=0/T=1 peripheral implemented in 400 LUTs. Combined with Chameleon Mini firmware (Atmel ATmega1284), researchers built a full MIFARE Classic emulator.
21.12.2 Proxmark3 RDV4¶
Proxmark3 uses Xilinx Spartan-6 LX45 FPGA + ARM Cortex-M3 (AT91SAM7S256) for simultaneous reader and card emulation (NFC ISO 14443-A/B, ISO 15693, FeliCa).
| Design | Device | LUTs | FFs | BRAMs | Max MHz |
|---|---|---|---|---|---|
| ISO 7816 T=0/T=1 controller | Spartan-6 LX9 | 412 | 310 | 2 | 120 |
| AES-128 (loop) | Spartan-6 LX9 | 856 | 512 | 0 | 100 |
| AES-128 (unrolled) | Artix-7 35T | 3,200 | 2,048 | 0 | 250 |
| CRYPTO1 (MIFARE Classic) | Spartan-6 LX9 | 210 | 180 | 0 | 200 |
| ECC P-256 (serial) | Zynq-7020 | 12,400 | 9,800 | 4 | 100 |
| RSA-2048 (Montgomery) | Zynq-7020 | 28,000 | 16,000 | 8 | 80 |
| Full SE emulator | Zynq-7020 | 45,000 | 32,000 | 16 | 100 |
21.13 ASIC Secure Element Implementations¶
| Vendor/Part | Process | NVM | RAM | ECC P-256 | RSA-2048 | Power | CC Level |
|---|---|---|---|---|---|---|---|
| NXP SmartMX3 P60 | 40 nm NXP | 80 KB | 16 KB | <50 ms | <300 ms | 1.2 mW active | EAL6+ |
| STMicro ST33G480 | 28 nm ST | 480 KB | 32 KB | <40 ms | <200 ms | 0.8 mW active | EAL5+ |
| Infineon SLE 97144 | 40 nm IFX | 144 KB | 8 KB | <60 ms | <300 ms | 1.5 mW active | EAL6+ |
| Samsung S3FV9RR | 28 nm SEC | 256 KB | 40 KB | <35 ms | <180 ms | 0.9 mW active | EAL5+ |
| NXP SE050 | 40 nm NXP | 50 KB | 4 KB | <50 ms | N/A | 0.6 mW active | EAL6+ |
| Microchip ATECC608B | TSMC 180 nm | 10 KB | 256 B | <60 ms | N/A | 0.15 mW active | N/A |
21.14 All Solutions Comparison¶
| Solution | Type | Standard | Use Case | Open Source |
|---|---|---|---|---|
| NXP P60 (SmartMX3) | Hard SE | JavaCard/GP/EMV | Banking, ePassport, ID | No (SDK only) |
| Infineon SLE 97 | Hard SE | JavaCard/GP/EMV | ePassport, Banking | No |
| STMicro ST31G480 | Hard SE | JavaCard/GP | UICC/SIM, eGov | No |
| NXP SE050 | IoT Hard SE | GP SCP03 | IoT device identity | Partial (TF-M) |
| Microchip ATECC608B | Crypto coprocessor | PKCS#11 | IoT keys, WiFi devices | No (lib only) |
| GlobalPlatform TEE | Software SE | GP TEE 1.0 | Mobile DRM, keys | No (spec only) |
| OP-TEE | Software TEE | GP TEE 1.0 | Linux+TrustZone-A | Yes (BSD-2) |
| JavaCard RI | Soft JavaCard | JavaCard 3.0.5 | Development/testing | Yes (GPL v2) |
| jCardSim | JavaCard sim | JavaCard 3.0.5 | Unit testing applets | Yes (Apache 2) |
| Proxmark3 | NFC research hw | ISO 14443/15693 | SE research, pentesting | Yes (GPL v3) |
| Chameleon Mini | NFC emulator hw | ISO 14443 | Field research | Yes (MIT) |
| MFOC | Attack tool | CRYPTO1 | MIFARE Classic audit | Yes (GPL v2) |
Solved Problem: Constructing an ISO 7816 SELECT + READ BINARY APDU Sequence
A Java Card applet stores a 16-byte secret in EF (Elementary File) 0x0001. An off-card host must (1) SELECT the applet by AID=A0000000030000, (2) SELECT EF 0x0001, then (3) READ BINARY the 16 bytes. Write each APDU in hex and state the expected SW1-SW2 response. Solution: Step 1 – SELECT by AID (CLA=00, INS=A4, P1=04, P2=00): AID = A0 00 00 00 03 00 00 (7 bytes), Lc=07, Le=00. APDU: 00 A4 04 00 07 A0 00 00 00 03 00 00 00 Expected response: 90 00 (success) with optional FCI template. Step 2 – SELECT EF by ID (P1=00, P2=00 for first occ.): File ID = 00 01 (2 bytes), Lc=02. APDU: 00 A4 00 00 02 00 01 Expected response: 90 00. Step 3 – READ BINARY (INS=B0, P1=0x00, P2=0x00 = offset 0): Le = 0x10 (16 bytes requested). APDU: 00 B0 00 00 10 Expected response: 16 data bytes + 90 00. Error codes: 6A82 = file not found; 6982 = security status not satisfied; 6C10 = wrong Le (use Le=10).
Solved Problem: SCP03 Session Key Derivation
A GlobalPlatform SCP03 channel uses a base key set: ENC=4041424344454647 48494A4B4C4D4E4F, MAC=4041424344454647 48494A4B4C4D4E4F (same for simplicity). Host challenge H=0102030405060708 and card challenge C=0807060504030201. Derive the Session ENC key S-ENC and confirm its first 4 bytes. Solution: SCP03 Key Derivation (Section 4.1.5 of GP Amend D): Derivation data = [derivation_constant] || [counter=0] || H || C For S-ENC: constant = 0x04; for S-MAC: constant = 0x06; for S-RMAC: constant = 0x07. Step 1: Build 32-byte derivation input: 00 00 00 00 00 00 00 00 00 00 00 00 04 80 00 80 bits 0-11: zeros; bit 96: derivation constant (0x04 for ENC); bit 112-127: length=128, then H || C appended. Step 2: AES-CMAC(ENC_base_key, derivation_data) Python: from Crypto.Hash import CMAC; from Crypto.Cipher import AES c = CMAC.new(enc_key, ciphermod=AES); c.update(deriv_data); s_enc = c.digest() Result: S-ENC first 4 bytes = E7 A1 C2 D3 (illustrative). The session keys encrypt C-APDU data (S-ENC) and compute C-MAC/R-MAC (S-MAC/S-RMAC).
Solved Problem: EMV DDA Offline Dynamic Authentication
During an EMV DDA transaction the terminal sends an INTERNAL AUTHENTICATE command. The card signs a 4-byte terminal random number (UN=AABBCCDD) concatenated with card-specific data using its ICC Private Key (RSA-2048). Describe the full verification steps the terminal performs to authenticate the card. Solution: Step 1 – Retrieve ICC Public Key: READ RECORD -> Application file contains ICC Public Key Certificate. Decrypt certificate with Issuer Public Key -> recover ICC PK (n_icc, e_icc). Step 2 – Send INTERNAL AUTHENTICATE: APDU: 00 88 00 00 04 AA BB CC DD 00 Card computes: SignedDynamicAppData = RSA_sign(ICC_priv, hash_data) where hash_data = Hash(ICC_dynamic_number || pad || UN). Step 3 – Verify Signature: 1. RSA_verify(ICC_pub, SignedDynamicAppData) -> recovered hash. 2. Recompute SHA-1(card_dynamic_data || UN). 3. Compare: if equal, card possesses ICC private key -> authentic card. Step 4 – Verify Certificate Chain: Issuer PK Certificate signed by CA PK (from terminal AID-keyed CA key table). ICC PK Certificate signed by Issuer PK. Full chain: CA -> Issuer -> ICC. Security: DDA prevents card skimming (static SDA data cannot be replayed because ICC dynamic number increments per transaction).
Solved Problem: MIFARE Classic MFOC Nested Authentication Attack
You have a MIFARE Classic 1K card. You know Key A=FFFFFFFFFFFF for sector 0. Using the nested authentication vulnerability, derive the Key A for sector 1. Explain each step of the MFOC algorithm and the time/space complexity. Solution: Background: CRYPTO1 is a 48-bit LFSR. The nested attack exploits that when the reader re-authenticates to a second sector while already authenticated, the card nonce nt2 is encrypted with the CRYPTO1 keystream (which depends on nt1). Step 1 – Authenticate sector 0 with known Key A: Reader sends: AUTHREQ(block 0) -> card sends nonce nt1 (32-bit random). Reader sends: {nr, ar} encrypted -> session established (CRYPTO1 state S0). Step 2 – Collect nested nonce nt2: Without resetting, reader sends: AUTHREQ(block 4, sector 1). Card responds with nt2 XOR ks2 (nt2 encrypted with CRYPTO1 keystream ks2). Also: parity bits are encrypted -> 8 extra keystream bits known. Step 3 – Exploit timing for nt2 prediction: MIFARE RNG is a 16-bit LFSR clocked by field pulses (32-bit internal state). After 200 timed acquisitions, nt2 space reduces from 232 to 216. Step 4 – Brute-force CRYPTO1 state: For each candidate nt2: CRYPTO1_init(Key?, uid, nt2) -> check 8 parity bits. Matching state reveals Key A for sector 1. Complexity: Time O(232/timing_reduction) = O(216); Space O(1); real-world: <20 s on commodity hardware with Proxmark3 or mfoc tool.
21.15 Recent Developments (2024–2026)¶
The secure element and smart card ecosystem has expanded rapidly into digital identity, post-quantum cryptography, and consumer device integration.
21.15.1 ISO/IEC 7816-15 (2023): Cryptographic Information Application¶
ISO/IEC 7816-15:2023 updated the Cryptographic Information Application standard for smart cards, aligning it with modern algorithm suites and key container formats. The revision introduced:
-
Extended CertificateInfo objects to accommodate Elliptic Curve certificates with named curves beyond the original NIST P-256 set, including Brainpool P-384 and Ed25519.
-
Post-quantum placeholder key object types using vendor-extension mechanisms in the PKCS#15 structure, anticipating FIPS 203/204 standardisation.
-
Updated TokenInfo record to include a
flagsfield for indicating PQC readiness, hardware security level, and FIPS 140-3 compliance. -
Alignment with PKCS#15 v1.2 and the GlobalPlatform 2.3.1 card content management specification.
21.15.2 GlobalPlatform SEPE (Secure Element Policy Engine, 2023)¶
GlobalPlatform published the Secure Element Policy Engine (SEPE) specification in 2023, providing a standardised framework for enforcing security policies on SE operations without requiring individual applet modification. SEPE operates as a privileged service in the Issuer Security Domain and intercepts APDU commands before they reach target applets. Key capabilities:
-
Rate limiting: Configurable maximum number of authentication attempts per time window, enforced at the SE OS level rather than in each applet.
-
Geofencing (NFC): Policy rules that restrict NFC payment operations to specific geographic regions, implemented via carrier signal metadata.
-
Biometric binding: SEPE policies can require biometric verification (FIDO UAF) as a precondition for high-value operations.
-
Remote policy update: Policy rules are signed and pushed via the GlobalPlatform Secure Channel Protocol (SCP11c), enabling remote risk management.
21.15.3 Apple Secure Element: iPhone 15/16 (A17 Pro, 3 nm)¶
Apple’s Secure Enclave in the iPhone 15 Pro (A17 Pro, TSMC 3 nm process) and iPhone 16 series continues to serve as the hardware SE for both biometric authentication and NFC payments. The A17 Pro integrates the Secure Enclave Processor (SEP) on the same 3 nm die as the main application processor, with hardware isolation preventing the AP from accessing SEP memory. The SEP manages:
-
Apple Pay / NFC payments: The payment credential (card number substitute, Device Account Number) is stored in the SE’s NVM and signed by the SEP’s unique device key for each transaction. The SE communicates directly with the NFC controller, bypassing the AP for contactless transactions.
-
iOS 17 Digital ID: iPhone 15/16 expanded the Wallet app to present digital driver’s licences and national IDs (in participating US states) from secure hardware. The presentation protocol uses the ISO 18013-5 mobile driving licence (mDL) standard with the SE holding the identity credential.
-
Passkeys: FIDO2 passkeys generated on iPhone 15/16 are anchored to the SEP—the ECDSA P-256 private key is hardware-bound, though passkeys sync encrypted through iCloud Keychain.
21.15.4 Google Pixel 8 Titan M2: SE + HSM Combo¶
The Google Pixel 8 (2023) and Pixel 8 Pro ship with the Titan M2 chip, which Google redesigned to function simultaneously as a secure element and a hardware security module. The Titan M2 in Pixel 8:
-
Manages the Android Strongbox Keymaster: a hardware-isolated keystore providing FIDO2 platform authenticator functionality, disk encryption key protection, and Android Keystore operations at security level
SECURITY_LEVEL_STRONGBOX. -
Stores the Pixel Titan Verified Boot signing key, providing an independent hardware root of trust separate from the application processor.
-
Supports Private Compute Core operations, protecting on-device ML model outputs from leaking to other apps or the OS.
-
Achieved Common Criteria EAL5+ (under the Mobile Device Fundamentals PP v3.3) for the Pixel 8 as a complete device, with the Titan M2 SE as a core evaluated component.
21.15.5 SE for Digital Identity: eIDAS 2.0 EUDIW Hardware Requirements¶
The European Digital Identity Wallet (EUDIW) regulation, finalised as eIDAS 2.0 in 2024 (Regulation 2024/1183), establishes mandatory hardware requirements for the wallet’s secure storage component. Member states must make EUDIW available to all EU citizens by 2027. Hardware security requirements:
| EUDIW Hardware Requirement | Minimum Assurance |
|---|---|
| Wallet Secure Cryptographic Device (WSCD) | CC EAL4+ or equivalent |
| Private key storage | Hardware SE; keys non-extractable |
| Authentication assurance | eIDAS Level High (LoA High) |
| Biometric binding | On-device match, result in SE |
| Proximity presentation (ISO 18013-5) | SE-signed mDL response |
| Remote qualified signature | QSCD (EAL4+ HSM-backed) |
The EUDIW Architecture Reference Framework (ARF 1.4, 2024) specifies that the WSCD must generate the wallet key pair on-chip and must not allow key export under any interface; this effectively mandates a dedicated secure element on the device.
Note: The EUDIW specification distinguishes between “remote” and “proximity” presentation flows. Both require hardware-backed signatures, but proximity flows (showing ID to a physical terminal) additionally require the ISO 18013-5 mDL protocol with SE-verified device authentication.
21.15.6 NXP SE051W: Post-Quantum Secure Element (2024)¶
NXP announced the SE051W in 2024 as the first commercially available secure element with native post-quantum cryptographic support. The SE051W extends the SE050 platform (CC EAL6+, I\(^2\)C, 50 KB NVM) with:
-
ML-KEM-512 support: Hardware-accelerated lattice arithmetic for Kyber key generation and encapsulation/decapsulation, enabling PQC key exchange from an IoT device without software overhead.
-
Hybrid key operations: A single APDU command can execute a hybrid ECDH P-256 + ML-KEM-512 key agreement, combining the outputs in a KDF.
-
Updated EdgeLock library: NXP’s SE05x middleware was updated to support PKCS#11 3.0 CKM_KYBER mechanism, transparently routing PQC operations to the SE hardware.
-
Form factor: Same WLCSP 2.5 \(\times\) 2.5 mm package as SE050, enabling drop-in upgrades in existing PCB designs.
// SE051W: ML-KEM-512 key generation via SE05x middleware (C API)
#include "fsl_sss_se05x_apis.h"
sss_se05x_key_store_t keyStore;
sss_se05x_object_t kyberKey;
uint8_t pubKey[800]; size_t pubKeyLen = 800; /* ML-KEM-512 public key */
/* Create ML-KEM-512 key pair in SE NVM slot 0x70000001 */
sss_se05x_key_object_init(&kyberKey, &keyStore);
sss_se05x_key_object_allocate_handle(&kyberKey, 0x70000001,
kSSS_KeyPart_Pair, kSSS_CipherType_KYBER_512, 0,
kKeyObject_Mode_Persistent);
sss_se05x_key_store_generate_key(&keyStore, &kyberKey, 512, NULL);
sss_se05x_key_store_get_key(&keyStore, &kyberKey,
pubKey, &pubKeyLen, NULL);
Exercises
-
Explain the difference between ISO 7816 T=0 and T=1 protocols. Which has better error recovery and why?
-
A JavaCard applet must implement ECDH key agreement over P-256. Write the
process()method skeleton showing JCAPI calls forKeyPair,KeyAgreement, andCipherobjects. -
GlobalPlatform defines three key types in SCP03: ENC, MAC, and DEK. Describe the purpose of each and which APDU fields they protect.
-
Trace the full EMV CDA (Combined DDA/Application Cryptogram) flow, explaining how it combines offline authentication with the online AC.
-
A US agency issues PIV cards with slot 9A using ECC P-384. List the X.509 certificate fields required by FIPS 201-3 and the key usage bits that must be set.
-
Describe how ICAO PACE protocol prevents brute-force attacks on MRZ data, referencing the PAKE mechanism and entropy analysis.
-
A building access system uses MIFARE Classic 1K cards. An auditor finds that all cards share the same Key A. Explain the specific attack steps and propose a migration to MIFARE DESFire EV3 with AES-128.
-
Calculate the maximum eavesdropping range for ISO 14443-A at 13.56 MHz given a reader field strength of 7.5 A/m and a passive attacker antenna with Q-factor=30.
-
The NXP P60 active shield detects wire tampering by measuring capacitance on a mesh routed above the die. Explain how laser fault injection (LFI) can still succeed and what countermeasures the EAL6+ evaluation requires.
-
An SCP02 channel is active on a JavaCard platform. An attacker intercepts and replays a C-APDU containing STORE DATA. Explain why SCP02 sequence counters prevent the replay and how SCP03 improves on this with AEAD.
-
Compare Apple Secure Enclave (T2 chip), Google Titan M2, and Samsung Galaxy S23 SE in terms of: process node, key storage architecture, and OS attestation key.
-
A researcher captures 1000 power traces during RSA-2048 signing on an NXP P60. Explain how Template Attack (a supervised SCA technique) can recover the private exponent, and list the three hardware countermeasures in the P60 that resist it.