Tools Beta

ODA Debugger: SDA, DDA and CDA

Drop a log with the card's certificates and the CA public key, and follow offline data authentication step by step as EMV Book 2 specifies: issuer and ICC key recovery, the static data to be authenticated, and the SDA, DDA and CDA signatures. Every recovered block, every hashed input and every check is shown, so you can see exactly where it fails and why.

Test keys and test cards only. Everything runs in your browser and nothing is sent anywhere. RSA only: Kernel 8 ECC certificates are not covered yet.

1. Card data

Drop a log here EVAL HTML log, KaNest text or XML log, or a list with one APDU per line
No log loaded.
Or paste a log or APDUs

2. Certification Authority public key

The card's RID and CA key index (8F) appear here once a log is loaded.

Key file format

A key file is a text file of hexadecimal bytes holding one or more CA public key records. Each record has this structure:

FieldLengthContent
Tag3 bytesDF A0 23
Record length1 to 3 bytesBER-TLV length, for example 82 01 22 (290 bytes)
RID5 bytesRegistered Application Provider Identifier, for example A0 00 00 00 04
Key index1 byteCA Public Key Index, as in tag 8F, for example F1
Hash algorithm indicator1 byte01 for SHA-1 (00 accepted)
Public key algorithm indicator1 byte01 for RSA (00 accepted)
Modulus length2 bytesLength of the modulus in bytes, most significant byte first, for example 00 B0 (176)
Modulus256 bytesThe modulus, padded on the right with 00 up to 256 bytes
Exponent length1 byte01 or 03
Exponent3 bytes03 00 00 for exponent 3, or 01 00 01 for 65537
Checksum20 bytesSHA-1 of RID, index, modulus and exponent, or all 00 if not provided

With a 2-byte record length, a record is 296 bytes: tag 3, length 3, then 290 bytes of content.

Reading rules: spaces, line breaks, brackets and other separators are ignored; a label line containing capk# (for example visa capk#1) is skipped; any number of records can follow each other in one file; RIDs from several payment systems can be mixed. A key imported again with the same RID and index replaces the previous one.

Example (shortened):

mastercard capk#4
[DF A0 23 82 01 22
A0 00 00 00 04
F1
01
01
00 B0
C7 5E 21 … (176 bytes of modulus) … 00 00 (80 bytes of padding)
01
03 00 00
00 00 … (20 bytes of checksum)]
Contains the fictional test key of the sample (RID A000000999, index 99), with its checksum.

RSA recovery on its own

Recover any EMV certificate or signature: X = Se mod n (Book 2 A2.1). A valid block starts with 6A and ends with BC.

How it follows EMV Book 2

Issuer and ICC public keys

The Issuer Public Key Certificate (90) is recovered with the CA key and checked as in Book 2 section 5.3: trailer BC, header 6A, format 02, SHA-1 hash over the certificate fields, the remainder (92) and the exponent (9F32), issuer identifier against the PAN, expiry and algorithm. The ICC Public Key Certificate (9F46) follows section 6.4, with format 04, the PAN, and a hash that also covers the ICC key remainder (9F48), exponent (9F47) and the static data to be authenticated.

SDA, DDA and CDA

SDA recovers the Signed Static Application Data (93, section 5.4). DDA recovers the INTERNAL AUTHENTICATE signature and hashes it with the DDOL data sent by the terminal (section 6.5.2). CDA recovers the signature from GENERATE AC, checks the CID, hashes with the Unpredictable Number, and recomputes the Transaction Data Hash Code from the PDOL data, the CDOL1 (and CDOL2) data and the response data objects except 9F4B (section 6.6.2).

The sample

"Load a sample" uses a complete test chain generated for this page with throwaway keys, under the fictional RID A000000999 and CA index 99: a 1408-bit CA key, a 1152-bit issuer key and a 1024-bit ICC key, with SDA, DDA and CDA. It is not a real payment system key.

Keys you save or import

"Remember this key" stores the modulus and exponent in this browser only, under the RID and index, and fills them in the next time a log uses the same key. "Import a key file" loads many keys at once from a file of key records, each starting with the tag DF A0 23 and a length, then the RID (5 bytes), the index, the hash and algorithm indicators, the modulus length (2 bytes), the modulus (256 bytes, padded with zeros), the exponent length, the exponent (3 bytes) and the key checksum (20 bytes). When the checksum is filled in, it is checked as SHA-1 of RID, index, modulus and exponent. Keys never leave your browser.