Modul 3 Kommunikation Karte/ M. Leischner Chipkartensysteme I Folie 1 Grundschema Chipkarten-Protokoll Smart Card "Master" "Client" Reset ATR (Answer to Reset) [PTS necessary] PTS-Requ PTS-Resp "Slave" "Server" command 1 response 1 command 2 response 2 M. Leischner Chipkartensysteme I Folie 2
Activation Sequence and Reset Smart Card Activation Activation sequence sequence (driven (driven by by the the terminal): terminal): 1) 1) Ground Ground 2) 2) Power Power supply supply 3) 3) (external) (external) Clock Clock 4) 4) Reset Reset 5) 5).. V CC RST CLK GND V PP I/O Reset ATR (Answer to Reset) [PTS necessary] PTS-Requ PTS-Resp command 1 response 1 command 2 response 2 M. Leischner Chipkartensysteme I Folie 3 Physical Layer - Transmitting a Bit terminal external clock (typical: 3,571200 MHz) Clock smart card divider (typical by 372) I/O I/O I/O data transmission rate = 3571200 / 372 = 9600 bit/s etu (elementary time unit) = length of a bit = 372 / 3571200 = 104 µs M. Leischner Chipkartensysteme I Folie 4
etu (elementary time unit) Definition 1 etu (elementary time unit) = Zeitdauer für die Übertragung eines Bits in Abhängigkeit von Taktfrequenz, einem Umrechnungsfaktor ("Teiler") und einem Justierfaktor. F 1 1 etu = D f F = Umrechnungsfaktor (clock rate conversion factor, "Teiler"): Standardwert = 372 D = Justierfaktor (baud rate adjustment factor): Standardwert =1 f = Taktfrequenz (frequency): Standardwert =3,571200 MHz M. Leischner Chipkartensysteme I Folie 5 Übertragung eines Zeichens 8 Bit = 1 Character Error Signal Guardtime Startbit Paritätsbit Startbit high low 0 1 2 3 4 5 6 7 8 9 10 11 12 CWT +0 CWT +1 CWT +2 t (etu) mindestens 12 Bitzeiten, d.h. Guardtime=2 M. Leischner Chipkartensysteme I Folie 6
direct/inverse convention high low 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 1 2 3 4 5 6 7 8 direct convention of the byte 3B = 00111011) t (etu) high low 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 1 8 7 6 5 4 3 2 1 t (etu) inverse convention of the byte 3B = 00111011 M. Leischner Chipkartensysteme I Folie 7 Answer to Reset terminal smart card Reset ATR (Answer to Reset) [PTS necessary] PTS-Requ PTS-Resp command 1 response 1 command 2 response 2 M. Leischner Chipkartensysteme I Folie 8
An Example of an ATR (Answer to Reset) The ATR of the enhanced BasicCard ZC3.9: 0 means "divider = 372" --> work etu = 372 / f terminal 3B EF 00 FF 81 31 20 75 42 61 73 69 63 43 61 72 64 20 5A 43 33 2E 39 86 F 16 = 1111 2 = 15 10 3B = direct convention (3F = inverse convention) "BasicCard ZC3.9" 15 historical characters M. Leischner Chipkartensysteme I Folie 9 TS T0 j/n j/n j/n j/n k Aufbau ATR Basic Structure of ATR TC1 TB1 TA1 TD1 j/n j/n j/n j/n Protokoll TC2 TB2 TA2 TD2 j/n j/n j/n j/n Protokoll TC3 TB3 TA3 TD3 j/n j/n j/n j/n Protokoll TC4 TB4 TA4 H1 TCK TD4 M. Leischner Chipkartensysteme I Folie 10 Hk
Protocol Type Selection Smart Card Reset ATR (Answer to Reset) [PTS necessary] PTS-Requ PTS-Resp command 1 response 1 command 2 response 2 M. Leischner Chipkartensysteme I Folie 11 Betriebsarten (Aktivitätsdiagramm) [kein PPS kommt --> implicite selection "first offered Prot."] Kalt-Reset [frühestens nach 400, spätesten nach 40000 Takten] [TA(2) signalisiert specific mode] ATR Betrieb Specific Mode [specific mode nicht akzeptiert] Warm-Reset [Initial Waiting Time überschritten,...] [PPS erfolgreich, ECHO PPS-Request] PPS Activation [ATR unbekannt] [TA(2) signalisiert negotiable mode] [negotiable mode nicht akzeptiert] Betrieb Negotiable Mode [direct nach ATR] Deactivation M. Leischner Chipkartensysteme I Folie 12
Erklärung der Begriffe Aktivierung: Inbetriebnahme der Chipkarte durch das Lesegerät. Kalt-Reset: Reset nach Aktivierung der Chipkarte Warm-Reset: Reset aus dem laufenden Betrieb. Chipkarte kann Kalt- und Warm-Reset unterscheiden. Deaktivierung: Abschalten der Chipkarte durch das Lesegerät. ATR (Answer-to-Reset): Aussenden einer asynchronen Bytefolge. Specific Mode: Betriebsart für den regulären Anwendungsbetrieb einer Chipkarte. Negotiable Mode: Betriebsart, in der Nachverhandlung des Protokolls möglich ist. PPS (Protocol and Parameter Selection): sendet PPS, im positiven Fall antwortet Chipkarte, indem es PPS unverändert zurücksendet. M. Leischner Chipkartensysteme I Folie 13 Initialisierungsprotokoll (ATR und PTS) Chipkarte Activation, Cold Reset ATR (Answer-to- Reset) [PTS notwendig] PTS-Requ [PTS möglich] PTS-Resp [Time-out PTS-Requ] Warmreset Kommando1 Antwort1 M. Leischner Chipkartensysteme I Folie 14
Scenario: Protokollumschaltung mit PTS Chipkarte Activation, Cold Reset ATR (mit Protokoll 1) PTS-Requ (Prot 2) PTS-Resp (Prot 2) Kommando1 Antwort1 M. Leischner Chipkartensysteme I Folie 15 Scenario: Protokollumschaltung mit Warm-Reset Chipkarte Activation, Cold Reset ATR (mit Protokoll 1) Warmreset ATR (mit Protokoll 2) Kommando1 Antwort1 M. Leischner Chipkartensysteme I Folie 16
Sending a Command Smart Card Reset ATR (Answer to Reset) [PTS necessary] PTS-Requ PTS-Resp command 1 response 1 command 2 response 2 M. Leischner Chipkartensysteme I Folie 17 Layered Communication Model for Smart Card Data Transfer OSI layer specification OSI layer 7 transfer of application data application layer ISO/IEC 7816-4 EMV GSM 11.11,... OSI layer 2 transfer of data frames data link layer ISO/IEC 7816-3 (T=0 / T=1) ISO/IEC 10536-4 (T=2) OSI layer 1 transfer of bits physical layer ISO/IEC 7816-3 M. Leischner Chipkartensysteme I Folie 18
Transmission Layer (Data Link Layer, Übertragungsschicht) Protokoll T=0 T=1 T=2 T=3 T=4 T=14 Norm ISO/IEC 7816-3 ISO/IEC 7816-3 Bedeutung halbduplex, asynchron byteorientiert halbduplex, asynchron blockorientiert vollduplex, asynchron blockorientiert (in Normierung) vollduplex halbduplex, asynchron byteorientiert Erweiterung von T=0 M. Leischner Chipkartensysteme I Folie 19 Structure of a T1 Transfer Block node address protocol control byte length field information field error dection code NAD PCB LEN APDU EDC 1 Byte 1 Byte 1 Byte 2.. 254 Byte 1..2 Byte prolog command APDU epilog The T1 protocol offers a transparent, block-oriented, asynchronous half-duplex protocol with error handling M. Leischner Chipkartensysteme I Folie 20
T1-Protokoll Timing Zeichenwartezeit (CWT): Blockwartezeit (BWT) Blockschutzzeit (BGT Blockverkettung: Entspricht der Fragmentierung bei IP. (erlaubt nur bei I-Blöcken) Fehlerbehandlung: Längenprüfungscode (XOR-Verknüpfung, Standard für T=1 Implementierungen) o. Ein CRC-Prüfsummenverfahren zum Teilerpolynom x**16+x**12+x*5+1 Zusätzlich wird noch ein Sendefolge/Empfangsfolgezähler modulo 2 eingesetzt. Die Fehlerbehandlung in drei Eskalationsstufen: Stufe 1: Bei Empfang eines fehlerhaften Blocks antworten mit einem R-Block, der die Wiederholung der Übertragung des letzten Blockes anfordert. Stufe 2: Führt Stufe 1 nicht zum Erfolg, so wird über einen S-Block eine Resynchronisationsanfrage an den Sender geschickt. Stufe 3: Auslösen eines Resets. Stufe 4: Nach dreimaligen Versuch: Fehlermeldung. M. Leischner Chipkartensysteme I Folie 21 Structure of a Command APDU class instruction parameter 1 Parameter 2 Length of data for command Length of data expected for response CLA INS P1 P2 Lc-Feld Data Le-Feld Header Body M. Leischner Chipkartensysteme I Folie 22
4 Fälle der APDU-Struktur Fall 1: Lc fehlt --> kein Datenfeld Le fehlt --> keine Daten in Antwort (nur SW1, SW2) Header Fall 2: Lc fehlt --> kein Datenfeld Header Le-Feld Fall 3: Le fehlt --> keine Daten in Antwort (nur SW1, SW2) Header Lc-Feld Data Fall 4: Daten in Kommando und Antwort Header Lc-Feld Data Le-Feld M. Leischner Chipkartensysteme I Folie 23 Sending a Response Smart Card Reset ATR (Answer to Reset) [PTS necessary] PTS-Requ PTS-Resp command 1 response 1 command 2 response 2 M. Leischner Chipkartensysteme I Folie 24
Structure of a Response-APDU status word 1 status word 2 Data SW1 SW2 Body (optional) Trailer M. Leischner Chipkartensysteme I Folie 25 Classification Scheme for the Return Code (SW1, SW2) return code process completed process aborted normal processing warning processing execution error checking error '61XX' '9000' '62XX' '63XX' '64XX' '65XX' '67XX'... '6FXX' EEPROM changed M. Leischner Chipkartensysteme I Folie 26