Oman eID

The Oman eID, end to end

A guided tour of the card and the tool that reads and personalizes it — from what a smart card is, through GlobalPlatform, MPCOS and the IAS PKI, to the Workshop you drive it all with. The material is organized into six parts. Use the Simple / Technical switch in the header to change how much detail every explanation shows, then jump to the Workshop to watch these ideas happen on the real card in your reader.

Part I

Foundations

How a smart card is built and how we talk to it — the vocabulary the rest of the book uses.

Chapter 1What is the Oman eID?

It's the Omani national ID card — but with a tiny secure computer (a chip) inside. The chip can prove who you are online, hold a digital signature, and act as an e-passport, all protected so it can't be copied.

Citizen / ResidenteID + e-signaturee-passportbiometrics

Chapter 2Anatomy of a smart card

The chip is a complete little computer with no screen or battery. It only wakes up in a reader, and it only ever receives a request, thinks, and sends an answer back. Everything it protects is protected by maths, not by a lock you can see.

On the die (a single tamper-resistant chip)
CPU core
8/16/32-bit processor — runs the OS and the applets
Crypto co-processor
AES · 3DES · RSA · ECC in hardware
ROM
the OS mask — fixed at manufacture
EEPROM / Flash
keys, files, data — kept with the power off
RAM
scratch memory — cleared when unpowered
Security sensors
voltage/clock/light traps against tampering
Contact interface
ISO 7816 — the gold pads. APDUs over T=0 / T=1 when inserted in a reader.
Contactless interface
ISO 14443 — an embedded RF antenna. Same APDUs over the air, gated by PACE.

No screen, no battery, no keyboard: the chip only ever receives a command, computes, and answers. Every security guarantee therefore lives in the protocol and the keys held inside — never in a UI.

Chapter 3APDUs — how we talk to a card

Every message to the card is a small command packet, and the card replies with data plus a 2-byte 'verdict' code. 9000 means OK.

Lc
08
Data fields
ISD AIDA0 00 00 00 18 43 4D 00
00 A4 04 00 08 A0 00 00 00 18 43 4D 00

Chapter 4TLV — how data is stored

Data on the card is packed as labelled boxes: a Tag (what it is), a Length (how big), and the Value (the contents).

5F20 06 4F 4D 41 4E 49 44
Tag 5F20 (name) · Length 6 · Value "OMANID"

Chapter 5The file system — MF, DF & EF

Inside the chip, data is organised like folders and files on a computer. There's one root folder, a sub-folder for each application, and the real data lives in small files inside. To read something you first open the right folder, then the file.

MF 3F00 — root
DF ROP app A0…524F5001
DF ID application …524F500101
EF 7001 ID info · 7002 photo · 7004 name · 7006 nationality
EF 7005 / 7007-7009 biometrics (PIN-gated)
The card answers you in status words — learn to read them:
9000 — success
6982 — needs authentication / PIN
6A82 — file/app not found (doesn't exist)
6981 — wrong command for this file's structure
6983 — blocked (counter exhausted)
6988 — secure-messaging / MAC wrong
The distinction matters: 6982 means the command was accepted but you lack the credential; 6988 means the message itself was malformed. Same-looking failure, very different cause.
→ Read a real card's ID fields in the Workshop
Part II

Platform & security

How applications are managed, how a card is identified, and the secure channel that protects every write.

Chapter 6GlobalPlatform & Java Card

Think of the card as a phone and the features as pre-installed apps. GlobalPlatform is the 'device admin + app store' that installs them and decides who's allowed to.

GP ISD (Card Manager)
A0 00 00 00 18 43 4D 00
9000
MPCOS (ID / DL / e-Auth)
A0 00 00 00 18 52 4F 50 01
9000
IAS Classic (PKI)
A0 00 00 00 18 0C 00 00 01 63 42 00
9000
BioManager — MOCA
A0 00 00 00 30 80 00 00 00 0A B1 00 01
9000
FIDO U2F
A0 00 00 06 47 2F 00 01
9000
eTravel / ICAO
A0 00 00 02 47 10 01
9000

Chapter 7Identifying a card

Before doing anything, we read three harmless things: the card's 'hello' (ATR), its 'birth certificate' (CPLC), and an identity tag that says Citizen vs Resident and Test vs real.

ATR 3B7A9700008065B0 85 20 05 0272D643
20 = Citizen · 05 = MAV5.2
→ Watch a real inspection in the Workshop

Chapter 8Keys & diversification

Every card shares one factory 'master key' family — but it would be dangerous if they were all identical. So each card mixes the master key with its own serial number to make keys that are unique to it. We never see the keys; we only see a short 'fingerprint' that proves they're right.

Mother key (test batch)
secretKCV 8A1C44
combined with card serial
Diversification data
4D 00 00 B3 5E 00 01 02 03 04
AES-CMAC(mother, role ‖ serial)
K-ENC
secretKCV 1F9E20
K-MAC
secretKCV 77B3C1
K-DEK
secretKCV 0A55E9
keys never displayedKCV fingerprint onlyAES-CMAC diversification

Chapter 9SCP03 & staying safe

To manage the card you must prove you know its secret key. Both sides swap random numbers and compute a matching proof. The big danger: guessing wrong locks the card forever after only 3 tries. So our tool checks the card's proof first and only sends our reply when it already knows it will succeed — it can never lock the card.

INITIALIZE UPDATEhost → card
host challenge
card responsecard → host
div data · challenge · cryptogram
Card cryptogram verifiedverify
safe to authenticate
EXTERNAL AUTHENTICATEhost → card
host cryptogram + C-MAC
9000 — channel opencard → host
velocity counter reset
Host challenge
7D 4C F9 8F 97 53 FA 0A
card challenge
Card challenge
01 02 03 04 05 06 07 08
SCP03 KDF (SP 800-108, AES-CMAC)
S-ENC
secretKCV C41A07
S-MAC
secretKCV 9B2E55
S-RMAC
secretKCV 30FFA1
Why this is safe:a wrong key is never submitted to the card, because the card's own cryptogram is verified before EXTERNAL AUTHENTICATE. Live cards are refused before INITIALIZE UPDATE.
→ Open the secure channel in the Workshop

Chapter 10Lifecycle & dangerous operations

A card has a 'life cycle' — stages from factory-fresh to retired. Some moves forward can never be undone, and a few operations can permanently brick the card. The tool is built so you can explore all of this safely, but it's important to know which actions are the dangerous ones.

OP_READY01
Fresh from the factory.
one-way →
INITIALIZED07
Being prepared for issuance.
one-way →
SECURED0Fcurrent
Normal in-the-field operation.
one-way →
CARD_LOCKED7F
Temporarily locked; refuses app selection.
reversible (with keys)
TERMINATEDFF
End of life — responds to almost nothing.
PERMANENT
Permanent (no recovery): SET STATUS → TERMINATED · PUT KEY to a key you don't hold · exhausting GP auth (≈3 on MAV5.2 perso) · PUK exhaustion.
Recoverable: CARD_LOCKED (unlock with keys) · PIN block (unblock with PUK).
Always safe: SELECT · GET DATA · a correct, completed SCP03 handshake.
Part III

MPCOS — data, keys & what it proves

The legacy identity store: its access rules, PINs and secure key loading — and what personalizing it end-to-end reveals about the “issuer wall.”

Chapter 11Access conditions — the 2-byte lock

Every file on the card carries a tiny 2-byte rule that says who may read it, who may change it, and who may never touch it. Learning to read those two bytes tells you at a glance whether a field is public, locked behind a PIN, or frozen forever.

71C0Read needs SM key SFI 0x11 (local) + secret code #4 (local)
01110001
11000000
protection = PIN (SCN1)key file SFI = 0x11secret code index = 4
0100Update needs SM key SFI 0x1 (global)
00000001
00000000
protection = freekey file SFI = 0x1secret code index = 0
C000Access never allowed — frozen
11000000
00000000
protection = neverkey file SFI = 0x0secret code index = 0
0000Access is free
00000000
00000000
protection = freekey file SFI = 0x0secret code index = 0

Chapter 12Writing data & the safety gate

Reading is safe; writing changes the card. Personalization means writing the cardholder's details into little files on the chip. To make sure nothing happens by accident, the tool always asks you to confirm first — and real cards are protected until you deliberately turn writes on.

EFTagFieldValue
70012100Civil Number12345678
7004E40BFull Name (EN)AHMED AL SAID
7004A40AFull Name (AR)أحمد السعيد
7006E614Nationality (EN)OMANI
70014102Date of Expiry2034-01-01
The safety gate: destructive operations stop and wait for an explicit confirmation. Nothing is written until you approve it in the dialog, and every write path is verify-first — the card cryptogram is checked before anything is sent — so a wrong key is never submitted.
→ Personalize the ID in the Workshop

Chapter 13MPCOS PINs & the secret-code file

The card keeps its PINs in one small file with eight numbered slots. On the Oman ID app, slot 5 is the cardholder's PIN that unlocks the protected fields, and slot 8 is the PUK — the 'master PIN' used to rescue a PIN that got blocked from too many wrong tries.

idx 0
idx 1
idx 2
idx 3
idx 4
PIN
idx 5
idx 6
idx 7
PUK
Pin 5 — cardholder PINgates read-AC 71C0
47mode00scr07ucrCFcksum12pin34pin56pin00pin
Pin 8 — PUKunblocks Pins 1-7
47mode00scr00ucrB1cksum12pin34pin56pin78pin

ucr (unblock-code reference) links a PIN to the PUK slot; pin4 is the 8-digit code compressed to 4 BCD bytes.

Chapter 14Loading keys & PINs without an HSM

You can't just write a key or PIN into the card as plain bytes — the chip ignores that. Instead you send it as a scrambled little package that only the current session can unlock, and the card sends back a short proof that it landed correctly. This is the exact step everyone assumed needed the manufacturer's secure server — and it turns out we can build the package ourselves.

plaintext block (16 bytes)
header
type/ver or mode/scr/ucr
chk
255−XOR
value
key half / pin4
value′
(pin repeat)
offset
data units
sum
Σ bytes
enc = 3DES-decrypt(KATS, block)
host → card
04 D6 <offset> 10 <enc16>
UpdateBinary, secure-messaging class
card → host
<cardCrypto3> 9000
host checks it == 3DES-enc(KATS, …)[:3]

A matching cryptogram proves the key/code landed correctly. The key file must have update-AC 0100 or the card refuses the load with 6982.

Chapter 15Personalizing a blank card end-to-end

Putting it all together: starting from a blank card we open an admin session, create the folders and files, load the keys and the PIN/PUK, and finally write the identity fields — marking the sensitive ones as PIN-protected. The result is a working ID card built entirely on the workstation.

SelectFileKey (global 0x01)host → card
open the admin session · KATS
CREATE DF 0200host → card
the ID application
CREATE 0211 (AC1=0100) + secure-load K2host → card
diversify(MKADMIN.02, CSN) · cardCrypto ok
SelectFileKey LOCAL 0x11 → 9000verify
K2 registered as an SM key
CREATE 0213 + secure-load PIN@4 / PUK@7host → card
123456 / 12345678
CREATE + fill data EFshost → card
sensitive set read-AC 71C0
9000 throughoutcard → host
working card personalized
→ Personalize a card in the Workshop

Chapter 16Reading protected files & the PUK

To read a protected field you open the card's secure channel and type the PIN — but the PIN never travels in the clear; it's scrambled first. Type it wrong too many times and the PIN blocks, and the PUK is supposed to rescue it. Blocking works exactly like a real card; the PUK rescue is still a work in progress.

SelectFileKey LOCAL 0x11host → card
open the K2 read session
VERIFY (ciphered PIN)host → card
00 20 00 04 08 <enc>
READ 7008 → 9000card → host
was 6982 · now the real data
Wrong tries → block → PUK
63C6
wrong PIN
63C0
last try
6983
BLOCKED
PUK verifies
VERIFY PUK@7 → 9000
PUK unblock — open
SetSecretCode → 6985 · admin re-load recovers
→ Read the protected fields in the Workshop

Chapter 17The issuer wall — re-examined

We first assumed you could read a card but never build one — that 'issuing' was locked inside the manufacturer's secure server. Digging into the real tools showed that's only half true. The server mostly just mixes the master keys with the card's serial number, which we can reproduce ourselves once we hold those master keys. So with the master keys and a blank card, we personalized a fully working card locally. What still can't be forged is a card that's already finished and frozen — plus the factory's own perso keys we don't have.

You CAN (mother keys + creatable card)
  • · Create the DF and data/key/PIN files
  • · Secure-load K2 and the PIN/PUK
  • · Present the PIN enciphered under K2
  • · Read the PIN-protected fields
  • · Personalize a blank into a working card
Still can't
  • · Re-personalize a finished/issued card (frozen)
  • · Reproduce factory-exact keys/PINs (no MKID/SK)
  • · Pass the issuer's PKI (passive auth / CSCA)
  • · Recover a TERMINATED card
The tell (status words)
  • fresh AC1=0100 create → 9000
  • secure load → cardCrypto match
  • ciphered VERIFY PIN → 9000
  • finished card create → 6982 / exists
The revised takeaway: the KMS is diversification, not a vault. A leaked mother key isn't just a read/clone risk — combined with blank stock of the same batch it is enough to mint a working staging card. The real protection against forging an issued card is the frozen file structure and the factory perso keys, not the HSM being unreproducible. The previous chapters walked through exactly how we did it.
Part IV

IAS & PKI

The modern PKI application: certificates and keys, and how we install, personalize and read it back.

Chapter 18IAS, PKI & secure messaging

IAS is the part of the card that does digital signatures and proves your identity online, using public-key cryptography (PKI). First we install the empty app; then, in chapter 20, we fill it with keys, a PIN and a certificate. Both jobs run over the encrypted admin channel, so every command is signed to prove it really came from us and wasn't tampered with on the way.

SCP03 channel already openverify
C-MAC on every command
INSTALL [for install] IAShost → card
84 E6 0C 00 … (C-MAC)
PUT DATA (A5)host → card
84 DA 00 00 … additional params
9000 eachcard → host
IAS shell installed — reversible
Install ≠ personalize: this creates the empty PKI app. Chapter 19 explains what a certificate actually is; Chapter 20 loads the keys, PIN and a real certificate; Chapter 21 reads it all back.
→ Install IAS in the Workshop

Chapter 19Certificates, X.509 & PKCS#15

A certificate is a signed statement that says 'this public key belongs to this person.' The card keeps the matching private key locked inside and never lets it out; the certificate is public. Because a trusted authority signed the certificate, anyone can check it's genuine and hasn't been altered. The card also keeps a little index so software knows which key, certificate and PIN go together.

X.509 certificate
tbsCertificate — the part that gets signed
versionv3
serialNumberunique per cert
signaturesha256WithRSAEncryption
issuerwho signed it (DN)
validitynotBefore → notAfter
subjectCN=Oman eID Test Holder
subjectPublicKeyInfoRSA-2048 public key
extensionsKeyUsage · EKU clientAuth
signatureValue— the issuer's signature computed over the whole body above. Change one byte of the body and this no longer verifies.
PKCS#15 / DF.CIA — the on-card index
EF.DIR 2F00points to the application
DF.CIA 5000the PKI directory
EF.OD 5031object directory — the map
EF.CIAInfo 5032label, serial, algorithms
PrKDF 5001 / PuKDF 5002private / public keys
CDF 5003certificate directory →
B001…B00Athe DER certificate bytes live here
AODF 5006PINs that gate the keys

A middleware reads EF.OD, follows it to the directories, and learns which key signs with which certificate behind which PIN — without any card-specific configuration.

→ Explore the PKCS#15 index in the Workshop

Chapter 20Personalizing IAS & writing a certificate

Putting real keys and a certificate onto the card. Installing only creates the empty PKI app; personalizing logs into it over an encrypted channel and writes its secret key, its PIN, a signing key, its folder structure, and a genuine digital certificate — then finalizes it so the card is ready to sign with the PIN.

SCP03 auth on the ISDhost → card
INIT UPDATE + EXT AUTH (MAC+ENC)
INSTALL IAS (priv 12 / 06 E4 E4)host → card
perso-enabling params
SELECT IAS + fresh SCP03 (Perso)host → card
the personalization channel
build PKCS#15host → card
SM key · PIN 81 / PUK 82 · SE 1-3 · EFs · DF.CIA
signing key 04host → card
GENERATE on-chip (46 02) or load a host CRT
UPDATE B001 ← X.509host → card
certificate of the signing key
END PERSONALIZATIONhost → card
80 E4 00 00 → application phase (PIN-gated)
The key insight:the card only opens a GP channel with the ISD selected — but after that ISD auth, it will open a second one with IAS selected. That's the door into personalization. Everything is on a test card with a self-generated key; verify-first refuses any non-test card.
→ Run IAS personalize in the Workshop

Chapter 21Exploring the IAS PKI

Reading everything the PKI app holds — safely. We open the app and list its certificates, keys and PIN status without ever typing a PIN or changing anything. A deeper 'authenticated' pass opens the encrypted channel to also read protected content, like the face photo.

▸ MF0001 CardSN · 0002 Shared · 2F00 EF.DIR
▸ DF.CIA 50005031 OD · 5032 CIAInfo · B001 certificate
▸ DF.DATA 51001000 face photo (secure channel)
→ Explore IAS in the Workshop (read-only or deep)

Chapter 22Signing with a PIN on the card

The whole point of the PKI app: making a real digital signature. You type your PIN, the chip signs your message with its private key, and anyone can check the signature with the public certificate. The private key never leaves the card — the card itself does the signing, and only after you enter the PIN.

SELECT IAShost → card
application phase (plain APDUs)
VERIFY User PINhost → card
00 20 00 81 … (wrong PIN → 63Cx)
MSE SET DSThost → card
algo 42 (RSA/SHA-256), key 04
PSO HASHhost → card
90 20 <SHA-256 of the message>
PSO COMPUTE DIGITAL SIGNATUREhost → card
→ 256-byte RSA signature
host verifyverify
VerifyData against the certificate → VALID
Why it's trustworthy: the private key was generated on the chip (or loaded once, off-card) and is never exportable; the card computes the signature, and only after the User PIN is verified. A wrong PIN just decrements the try counter (3 = blocked) — it never signs.
→ Sign a message in the Workshop
Part V

The other applications

The rest of what the chip can hold — the e-passport and the applets this tool doesn't drive — and why.

Chapter 23e-Passport (eTravel) & PACE

The card can also act as an e-passport. To stop anyone secretly reading it over the air, the chip only opens up after you prove you can physically see the document — by entering a password printed on it (the machine-readable text, or a 6-digit number). Then the reader can fetch the holder's details and photo, and check the issuer's signature to be sure nothing was changed.

SELECT eTravel + read EF.CardAccesshost → card
learn the PACE parameters
PACE (MRZ/CAN password)verify
MSE:Set AT + GENERAL AUTHENTICATE ×4
secure messaging opencard → host
AES KSEnc / KSMac
read DG1 MRZ · DG2 face · …host → card
encrypted + MAC'd
passive authenticationverify
verify EF.SOD hashes + CSCA signature
Who can read what
ObjectNo authBACPACEEAC
EF.CardAccess
PACE parameters
EF.COM / EF.SOD
DG index + signature
DG1
MRZ (name, number, dates)
DG2
facial image
DG14 / DG15
Chip / Active Authentication keys
DG3 / DG4
fingerprints / iris

The eTravel applet is contactless and PACE-gated: reading it needs the MRZ/CAN-derived keys printed on the document, which the test cards don't carry — so this tool doesn't operate it. The mechanics are covered here for background.

Chapter 24FIDO, MOCA & PURE

Beyond identity and signatures, the chip carries a few more applications: a fingerprint check that happens inside the card, a phishing-resistant login key for websites, and a bank-card-style applet. This tool focuses on the ID and PKI applications, so it shows these exist but doesn't drive them — each needs credentials or an enrolment this tool doesn't have.

FIDO U2F
A0000006472F0001

Phishing-resistant login. Per-site key handles + a signature counter; attestation cert.

MOCA — biometrics
A0…AB10001

Match-on-card fingerprint. Templates never leave the chip; BioPIN fallback.

PURE — EMV
white applet

Payment kernel, personalized post-issuance via its own SSD over SCP02.

Why the tool doesn't drive FIDO and PURE: each needs a credential a test card doesn't carry — a relying-party registration (FIDO) or EMV personalization keys (PURE). MOCA is different — this tool can install and enrol it with a synthetic fingerprint; see the next chapter.

Chapter 25Match-on-card: fingerprints on the chip

A normal system checks your fingerprint by sending it to a computer that holds a copy. Match-on-card flips that around: your fingerprint is stored inside the chip, and the comparison happens inside the chip too. Nothing about your finger ever comes back out — the card only ever answers 'yes, that's the finger' or 'no, it isn't'. This tool can set that up on a test card with a made-up (synthetic) fingerprint, then prove the matching works.

Server — the vault + matcher

Holds the enrolled template and does the comparison on-chip. Personalized with a synthetic ISO 19794-2 fingerprint; the matcher goes live automatically.

Client — the verify interface

The applet an app talks to for a runtime VERIFY. Its install parameter is applet-private (not in the vendor manual), so runtime verify needs the vendor integration guide.

What the tool does today: Install MOCA (server) → Enrol fingerprint (synthetic, on-card) → the server reports personalized and the matcher is live. Test cards only; the template is synthetic and never leaves the chip; everything is removable with Remove MOCA.
Part VI

Using the Workshop

How the tool itself works: the card overview, the two views, the contextual toolbox and the safety model.

Chapter 26The Workshop & the two views

The Workshop is the main screen. Put a card in the reader, press Scan, and it draws everything on the card as a grid of applications — each showing whether it's present. There are two ways to view the work: Simple, which shows plain outcomes, and Technical, which shows every command the tool sends. The switch is in the top bar; this whole book responds to it too.

GP ISD (Card Manager)
A0 00 00 00 18 43 4D 00
9000
MPCOS (ID)
A0 00 00 00 18 52 4F 50 01
9000
IAS Classic (PKI)
A0 00 00 00 18 0C 00 00 01 63 42 00
9000
eTravel / ICAO
A0 00 00 02 47 10 01
6A82
→ Open the Workshop

Chapter 27The toolbox & the safety model

Instead of a menu of raw commands, each application on the card offers just the actions that make sense for it right now. An empty IAS offers Install; once installed it offers Personalize; once personalized it offers Explore and Sign. Anything that changes the card asks you to confirm first, and the tool refuses to touch anything but test cards.

ActionOperationWhat it does
Scan cardinspection.readATR, CPLC, identity and applet presence — read-only.
Deep scancard.deepscanSCP03 + GET STATUS: the real installed applets and life-cycles.
Open secure channelscp03.handshakeVerify-first SCP03 mutual authentication (resets the lock counter).
Read IDmpcos.readidRead the MPCOS identity fields (free-read).
Read ID (authenticated)mpcos.readid.authSM session — reveal admin-gated fields.
Personalize IDmpcos.personalizeWrite the identity fields (confirm-gated).
Install IASias.instantiateCreate the IAS instance — reversible.
Explore / Deep exploreias.exploreRead the PKI; deep pass reads protected content over SM.
Personalize IAS (default)ias.personalizeFull perso ending in a certificate + on-card signing key.
Personalize IAS (custom)ias.provisionChoose exactly what to build (incl. on-card / off-card key).
Sign with IASias.signSign a message with the on-card key, gated by the User PIN.
Remove IASias.deleteDelete the instance — reversible.
The safety model: reads never move a counter; every write waits for your confirmation; the card cryptogram is verified before any authentication so a wrong key is never submitted; and non-test cards are refused outright.
→ Try the toolbox in the Workshop