SOSSE Reference Manual

Generated by Doxygen 1.2.14

Wed Jul 9 16:22:07 2003

Contents

1 SOSSE - Simple Operating System for Smartcard Education 1

2 SOSSE Data Structure Index 18

3 SOSSE File Index 18

4 SOSSE Page Index 20

5 SOSSE Data Structure Documentation 20

6 SOSSE File Documentation 23

7 SOSSE Page Documentation 111

1 SOSSE - Simple Operating System for Smartcard Education

1.1 Overview

SOSSE is a simple operating system for smart cards which is opensource and free. It has been developed to provide a smart card platform for learning, experimenting and implementing inovative concepts. The hardware platform choosen for this project are the Funcards based on commercial-of-the-shelf AVR microcontrollers, because the hardware documentation is available without nondisclosure agreement.

1.2 Hardware

All of the currently supported cards use the AVR-Microcontrollers from Atmel. The are e.g. called Funcard, Jupiter or Pink card. The used AVRs are the AT90S2323, AT90S2343, AT90S8515 and AT90S8535. There are even a few boards with the ATmega161 available. The data sheets for all Atmel AVR microcontrollers are available on the Atmel website.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Figure 1: Connection scheme for the AVR cards.

The pinout of the AVR cards is as follows:

• C1 (VCC): Vcc

• C2 (RST): RESET

• C3 (CLK): XTAL

• C4: MOSI

• C5 (VSS): Vss

• C6: Not connected

• C7 (I/O): MISO

• C8: SCK

Additional to the smart cards, a programmer is needed. These are available at the same shops as the AVR cards.

1.3 Software

SOSSE has been developed using the GCC development tools. These are available at http://combio.de/avr/. There are the sources, binaries and RPMs for Linux and binaries for MS Windows.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

1.4 Design Decisions

Programming Language

The C programming language has been choosen instead of assembler, because:

• It is easier to understand C source code.

• Modern smart card operating systems are probably all written mostly in C. Who does want to write and verify 128kB assembler code?

• When new smart card architectures are available for SOSSE, these can be utilized more easily.

1.5 Building Instructions

Standard Build

1. Go to the src directory and edit config.h. This file contains the configuration data for the build process. The meaning of the options is described in the doxygen documention of config.h itself. (It is not possible to switch on all features, because then the code size is above 8kB.)

2. You can edit eedata.S if you want to change the EEPROM data loaded onto the AVR card. You might want to change the card serial number, the start value for the random number generator, the keys, the file permissions or the created files.

3. There are two defines in the Makefile, which could need editing. The first is the -mmcu setting in CC and the second is -mtiny-stack in CFLAGS. Adjust these to reflect your used AVR card.

4. To build the HEX files start make.

5. The resulting HEX files sosse.hex and eedata.hex (or BIN files sosse.bin and eedata.bin) have then to be loaded on the card with the programmer and an apropriate software. The destination for sosse.hex is the Flash and for eedata.hex the internal EEPROM.

Debugging

Test programms which run natively on the host operating system are built running:

make -f Makefile.emu

These can be used for comfortable debugging and testing using the normal GNU debugger. When the reset sequence is implemented, this can be used to simulate a SOSSE smart card via e.g. a Season interface.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

CT-API driver

Building

A virtual card sitting in a virtual reader can be build with:

make -f Makefile.ctapi

This builds a CT-API driver, which can be used to test applications and to debug using a normal debugger.

Supported CT-BCS commands

• EJECT ICC: Supported with functional unit ICC1. P2 is ignored.

• GET STATUS: Supported tag is 80. Possible card states are 01 and 05.

• REQUEST ICC: Supported with functional unit ICC1 and response data none and complete ATR. Display settings are ignored.

• RESET CT: Supported with functional unit CT and ICC1 and response data none and complete ATR. This command is the same as REQUEST ICC, but does support reseting the CT, which stops the ICC.

Proprietary command: EEPROM FILE

Header

CLA  INS  P1  P2  P3
20  E0  Flags  RFU  Length

Command data

Byte(s)  Description  Length
1 - Length  File name  Length

Status words

SW  Description

90 00

Command completed successfully

Description

This command sets the parameter for EEPROM loading and saving for the virtual card.

If bit 1 of P1 is set, the EEPROM is saved at stopping of the ICC and if bit 2 is set, the EEPROM loaded at starting of the ICC. The file name for this operation is specified in the data field of the command.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

The proprietary commands must be executed before a REQUEST ICC and RE-SET CT, because the parameters are held in RAM, which is separated by a fork at card reset. A success of the command means only, that the variables have correctly been set. It does not verify, that the file is createable, readable or writeable.

1.6 More Information and Download

The web page with up to date information about SOSSE is at:

http://www.mbsks.franken.de/sosse/

The download location of the SOSSE sources is at:

ftp://ftp.franken.de/pub/crypt/chipcards/sosse/

The documentation was generated using DoxyGen:

http://www.doxygen.org/

1.7 Special Files

These File are only used, when filesystem support is compiled in. Otherwise special absolut locations in EEPROM are used to hold the data.

EF Ext Auth

Path: 3F00FF00 Content:

• 16 Bytes Key

• 1 Byte Retry Counter (resets to 10)

EF Int Auth

Path: 3F00FF01 Content:

• 16 Bytes Key

• 1 Byte Retry Counter (unused)

EF PIN

Path: 3F00FF02 Content:

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

• 8 Bytes PIN

• 1 Byte Retry Counter (resets to 3)

• 8 Bytes PUK

• 1 Byte Retry Counter (resets to 10)

1.8 Commands

Write EEPROM. (Test command)

Header

CLA  INS  P1  P2  P3
80  02  Address high  Address low Length

Command data

Byte(s)  Description  Length

1 - Length Data to write to Address

Length

Status words

SW  Description

90 00

Command completed successfully

65 00 Memory failure (unsuccessful writing)

67 00  Wrong Lc

Description

This command can be used to directly write into EEPROM. The start address is specified in P1P2 and the data length in P3. If there exists an internal and external EEPROM, the address convention of the HAL is used. Currently the internal EEPROM is in the address range 0 - sizeof internal EEPROM. The external EEPROM starts directly afterwards.

This command should be disabled by setting CONF WITH TESTCMDS to 0 for a production version.

Data updates are NOT protected with transactions.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Read EEPROM. (Test command)

Header

CLA  INS  P1  P2  P3
80  04  Address high  Address low Length

Response data

Byte(s)  Description  Length

1 - Length Data read from Address

Length

Status words

SW  Description

90 00

Command completed successfully

Description

This command can be used to directly read from EEPROM. The start address is specified in P1P2 and the data length in P3. If there exists an internal and external EEPROM, the address convention of the HAL is used. Currently the internal EEPROM is in the address range 0 - sizeof internal EEPROM. The external EEPROM starts directly afterwards.

This command should be disabled by setting CONF WITH TESTCMDS to 0 for a production version.

LED Effects (Fun command)

Header

CLA  INS  P1  P2  P3
80  06  Effect  Parameter  00

Status words

SW  Description

90 00

Command completed successfully

Description

This command does control the LEDs present on some PCB AVR cards and shows some nice effects.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Effect type 0x01 does switch the LEDs specified in P2 on. Each bit controlls one LED. Which LED is controlled may be card dependent. Currently bits 0 - 6 control the leds beginning from the left, when looking down at them with the contacts to the top.

Effect type 0x02 does implement a runlight with the left 4 LED block. It may need adjustment on other cards to select the correct LEDs.

This command is only enabled when setting CONF WITH FUNNY to 1.

Change PIN.

Header

CLA  INS  P1  P2  P3
80  24  00  00  10

Command data

Byte(s)  Description  Length
1 - 8  Current PIN  8
9 - 16  New PIN  8

Status words

SW  Description

90 00

Command completed successfully

63 CX Verification failed, retry counter specified

67 00 Wrong Lc

69 83

Authentication method blocked

6A 86

Incorrect parameters P1-P2

6A 88

Referenced data not found

Description

This command changes the PIN of the card. The first four bytes of the data is the current PIN, which is checked for correctness. The second four bytes of the data is the new PIN, which will be written. On success the AUTH FLAG PIN bit in authstate is set, on fauilure it is cleared.

Warning: Currently the retry counter is not handled in a secure way. For more information see e.g. Rankl/Effing.

PIN update is protected with transactions.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Create File.

Header

CLA  INS  P1  P2  P3
80  E0  00  00  06

Command data

Byte(s)  Description  Length
1 - 2  Size  2
3 - 4  FID  2

5 File type (DF: 38, EF: 00)

1

6 Access conditions (DF: Create/Delete, EF: Update/Read)

1

Status words

SW  Description

90 00

Command completed successfully

67 00 Wrong Lc

69 82

Security status not satisfied

69 86 Command not allowed (no DF selected)

6A 80

Incorrect arameters in the data field

6A 84

Not enough free space in DF

6A 86

Incorrect parameters P1-P2

6A 89

File exists already

Description

This command creates an elementary or dedicated file. To succeed the current file must be a dedicated file or the master file and the access conditions for file creation must be fulfilled.

The data of the command is the file header. It consists of a 2-byte size, 2-byte FID, 1-byte type and 1-byte access conditions. Size can’t be 0000. The FID can’t be 3F00 or FFFF. Valid file types are 00 for EF and 38 for DF. The access conditions are described in the next tables.

File type  High Nibble  Low Nibble
DF  Create File  Delete File
EF  Update  Read

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Nibble Value

Access condition

0  Always
1  PIN verified

2

External Authentication key verified

3 PIN or External Authentication Key verified

4 PIN and External Authentication Key verified

F  Never

File header updates are protected with transactions.

Delete File.

Header

CLA  INS  P1  P2  P3
80  E4  00  00  02

Command data

Byte(s)  Description  Length
1 - 2  FID  2

Status words

SW  Description

90 00

Command completed successfully

67 00 Wrong Lc

69 82

Security status not satisfied

69 86 Command not allowed (no DF selected)

6A 82

File not found

6A 86

Incorrect parameters P1-P2

Description

The file with the specified FID is deleted from the current file, which must be a DF or the MF. Also the access conditions for delete must be satisfied and the specified file must be the last one in the DF/MF. Deletion of a DF, which contains EFs, is possible.

File header updates are protected with transactions.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

External Authentication.

Header

CLA  INS  P1  P2  P3
80  82  00  00  08

Command data

Byte(s)  Description  Length

1 - 8 Encrypted Challenge

8

Status words

SW  Description

90 00

Command completed successfully

63 CX Verification failed, retry counter specified

67 00 Wrong Lc

69 83

Authentication method blocked

69 85

Conditions of use not satisfied

6A 86

Incorrect parameters P1-P2

6A 88

Referenced data not found

Description

Directly before this command a 8 byte challenge must be fetched from the card with the Get Challenge command. This challenge must then be encrypted with the TEA algorithm and the External Authentication key. For authentication the resulting data must then be sent back via this command.

Warning: Currently the retry counter is not handled in a secure way. For more information see e.g. Rankl/Effing.

Get Challenge

Header

CLA  INS  P1  P2  P3
80  84  00  00  08

Response data

Byte(s)  Description  Length

1 - 8 Random Challenge

8

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Status words

SW  Description

90 00

Command completed successfully

67 00 Wrong Le

6A 86

Incorrect parameters P1-P2

Description

Returns a challenge usable for the External Authentication command, which must then be the next issued command.

Warning: On the current hardware this challenge is produced with a PRNG based on TEA. It is not evaluated, if the current mechanism is appropriate for this task.

Get Response.

Header

CLA  INS  P1  P2  P3
80  C0  00  00  Length

Response data after Internal Authenticate

Byte(s)  Description  Length

1 - 8 Internal Authentication key encrypted challenge

8

Response data after Select

Byte(s)  Description  Length
1 - 2  Size  2
3 - 4  FID  2

5 File type (DF: 38, EF: 00)

1

6 Access conditions

1

Status words

SW  Description

90 00

Command completed successfully

69 85

Wrong condition (No data available)

6A 86

Incorrect parameters P1-P2

6C XX  Wrong Le

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Description

This command fetches data from Internal Authentication and Select. These commands signal the availability of data with the status word 61XX. For more details about the data returned after a Select, see at the Create command.

Internal Authentication.

Header

CLA  INS  P1  P2  P3
80  88  00  Decrypt  08

This command decrypts the data if P2 is 01. This functionality is only enabled when CONF WITH DECRYPT is set to 1.

Command data

Byte(s)  Description  Length

1 - 8 Random Challenge

8

Status words

SW  Description

61 08 Command completed successfully (Data available)

67 00 Wrong Lc

69 85

Conditions of use not satisfied

6A 86

Incorrect parameters P1-P2

6A 88

Referenced data not found

Description

Provieds a random challenge to the card. It encryptes the challenge with TEA and the Internal Authentication key and makes it available via Get Response. For the successful execution either the PIN or the External Authentication key must have been successfully verified previously.

Because of possibility to decrypt data, this command can easily be used to implement some form of Remotely Keyed Encryption.

Read Binary.

Header

CLA  INS  P1  P2  P3
80  B0  Offset high  Offest low  Length

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Response data

Byte(s)  Description  Length
1 - Length  Data  Length

Status words

SW  Description

90 00

Command completed successfully

69 82

Security status not satisfied

69 86 Command not allowed (no EF selected)

6A 82

File not found

6A 84 File to short

6B 00 Wrong parameters (offset outside EF)

Description

Reads Lenght bytes from Offset of the currently selected EF.

Select File.

Header

CLA  INS  P1  P2  P3
80  A4  00  00  02

Command data

Byte(s)  Description  Length
1 - 2  FID  2

Status words

SW  Description

61 06

Command completed successfully

67 00 Wrong Lc

6A 82

File not found

6A 86

Incorrect parameters P1-P2

Description

It tries to select a file with the specified FID and searches for it in the following order:

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

1. EF in the current MF/DF

2. DF in MF

If FID is 3F00, the MF is always selected.

Unblock PIN.

Header

CLA  INS  P1  P2  P3
80  2C  00  00  10

Command data

Byte(s)  Description  Length
1 - 8  PUK  8
9 - 16  New PIN  8

Status words

SW  Description

90 00

Command completed successfully

63 CX Verification failed, retry counter specified

67 00 Wrong Lc

69 83

Authentication method blocked

6A 86

Incorrect parameters P1-P2

6A 88

Referenced data not found

Description

This command changes the PIN of the card and resets the retry counter of this PIN. The first eight bytes of the data is the PUK, which is checked for correctness. The second four bytes of the data is the new PIN, which will be written. On success the AUTH FLAG PIN bit in authstate is set, on fauilure it is cleared.

Warning: Currently the retry counter is not handled in a secure way. For more information see e.g. Rankl/Effing.

PIN update is protected with transactions.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Update Binary.

Header

CLA  INS  P1  P2  P3
80  D6  Offset high  Offset low  Length

Command data

Byte(s)  Description  Length
1 - Length  Data  Length

Status words

SW  Description

90 00

Command completed successfully

65 00 Memory failure (unsuccessful writing)

67 00 Wrong Le

69 82

Security status not satisfied

69 86 Command not allowed (no EF selected)

6A 82

File not found

6A 84 File to short

6B 00 Wrong parameters (offset outside EF)

Description

Writes Lenght bytes to Offset of the currently selected EF.

Data updates are NOT protected with transactions.

Verify Key

Header

CLA  INS  P1  P2  P3
80  2A  00  00  10

Command data

Byte(s)  Description  Length

1 - 16 External Authentication Key

16

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Status words

SW  Description

90 00

Command completed successfully

63 CX Verification failed, retry counter specified

67 00 Wrong Lc

69 83

Authentication method blocked

6A 86

Incorrect parameters P1-P2

6A 88

Referenced data not found

Description

Verifies the External Authentication key as 16 byte plain text in the data part of the command. On success the AUTH FLAG KEY bit in authstate is set, on failure it is cleared.

Warning: Currently the retry counter is not handled in a secure way. For more information see e.g. Rankl/Effing.

Verify PIN

Header

CLA  INS  P1  P2  P3
80  20  00  00  08

Command data

Byte(s)  Description  Length
1 - 8  PIN  8

Status words

SW  Description

90 00

Command completed successfully

63 CX Verification failed, retry counter specified

67 00 Wrong Lc

69 83

Authentication method blocked

6A 86

Incorrect parameters P1-P2

6A 88

Referenced data not found

Description

This command verifies the PIN. The four data bytes contain the user supplied PIN, which is checked for correctness. On success the AUTH FLAG PIN bit in

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

authstate is set, on fauilure it is cleared.

Warning: Currently the retry counter is not handled in a secure way. For more information see e.g. Rankl/Effing.

1.9 Developers

• Matthias Bruestle <m@mbsks.franken.de>

1.10 License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABIL-ITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

2 SOSSE Data Structure Index

2.1 SOSSE Data Structures

Here are the data structures with brief descriptions:

s finfo (File info struct. This is directly written as a file header in the file system) 20

s fpath (File path specifier) 21

s fstream (Stream struct) 22

3 SOSSE File Index

3.1 SOSSE File List

Here is a list of all files with brief descriptions:

auth.c (Authentication functions) 23

auth.h (Authentication declarations) 27

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

authtest.c (Test program for authentication functions) 34 commands.c (Commands) 35 commands.h (Command declarations) 38 config.h (Configuration settings) 43 crypt.h (Crypto declarations) 51 ctapi.c (Virtual CT-API library) 52 ctapi.h (Declarations for virtual CT-API library) 55 fs.c (File system) 59 fs.h (File system declarations) 63 fstest.c (Test program for file system functions) 69 fstream.c (File stream functions) 70 fstream.h (File stream declarations) 72 hal-emu.c (HAL emulation for Linux) 74 hal.c (HAL (Hardware Abstraction Layer)) 77 hal.h (HAL (Hardware Abstraction Layer) declarations) 80 log.c (Logging functions) 83 log.h (Logging declarations) 84 main.c (Main() function with command loop) 86 main.h (Main() declarations and documentation) 87 newdes-sk.c 87 newdes-sk.h (NEWDES-SK declarations) 87 skipjack.c (Skipjack declarations) 88 skipjack.h (Skipjack declarations) 89 sw.c (Errno functions) 90 sw.h (Errno declarations) 91 t0.c (T=0 functions) 94 t0.h (T=0 declarations) 97

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

tea.c (TEA functions) 101 tea.h (TEA declarations) 102 tools.c (Tool functions) 104 tools.h (Tool declarations) 104 transaction.c (Transaction functions) 106 transaction.h (Transaction declarations) 107 types.h (Type declarations) 109

4 SOSSE Page Index

4.1 SOSSE Related Pages

Here is a list of all related documentation pages:

Todo List 111

5 SOSSE Data Structure Documentation

5.1 s finfo Struct Reference

File info struct. This is directly written as a file header in the file system.

#include <fs.h>

Data Fields

• iu16 size

Size of the file content.

• iu16 fid

ID of the file.

• iu8 type

Type of the file. (FS TYPE ∗).

• iu8 ac [1]

Access conditions of the file. (See CREATE FILE dox.).

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

5.1.1 Detailed Description

File info struct. This is directly written as a file header in the file system.

5.1.2 Field Documentation

5.1.2.1 iu8 s finfo::ac[1] Access conditions of the file. (See CREATE FILE dox.).

5.1.2.2 iu16 s finfo::fid ID of the file.

5.1.2.3 iu16 s finfo::size Size of the file content.

5.1.2.4 iu8 s finfo::type Type of the file. (FS TYPE ∗). The documentation for this struct was generated from the following file:

• fs.h

5.2 s fpath Struct Reference

File path specifier.

#include <fs.h>

Data Fields

• iu16 df

ID of one DF level. Set to FFFF if unused.

• iu16 ef

IF of the EF. Set to FFFF if unused.

5.2.1 Detailed Description

File path specifier.

Todo: There is probably a potential for simplification, when the file type (DF/EF) is not handled so rigid.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

5.2.2 Field Documentation

5.2.2.1 iu16 s fpath::df ID of one DF level. Set to FFFF if unused.

5.2.2.2 iu16 s fpath::ef IF of the EF. Set to FFFF if unused. The documentation for this struct was generated from the following file:

• fs.h

5.3 s fstream Struct Reference

Stream struct.

#include <fstream.h>

Data Fields

• iu16 start

EEPROM start address of the stream.

• iu16 size

Data size of the stream.

• iu16 pos

Current position in the stream.

5.3.1 Detailed Description

Stream struct.

5.3.2 Field Documentation

5.3.2.1 iu16 s fstream::pos Current position in the stream.

5.3.2.2 iu16 s fstream::size Data size of the stream.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

5.3.2.3 iu16 s fstream::start EEPROM start address of the stream. The documentation for this struct was generated from the following file:

• fstream.h

6 SOSSE File Documentation

6.1 auth.c File Reference

Authentication functions.

#include <config.h>
#include <auth.h>
#include <crypt.h>
#include <fs.h>
#include <fstream.h>
#include <hal.h>
#include <string.h>
#include <sw.h>
#include <tea.h>
#include <tools.h>
#include <transaction.h>
#include <types.h>

Functions

• bool auth init (void)

Initialize authentication variables.

• bool auth checkAc (iu8 ac)

Check fullfillment of access condition.

• bool auth getCheckPinLen (iu8 pintype, iu8 pinlen, iu16 ∗addr, iu8

∗len, iu16 ∗rcaddr, iu8 ∗maxret)

Verifies length of PIN and returns addresses of PIN in EEPROM.

• bool auth setPin (iu8 pintype, iu8 ∗pin, iu8 pinlen)

Write PIN, PUK, External Authentication key or Internal Authentication key.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

• bool auth verifyPin (iu8 pintype, iu8 ∗pin, iu8 pinlen)

Verifies PIN, PUK or External Authentication key and sets flags in authstate.

• bool auth getChallenge (iu8 ∗dst, iu8 rndlen)

Returns 8 byte challenge for External Authentication.

• bool auth createVerifyCryptogram (iu8 ∗cry, iu8 crylen, bool cre-

ate, bool enc)

Encrypt or decrypt challenge or verify cryptogram.

Variables

• iu8 challenge [CRYPT BLOCK LEN]

Value of the last with Get Challenge fetched random challenge.

• iu8 challvalidity

• iu8 authstate

Variable indicating current authentication state.

6.1.1 Detailed Description

Authentication functions.

Id: auth.c,v 1.21 2003/03/30 19:43:15 m Exp

6.1.2 Function Documentation

6.1.2.1 bool auth checkAc (iu8 ac) Check fullfillment of access condition. This function checks, if the current setting of authstate fullfills the condition specified with ac.

Parameters: ac A nibble specifying an access condition.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.1.2.2 bool auth createVerifyCryptogram (iu8 ∗ cry, iu8 crylen, bool create, bool enc)

Encrypt or decrypt challenge or verify cryptogram.

To include the decryption process CONF WITH DECRYPT must be set to 1.

Parameters: cry Pointer to byte array, which supplies challenge and which is used to return the encrypted or decrypted challenge or a cryptogram.

crylen Length of challenge or cryptogram.

create If set to TRUE, a challenge is processed, else a cryptogram is verified.

enc If CONF WITH DECRYPT is not set to 1, this has no effect. Otherwise, if TRUE encrypt the challenge, else decrypt it. If create is FALSE, this parameter is ignored.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.1.2.3 bool auth getChallenge (iu8 ∗ dst, iu8 rndlen)

Returns 8 byte challenge for External Authentication.

The challenge is also written to the challenge array and challvalidity is set to 2.

Parameters: dst Destination byte array.

rndlen Length of requested data. This must be 8.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.1.2.4 bool auth getCheckPinLen (iu8 pintype, iu8 pinlen, iu16 ∗ addr, iu8 ∗ len, iu16 ∗ rcaddr, iu8 ∗ maxret)

Verifies length of PIN and returns addresses of PIN in EEPROM.

This functions does depending on pintype:

• Check the length of the PIN or key.

• Return the address of the PIN or key in EEPROM.

• Return the length of the PIN or key in EEPROM.

• Return the address of the retry counter in EEPROM.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

• Return the default max. value for the retry counter.

Parameters: pintypePIN type. One of the PIN TYPE defines.

pinlen Length of supplied PIN or key.

addr Returns the address of the PIN or key in EEPROM. len Returns the length ofthe PIN or key in EEPROM. rcaddr Returns the address of the retry counter for the PIN or key. maxret Returns the default max. value for the retry counter.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.1.2.5 bool auth init (void) Initialize authentication variables. This function resets authstate and challvalidity. It must be called after reset.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.1.2.6 bool auth setPin (iu8 pintype, iu8 ∗ pin, iu8 pinlen) Write PIN, PUK, External Authentication key or Internal Authentication key. The process is secured by transactions.

Parameters: pintypeType of the PIN/Key. May be one of the PIN TYPE ∗ defines. pin Pointer to byte array containing PIN/Key. pinlen Length of PIN/Key.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.1.2.7 bool auth verifyPin (iu8 pintype, iu8 ∗ pin, iu8 pinlen) Verifies PIN, PUK or External Authentication key and sets flags in authstate. The update of the retry counter is secured by transactions. Warning: Currently the retry counter is not handled in a secure way. For more information see e.g. Rankl/Effing.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Parameters: pintypeType of the PIN/Key. May be one of the PIN TYPE ∗ defines. pin Pointer to byte array containing PIN/Key. pinlen Length of PIN/Key.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.1.3 Variable Documentation

6.1.3.1 iu8 authstate Variable indicating current authentication state. Single bit flags indicate, which authorization process has been successful. The flag is cleared, at the reset of the card and after unsuccessful authorization processes. Valid flags are:

• AUTH FLAG PIN

• AUTH FLAG KEY

6.1.3.2 iu8 challenge[CRYPT BLOCK LEN] Value of the last with Get Challenge fetched random challenge.

6.1.3.3 iu8 challvalidity

6.2 auth.h File Reference

Authentication declarations.

#include <types.h>

Defines

• #define AUTH FLAG PIN 0x01

Flag for authstate signalling a successful PIN verification.

• #define AUTH FLAG KEY 0x02

Flag for authstate signalling a successful external authentication or key verification.

• #define AUTH AC ALW 0x0

Access Condition: Always.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.2 auth.h File Reference  28

• #define AUTH AC PIN 0x1

Access Condition: PIN.

• #define AUTH AC ADM 0x2

Access Condition: Key.

• #define AUTH AC POA 0x3

Access Condition: PIN or Key.

• #define AUTH AC PAA 0x4

Access Condition: PIN and Key.

• #define AUTH AC NEV 0xF

Access Condition: Never.

• #define PIN MAX RETRIES 3

Default max. retries for PIN.

• #define PUK MAX RETRIES 10

Default max. retries for PUK.

• #define PIN TYPE PIN 0

PIN type: PIN.

• #define PIN TYPE PUK 1

PIN type: PUK.

• #define PIN TYPE EXT 2

PIN type: Key for external authentication.

• #define PIN TYPE INT 3

PIN type: Key for internal authentication.

• #define KEY MAX RETRIES 10

Default max. retries for keys.

• #define AUTH FID EXTAUTH 0xFF00

FID for file with external authentication key.

• #define AUTH FID INTAUTH 0xFF01

FID for file with internal authentication key.

• #define AUTH FID PINPUK 0xFF02

FID for file with PIN and PUK.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Functions

• bool auth init (void)

Initialize authentication variables.

• bool auth checkAc (iu8 ac)

Check fullfillment of access condition.

• bool auth getCheckPinLen (iu8 pintype, iu8 pinlen, iu16 ∗addr, iu8

∗len, iu16 ∗rcaddr, iu8 ∗maxret)

Verifies length of PIN and returns addresses of PIN in EEPROM.

• bool auth setPin (iu8 pintype, iu8 ∗pin, iu8 pinlen)

Write PIN, PUK, External Authentication key or Internal Authentication key.

• bool auth verifyPin (iu8 pintype, iu8 ∗pin, iu8 pinlen)

Verifies PIN, PUK or External Authentication key and sets flags in authstate.

• bool auth getChallenge (iu8 ∗dst, iu8 rndlen)

Returns 8 byte challenge for External Authentication.

• bool auth createVerifyCryptogram (iu8 ∗cry, iu8 crylen, bool cre-

ate, bool enc)

Encrypt or decrypt challenge or verify cryptogram.

Variables

• iu8 challvalidity

Validity of challenge.

6.2.1 Detailed Description

Authentication declarations. Here are the declarations and definitions for the authentication functions. The authentication types supported are:

• PIN/PUK

• External Authentication

• Internal Authentication

Todo: Here are certainly some optimizations possible to reduce code size.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Id: auth.h,v 1.11 2002/12/22 15:42:55 m Exp

6.2.2 Define Documentation

6.2.2.1 #define AUTH AC ADM 0x2 Access Condition: Key.

6.2.2.2 #define AUTH AC ALW 0x0 Access Condition: Always.

6.2.2.3 #define AUTH AC NEV 0xF Access Condition: Never.

6.2.2.4 #define AUTH AC PAA 0x4 Access Condition: PIN and Key.

6.2.2.5 #define AUTH AC PIN 0x1 Access Condition: PIN.

6.2.2.6 #define AUTH AC POA 0x3 Access Condition: PIN or Key.

6.2.2.7 #define AUTH FID EXTAUTH 0xFF00 FID for file with external authentication key. It is only searched for the file in the MF and not in any DF.

6.2.2.8 #define AUTH FID INTAUTH 0xFF01 FID for file with internal authentication key. It is only searched for the file in the MF and not in any DF.

6.2.2.9 #define AUTH FID PINPUK 0xFF02 FID for file with PIN and PUK. It is only searched for the file in the MF and not in any DF.

6.2.2.10 #define AUTH FLAG KEY 0x02 Flag for authstate signalling a successful external authentication or key verification.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.2.2.11 #define AUTH FLAG PIN 0x01 Flag for authstate signalling a successful PIN verification.

6.2.2.12 #define KEY MAX RETRIES 10 Default max. retries for keys.

6.2.2.13 #define PIN MAX RETRIES 3 Default max. retries for PIN.

6.2.2.14 #define PIN TYPE EXT 2 PIN type: Key for external authentication.

6.2.2.15 #define PIN TYPE INT 3 PIN type: Key for internal authentication.

6.2.2.16 #define PIN TYPE PIN 0 PIN type: PIN.

6.2.2.17 #define PIN TYPE PUK 1 PIN type: PUK.

6.2.2.18 #define PUK MAX RETRIES 10 Default max. retries for PUK.

6.2.3 Function Documentation

6.2.3.1 bool auth checkAc (iu8 ac) Check fullfillment of access condition. This function checks, if the current setting of authstate fullfills the condition specified with ac.

Parameters: ac A nibble specifying an access condition.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.2.3.2 bool auth createVerifyCryptogram (iu8 ∗ cry, iu8 crylen, bool create, bool enc)

Encrypt or decrypt challenge or verify cryptogram.

To include the decryption process CONF WITH DECRYPT must be set to 1.

Parameters: cry Pointer to byte array, which supplies challenge and which is used to return the encrypted or decrypted challenge or a cryptogram.

crylen Length of challenge or cryptogram.

create If set to TRUE, a challenge is processed, else a cryptogram is verified.

enc If CONF WITH DECRYPT is not set to 1, this has no effect. Otherwise, if TRUE encrypt the challenge, else decrypt it. If create is FALSE, this parameter is ignored.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.2.3.3 bool auth getChallenge (iu8 ∗ dst, iu8 rndlen)

Returns 8 byte challenge for External Authentication.

The challenge is also written to the challenge array and challvalidity is set to 2.

Parameters: dst Destination byte array.

rndlen Length of requested data. This must be 8.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.2.3.4 bool auth getCheckPinLen (iu8 pintype, iu8 pinlen, iu16 ∗ addr, iu8 ∗ len, iu16 ∗ rcaddr, iu8 ∗ maxret)

Verifies length of PIN and returns addresses of PIN in EEPROM.

This functions does depending on pintype:

• Check the length of the PIN or key.

• Return the address of the PIN or key in EEPROM.

• Return the length of the PIN or key in EEPROM.

• Return the address of the retry counter in EEPROM.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

• Return the default max. value for the retry counter.

Parameters: pintypePIN type. One of the PIN TYPE defines.

pinlen Length of supplied PIN or key.

addr Returns the address of the PIN or key in EEPROM. len Returns the length ofthe PIN or key in EEPROM. rcaddr Returns the address of the retry counter for the PIN or key. maxret Returns the default max. value for the retry counter.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.2.3.5 bool auth init (void) Initialize authentication variables. This function resets authstate and challvalidity. It must be called after reset.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.2.3.6 bool auth setPin (iu8 pintype, iu8 ∗ pin, iu8 pinlen) Write PIN, PUK, External Authentication key or Internal Authentication key. The process is secured by transactions.

Parameters: pintypeType of the PIN/Key. May be one of the PIN TYPE ∗ defines. pin Pointer to byte array containing PIN/Key. pinlen Length of PIN/Key.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.2.3.7 bool auth verifyPin (iu8 pintype, iu8 ∗ pin, iu8 pinlen) Verifies PIN, PUK or External Authentication key and sets flags in authstate. The update of the retry counter is secured by transactions. Warning: Currently the retry counter is not handled in a secure way. For more information see e.g. Rankl/Effing.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Parameters: pintypeType of the PIN/Key. May be one of the PIN TYPE ∗ defines. pin Pointer to byte array containing PIN/Key. pinlen Length of PIN/Key.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.2.4 Variable Documentation

6.2.4.1 iu8 challvalidity Validity of challenge. The initial value if challvalidity is 2. This is decremented at the start of the command loop, so that it is 1 at the command following a Get Challenge.

6.3 authtest.c File Reference

Test program for authentication functions.

#include <stdio.h>
#include <config.h>
#include <auth.h>
#include <sw.h>
#include <fs.h>
#include <hal.h>
#include <transaction.h>
#include <netinet/in.h>

Functions • int main (int argc, char ∗argv[ ])

Variables • iu8 authstate

• iu32 challenge [2]

Value of the last with Get Challenge fetched random challenge.

• iu8 challvalidity

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.3.1 Detailed Description

Test program for authentication functions.

Id: authtest.c,v 1.11 2002/12/22 15:42:55 m Exp

6.3.2 Function Documentation

6.3.2.1 int main (int argc, char ∗ argv[ ])

6.3.3 Variable Documentation

6.3.3.1 iu8 authstate

6.3.3.2 iu32 challenge[2] Value of the last with Get Challenge fetched random challenge.

6.3.3.3 iu8 challvalidity

6.4 commands.c File Reference

Commands.

#include <auth.h>
#include <hal.h>
#include <commands.h>
#include <config.h>
#include <crypt.h>
#include <fs.h>
#include <log.h>
#include <stddef.h>
#include <string.h>
#include <sw.h>
#include <t0.h>
#include <tools.h>
#include <types.h>

Defines • #define pinssize (PIN LEN+PIN LEN)

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

• #define pin1len PIN LEN

Functions

• void cmd write (void)

Write EEPROM. (Test command).

• void cmd read (void)

Read EEPROM. (Test command).

• void cmd changeUnblockPIN (void)

Change or Unblock PIN.

• void cmd create (void)

Create File.

• void cmd delete (void)

Delete File.

• void cmd extAuth (void)

External Authentication.

• void cmd getChallenge (void)

Get Challenge.

• void cmd intAuth (void)

Internal Authentication.

• void cmd readBinary (void)

Read Binary.

• void cmd select (void)

Select File.

• void cmd updateBinary (void)

Update Binary.

• void cmd verifyKeyPIN (void)

Verify Key/Verify PIN.

6.4.1 Detailed Description

Commands. The documentation of the commands is on the main page of the doxygen documentation.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Id: commands.c,v 1.30 2003/05/10 17:26:58 m Exp 6.4.2 Define Documentation 6.4.2.1 #define pin1len PIN LEN 6.4.2.2 #define pinssize (PIN LEN+PIN LEN) 6.4.3 Function Documentation 6.4.3.1 void cmd changeUnblockPIN (void) Change or Unblock PIN. 6.4.3.2 void cmd create (void) Create File. 6.4.3.3 void cmd delete (void) Delete File. 6.4.3.4 void cmd extAuth (void) External Authentication. 6.4.3.5 void cmd getChallenge (void) Get Challenge. 6.4.3.6 void cmd intAuth (void) Internal Authentication. 6.4.3.7 void cmd read (void) Read EEPROM. (Test command). 6.4.3.8 void cmd readBinary (void) Read Binary. 6.4.3.9 void cmd select (void) Select File.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.4.3.10 void cmd updateBinary (void) Update Binary.

6.4.3.11 void cmd verifyKeyPIN (void) Verify Key/Verify PIN. This function is a combined implementation of Verify Key and Verify PIN. This is done to save code size.

6.4.3.12 void cmd write (void) Write EEPROM. (Test command).

6.5 commands.h File Reference

Command declarations.

Defines

• #define CLA PROP 0x80

CLA byte: Proprietary.

• #define INS WRITE 0x02

INS byte: Write EEPROM.

• #define INS READ 0x04

INS byte: Read EEPROM.

• #define INS LED 0x06

INS byte: LED Effects.

• #define INS CHANGE PIN 0x24

INS byte: Change PIN.

• #define INS CREATE 0xE0

INS byte: Create File.

• #define INS DELETE 0xE4

INS byte: Delete File.

• #define INS EXTERNAL AUTH 0x82

INS byte: External Authentication.

• #define INS GET CHALLENGE 0x84

INS byte: Get Challenge.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

• #define INS GET RESPONSE 0xC0

INS byte: Get Response.

• #define INS INTERNAL AUTH 0x88

INS byte: Internal Authentication.

• #define INS READ BINARY 0xB0

INS byte: Read Binary.

• #define INS SELECT 0xA4

INS byte: Select File.

• #define INS UNBLOCK PIN 0x2C

INS byte: Unblock PIN.

• #define INS UPDATE BINARY 0xD6

INS byte: Update Binary.

• #define INS VERIFY KEY 0x2A

INS byte: Verify Key.

• #define INS VERIFY PIN 0x20

INS byte: Verify PIN.

Functions

• void cmd write (void)

Write EEPROM. (Test command).

• void cmd read (void)

Read EEPROM. (Test command).

• void cmd led (void)

LED Effects.

• void cmd changeUnblockPIN (void)

Change or Unblock PIN.

• void cmd create (void)

Create File.

• void cmd delete (void)

Delete File.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

• void cmd extAuth (void)

External Authentication.

• void cmd getChallenge (void)

Get Challenge.

• void cmd getResponse (void)

Get Response.

• void cmd intAuth (void)

Internal Authentication.

• void cmd readBinary (void)

Read Binary.

• void cmd select (void)

Select File.

• void cmd updateBinary (void)

Update Binary.

• void cmd verifyKeyPIN (void)

Verify Key/Verify PIN.

Variables

• iu8 resplen

Valid data in response array. Invalid if zero.

6.5.1 Detailed Description

Command declarations. The documentation of the commands is on the main page of the doxygen documentation.

Id: commands.h,v 1.15 2002/12/22 15:42:55 m Exp

6.5.2 Define Documentation

6.5.2.1 #define CLA PROP 0x80 CLA byte: Proprietary.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.5.2.2 #define INS CHANGE PIN 0x24 INS byte: Change PIN.

6.5.2.3 #define INS CREATE 0xE0 INS byte: Create File.

6.5.2.4 #define INS DELETE 0xE4 INS byte: Delete File.

6.5.2.5 #define INS EXTERNAL AUTH 0x82 INS byte: External Authentication.

6.5.2.6 #define INS GET CHALLENGE 0x84 INS byte: Get Challenge.

6.5.2.7 #define INS GET RESPONSE 0xC0 INS byte: Get Response.

6.5.2.8 #define INS INTERNAL AUTH 0x88 INS byte: Internal Authentication.

6.5.2.9 #define INS LED 0x06 INS byte: LED Effects.

6.5.2.10 #define INS READ 0x04 INS byte: Read EEPROM.

6.5.2.11 #define INS READ BINARY 0xB0 INS byte: Read Binary.

6.5.2.12 #define INS SELECT 0xA4 INS byte: Select File.

6.5.2.13 #define INS UNBLOCK PIN 0x2C INS byte: Unblock PIN.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.5.2.14 #define INS UPDATE BINARY 0xD6 INS byte: Update Binary.

6.5.2.15 #define INS VERIFY KEY 0x2A INS byte: Verify Key.

6.5.2.16 #define INS VERIFY PIN 0x20 INS byte: Verify PIN.

6.5.2.17 #define INS WRITE 0x02 INS byte: Write EEPROM.

6.5.3 Function Documentation

6.5.3.1 void cmd changeUnblockPIN (void) Change or Unblock PIN.

6.5.3.2 void cmd create (void) Create File.

6.5.3.3 void cmd delete (void) Delete File.

6.5.3.4 void cmd extAuth (void) External Authentication.

6.5.3.5 void cmd getChallenge (void) Get Challenge.

6.5.3.6 void cmd getResponse (void) Get Response.

6.5.3.7 void cmd intAuth (void) Internal Authentication.

6.5.3.8 void cmd led (void) LED Effects.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.5.3.9 void cmd read (void) Read EEPROM. (Test command).

6.5.3.10 void cmd readBinary (void) Read Binary.

6.5.3.11 void cmd select (void) Select File.

6.5.3.12 void cmd updateBinary (void) Update Binary.

6.5.3.13 void cmd verifyKeyPIN (void) Verify Key/Verify PIN. This function is a combined implementation of Verify Key and Verify PIN. This is done to save code size.

6.5.3.14 void cmd write (void) Write EEPROM. (Test command).

6.5.4 Variable Documentation

6.5.4.1 iu8 resplen Valid data in response array. Invalid if zero.

6.6 config.h File Reference

Configuration settings.

Defines

• #define CONF IODATA SIZE 256

Max. I/O data size.

• #define CONF WITH FILESYSTEM 1

En-/disables file system.

• #define CONF WITH RECORD FILES 0

En-/disables support for fixed record files.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.6 config.h File Reference  44

• #define CONF WITH TRANSACTIONS 1

En-/disables transactions.

• #define CONF WITH TESTCMDS 1

En-/disables test commands.

• #define CONF WITH DELETECMD 1

En-/disables DELETE.

• #define CONF WITH CREATECMD 1

En-/disables CREATE.

• #define CONF WITH PINAUTH 1

En-/disables PIN authentication functions.

• #define CONF WITH PINCMDS 1

En-/disables PIN commands.

• #define CONF WITH KEYAUTH 1

En-/disables key authentication functions.

• #define CONF WITH KEYCMDS 1

En-/disables key related commands.

• #define CONF WITH I2CEEPROM 1

En-/disables support for the external I2C EEPROM.

• #define CONF WITH DECRYPT 1

En-/disables support for decryption.

• #define CONF WITH LOGGING 1

En-/disables support for logging.

• #define CONF WITH RETCODEMGR 0

En-/disables return code manager.

• #define CONF WITH FUNNY 0

En-/disables funny commands.

• #define CONF WITH TRNG 0

En-/disables true random generator. Highly experimental!.

• #define CONF WITH CRYPT ALGO 0

Set crypto algorithm.

• #define CARD STATE ADDR 0x0000

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.6 config.h File Reference  45

EEPROM address of the state of the card.

• #define ATR LEN ADDR (CARD STATE ADDR+1)

EEPROM address of the ATR length.

• #define ATR MAXLEN 28

Max. length of the ATR.

• #define ATR ADDR (ATR LEN ADDR+1)

EEPROM address of the ATR.

• #define SERNUM ADDR (ATR ADDR+ATR MAXLEN)

EEPROM address of the serial number of the card.

• #define SERNUM LEN 8

Length of the serial number.

• #define RAND STATE ADDR (SERNUM ADDR+SERNUM -

LEN)

EEPROM address of the state of the PRNG.

• #define RAND STATE LEN 8+8+16

Length of the state of the PRNG. (Counter[8], State[8], Key[16]).

• #define  TRANSAC STATE ADDR  (RAND STATE -

ADDR+RAND STATE LEN)

EEPROM address of the transaction state.

• #define  TRANSAC DATA ADDR  (TRANSAC STATE -

ADDR+1)

EEPROM address of the transaction data.

• #define TRANSAC DATA LEN 19

Length of the transaction data.

• #define ADM KEY LEN 16

Length of the External Authentication key.

• #define INT KEY LEN 16

Length of the Internal Authentication key.

• #define PIN LEN 8

Length of the PIN.

• #define PUK LEN 8

Length of the PUK.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

• #define DATA END 1 (TRANSAC DATA ADDR+TRANSAC -

DATA LEN)

Dummy address to handle the ifdefs here.

• #define FS START PTR ADDR DATA END 1

EEPROM address of pointer to the file system start.

• #define ENDIAN LITTLE

This is a little endian architecture.

• #define EEPROM SIZE 0x200

Size of the internal EEPROM.

• #define RAM SIZE 0x200

Size of the RAM.

• #define CHIP 0x01

Chip ID.

• #define ESIZ 0x03

External EEPROM ID.

• #define ARCH avr2

AVR architecture. Needed for assembler.

6.6.1 Detailed Description

Configuration settings.

Id: config.h,v 1.28 2003/05/10 17:26:58 m Exp

6.6.2 Define Documentation

6.6.2.1 #define ADM KEY LEN 16 Length of the External Authentication key.

6.6.2.2 #define ARCH avr2 AVR architecture. Needed for assembler.

6.6.2.3 #define ATR ADDR (ATR LEN ADDR+1) EEPROM address of the ATR.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.6.2.4 #define ATR LEN ADDR (CARD STATE ADDR+1) EEPROM address of the ATR length.

6.6.2.5 #define ATR MAXLEN 28 Max. length of the ATR.

6.6.2.6 #define CARD STATE ADDR 0x0000 EEPROM address of the state of the card. This is currently unused. Warning: When using interrupts on the AVR, this byte may accidently be changed. See errata sheets of AVR.

6.6.2.7 #define CHIP 0x01 Chip ID.

6.6.2.8 #define CONF IODATA SIZE 256 Max. I/O data size.

6.6.2.9 #define CONF WITH CREATECMD 1 En-/disables CREATE.

6.6.2.10 #define CONF WITH CRYPT ALGO 0 Set crypto algorithm.

• 0: TEA – 1: Skipjack

– 2: NEWDES-SK

6.6.2.11 #define CONF WITH DECRYPT 1 En-/disables support for decryption. If set to 1, support for decryption side of the cryptographic algorithms are included.

6.6.2.12 #define CONF WITH DELETECMD 1 En-/disables DELETE.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.6.2.13 #define CONF WITH FILESYSTEM 1 En-/disables file system.

Todo: Make this define something happen.

6.6.2.14 #define CONF WITH FUNNY 0 En-/disables funny commands. If set to 1, funny commands are included.

6.6.2.15 #define CONF WITH I2CEEPROM 1 En-/disables support for the external I2C EEPROM.

6.6.2.16 #define CONF WITH KEYAUTH 1 En-/disables key authentication functions. If set to 1, functions impelementing calculations with challenges are included. This is a requirement for CONF WITH KEY CMDS.

6.6.2.17 #define CONF WITH KEYCMDS 1 En-/disables key related commands. If set to 1, commands EXTERNAL KEYENTIFICATION, GET CHAL-LENGE, INTERNAL KEYENTIFICATION and VERIFY KEY are included.

6.6.2.18 #define CONF WITH LOGGING 1 En-/disables support for logging. If set to 1, support for logging is included.

6.6.2.19 #define CONF WITH PINAUTH 1 En-/disables PIN authentication functions. If set to 1, functions to set and test PIN and PUK are included. This is a requirement for CONF WITH PINCMDS.

6.6.2.20 #define CONF WITH PINCMDS 1 En-/disables PIN commands. If set to 1, commands CHANGE PIN and VERIFY PIN are included.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.6.2.21 #define CONF WITH RECORD FILES 0 En-/disables support for fixed record files.

6.6.2.22 #define CONF WITH RETCODEMGR 0 En-/disables return code manager. If set to 1, the return code manager is included. This increases code size on the AVR.

6.6.2.23 #define CONF WITH TESTCMDS 1 En-/disables test commands. If set to 1, commands READ EEPROM and WRITE EEPROM are included.

6.6.2.24 #define CONF WITH TRANSACTIONS 1 En-/disables transactions.

6.6.2.25 #define CONF WITH TRNG 0 En-/disables true random generator. Highly experimental!. If set to 1, a true random number generator is included. This is currently only for test purposes and highly experimental!

6.6.2.26 #define  DATA END 1  (TRANSAC DATA -

ADDR+TRANSAC DATA LEN) Dummy address to handle the ifdefs here.

6.6.2.27 #define EEPROM SIZE 0x200 Size of the internal EEPROM.

6.6.2.28 #define ENDIAN LITTLE This is a little endian architecture.

6.6.2.29 #define ESIZ 0x03 External EEPROM ID.

6.6.2.30 #define FS START PTR ADDR DATA END 1 EEPROM address of pointer to the file system start.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.6.2.31 #define INT KEY LEN 16 Length of the Internal Authentication key.

6.6.2.32 #define PIN LEN 8 Length of the PIN.

6.6.2.33 #define PUK LEN 8 Length of the PUK.

6.6.2.34 #define RAM SIZE 0x200 Size of the RAM.

6.6.2.35 #define  RAND STATE ADDR  (SERNUM -

ADDR+SERNUM LEN) EEPROM address of the state of the PRNG.

6.6.2.36 #define RAND STATE LEN 8+8+16 Length of the state of the PRNG. (Counter[8], State[8], Key[16]).

6.6.2.37 #define  SERNUM ADDR  (ATR ADDR+ATR -

MAXLEN) EEPROM address of the serial number of the card.

6.6.2.38 #define SERNUM LEN 8 Length of the serial number.

6.6.2.39 #define TRANSAC DATA ADDR (TRANSAC STATE - ADDR+1) EEPROM address of the transaction data.

6.6.2.40 #define TRANSAC DATA LEN 19 Length of the transaction data.

6.6.2.41 #define TRANSAC STATE ADDR (RAND STATE - ADDR+RAND STATE LEN) EEPROM address of the transaction state.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.7 crypt.h File Reference

Crypto declarations.

#include <config.h>
#include <sw.h>
#include <string.h>
#include <types.h>
#include <tea.h>

Defines

• #define CRYPT ALGO TEA 0

Algorithm ID: TEA.

• #define CRYPT ALGO SKIPJACK 1

Algorithm ID: Skipjack.

• #define CRYPT ALGO NEWDESSK 2

Algorithm ID: NEWDES-SK.

• #define CRYPT KEY LEN TEA KEY LEN

Length of key in octets.

• #define CRYPT BLOCK LEN TEA BLOCK LEN

Length of cipher block in octets.

• #define crypt enc(v, k) tea enc((iu32∗)(v),(iu32∗)(k))

Single block encryption function.

• #define crypt dec(v, k) tea dec((iu32∗)(v),(iu32∗)(k))

Single block decryption function.

6.7.1 Detailed Description

Crypto declarations.

Id: crypt.h,v 1.1 2003/03/30 12:42:21 m Exp

6.7.2 Define Documentation

6.7.2.1 #define CRYPT ALGO NEWDESSK 2 Algorithm ID: NEWDES-SK.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.7.2.2 #define CRYPT ALGO SKIPJACK 1 Algorithm ID: Skipjack.

6.7.2.3 #define CRYPT ALGO TEA 0 Algorithm ID: TEA.

6.7.2.4 #define CRYPT BLOCK LEN TEA BLOCK LEN Length of cipher block in octets.

6.7.2.5 #define crypt dec(v, k) tea dec((iu32∗)(v),(iu32∗)(k)) Single block decryption function.

6.7.2.6 #define crypt enc(v, k) tea enc((iu32∗)(v),(iu32∗)(k)) Single block encryption function.

6.7.2.7 #define CRYPT KEY LEN TEA KEY LEN Length of key in octets.

6.8 ctapi.c File Reference

Virtual CT-API library.

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <ctapi.h>
#include <main.h>
#include <sw.h>

Functions • IS8 CT forkIcc (void)

• IS8 CT stopIcc (void)

• IS8 CT ifdCmdResetCT (IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

• IS8 CT ifdCmdRequestICC (IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

• IS8 CT ifdCmdGetStatus (IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

• IS8 CT ifdCmdEjectICC (IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

• IS8 CT ifdCmdEepromFile (IU16 lenc, IU8 ∗command, IU16 ∗lenr,

IU8 ∗response)

Parses EEPROM FILE command.

• IS8 CT ifdCmd (IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

• int CT t0 (IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

• IS8 CT iccCmd (IU8 ∗dad, IU8 ∗sad, IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

• IS8 CT init (IU16 ctn, IU16 pn)

• IS8 CT data (IU16 ctn, IU8 ∗dad, IU8 ∗sad, IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

• IS8 CT close (IU16 ctn)

Variables

• IS32 cthandle = -1

• int fd fromCard [2]

• int fd toCard [2]

• pid t pidVirtuaCard = 0

• int loadEepromFile = FALSE

• int saveEepromFile = FALSE

• char eepromFile [256]

• int fdEepromFile

• char atr [32]

• int atrlen = 0

6.8.1 Detailed Description

Virtual CT-API library.

Id: ctapi.c,v 1.4 2002/12/24 13:29:57 m Exp

6.8.2 Function Documentation

6.8.2.1 IS8 CT close (IU16 ctn)

6.8.2.2 IS8 CT data (IU16 ctn, IU8 ∗ dad, IU8 ∗ sad, IU16 lenc, IU8

∗ command, IU16 ∗ lenr, IU8 ∗ response)

6.8.2.3 IS8 CT forkIcc (void)

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.8 ctapi.c File Reference  54

6.8.2.4 IS8 CT iccCmd (IU8 ∗ dad, IU8 ∗ sad, IU16 lenc, IU8 ∗ command, IU16 ∗ lenr, IU8 ∗ response) 6.8.2.5 IS8 CT ifdCmd (IU16 lenc, IU8 ∗ command, IU16 ∗ lenr, IU8 ∗ response) 6.8.2.6 IS8 CT ifdCmdEepromFile (IU16 lenc, IU8 ∗ command, IU16 ∗ lenr, IU8 ∗ response) Parses EEPROM FILE command.

• CLA: ’20’ – INS: ’E0’

– P1:

∗ bit 1: Save EEPROM to file at eject or reset.

∗ bit 2: Load EEPROM from file at reset.

– P2: RFU

– Lc: Length of file name

– Data: File name (possibly including path) without null-termination

6.8.2.7 IS8 CT ifdCmdEjectICC (IU16 lenc, IU8 ∗ command, IU16

∗ lenr, IU8 ∗ response) 6.8.2.8 IS8 CT ifdCmdGetStatus (IU16 lenc, IU8 ∗ command, IU16

∗ lenr, IU8 ∗ response) 6.8.2.9 IS8 CT ifdCmdRequestICC (IU16 lenc, IU8 ∗ command, IU16 ∗ lenr, IU8 ∗ response) 6.8.2.10 IS8 CT ifdCmdResetCT (IU16 lenc, IU8 ∗ command, IU16

∗ lenr, IU8 ∗ response) 6.8.2.11 IS8 CT init (IU16 ctn, IU16 pn) 6.8.2.12 IS8 CT stopIcc (void) 6.8.2.13 int CT t0 (IU16 lenc, IU8 ∗ command, IU16 ∗ lenr, IU8 ∗ response) 6.8.3 Variable Documentation 6.8.3.1 char atr[32]

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.8.3.2 int atrlen = 0

6.8.3.3 IS32 cthandle = -1

6.8.3.4 char eepromFile[256]

6.8.3.5 int fd fromCard[2]

6.8.3.6 int fd toCard[2]

6.8.3.7 int fdEepromFile

6.8.3.8 int loadEepromFile = FALSE

6.8.3.9 pid t pidVirtuaCard = 0

6.8.3.10 int saveEepromFile = FALSE

6.9 ctapi.h File Reference

Declarations for virtual CT-API library.

#include <types.h>

Defines

• #define CTAPI AD ICC1 0

• #define CTAPI AD CT 1

• #define CTAPI AD HOST 2

• #define CTAPI RV OK 0

• #define CTAPI RV ERR INVALID -1

• #define CTAPI RV ERR CT -8

• #define CTAPI RV ERR TRANS -10

• #define CTAPI RV ERR MEMORY -11

• #define CTAPI RV ERR HOST -127

• #define CTAPI RV ERR HTSI -128

• #define CTAPI PORT 1

• #define CTAPI CLA 0x20

• #define CTAPI INS RESET CT 0x11

• #define CTAPI INS REQUEST ICC 0x12

• #define CTAPI INS GET STATUS 0x13

• #define CTAPI INS EJECT ICC 0x14

• #define CTAPI INS EEPROM 0xE0

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Typedefs

• typedef unsigned char IU8

• typedef signed char IS8

• typedef unsigned short IU16

• typedef signed short IS16

• typedef unsigned long IU32

• typedef signed long IS32

Functions

• IS8 CT forkIcc (void)

• IS8 CT stopIcc (void)

• IS8 CT ifdCmdEepromFile (IU16 lenc, IU8 ∗command, IU16 ∗lenr,

IU8 ∗response)

Parses EEPROM FILE command.

• IS8 CT ifdCmdResetCT (IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

• IS8 CT ifdCmdRequestICC (IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

• IS8 CT ifdCmdGetStatus (IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

• IS8 CT ifdCmdEjectICC (IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

• IS8 CT ifdCmd (IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

• IS8 CT iccCmd (IU8 ∗dad, IU8 ∗sad, IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

• IS8 CT init (IU16 ctn, IU16 pn)

• IS8 CT data (IU16 ctn, IU8 ∗dad, IU8 ∗sad, IU16 lenc, IU8 ∗command, IU16 ∗lenr, IU8 ∗response)

• IS8 CT close (IU16 ctn)

Variables

• int fd fromCard [2]

• int fd toCard [2]

• int loadEepromFile

• int saveEepromFile

• char eepromFile [256]

• int fdEepromFile

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.9 ctapi.h File Reference  57

6.9.1 Detailed Description Declarations for virtual CT-API library. Id: ctapi.h,v 1.2 2002/12/22 23:16:15 m Exp 6.9.2 Define Documentation 6.9.2.1 #define CTAPI AD CT 1 6.9.2.2 #define CTAPI AD HOST 2 6.9.2.3 #define CTAPI AD ICC1 0 6.9.2.4 #define CTAPI CLA 0x20 6.9.2.5 #define CTAPI INS EEPROM 0xE0 6.9.2.6 #define CTAPI INS EJECT ICC 0x14 6.9.2.7 #define CTAPI INS GET STATUS 0x13 6.9.2.8 #define CTAPI INS REQUEST ICC 0x12 6.9.2.9 #define CTAPI INS RESET CT 0x11 6.9.2.10 #define CTAPI PORT 1 6.9.2.11 #define CTAPI RV ERR CT -8 6.9.2.12 #define CTAPI RV ERR HOST -127 6.9.2.13 #define CTAPI RV ERR HTSI -128 6.9.2.14 #define CTAPI RV ERR INVALID -1 6.9.2.15 #define CTAPI RV ERR MEMORY -11 6.9.2.16 #define CTAPI RV ERR TRANS -10

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.9 ctapi.h File Reference  58

6.9.2.17 #define CTAPI RV OK 0 6.9.3 Typedef Documentation 6.9.3.1 typedef signed short IS16 6.9.3.2 typedef signed long IS32 6.9.3.3 typedef signed char IS8 6.9.3.4 typedef unsigned short IU16 6.9.3.5 typedef unsigned long IU32 6.9.3.6 typedef unsigned char IU8 6.9.4 Function Documentation 6.9.4.1 IS8 CT close (IU16 ctn) 6.9.4.2 IS8 CT data (IU16 ctn, IU8 ∗ dad, IU8 ∗ sad, IU16 lenc, IU8

∗ command, IU16 ∗ lenr, IU8 ∗ response) 6.9.4.3 IS8 CT forkIcc (void) 6.9.4.4 IS8 CT iccCmd (IU8 ∗ dad, IU8 ∗ sad, IU16 lenc, IU8 ∗ command, IU16 ∗ lenr, IU8 ∗ response) 6.9.4.5 IS8 CT ifdCmd (IU16 lenc, IU8 ∗ command, IU16 ∗ lenr, IU8 ∗ response) 6.9.4.6 IS8 CT ifdCmdEepromFile (IU16 lenc, IU8 ∗ command, IU16 ∗ lenr, IU8 ∗ response) Parses EEPROM FILE command.

• CLA: ’20’ – INS: ’E0’

– P1:

∗ bit 1: Save EEPROM to file at eject or reset.

∗ bit 2: Load EEPROM from file at reset.

– P2: RFU

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.10 fs.c File Reference  59

– Lc: Length of file name

– Data: File name (possibly including path) without null-termination

6.9.4.7 IS8 CT ifdCmdEjectICC (IU16 lenc, IU8 ∗ command, IU16

∗ lenr, IU8 ∗ response) 6.9.4.8 IS8 CT ifdCmdGetStatus (IU16 lenc, IU8 ∗ command, IU16

∗ lenr, IU8 ∗ response) 6.9.4.9 IS8 CT ifdCmdRequestICC (IU16 lenc, IU8 ∗ command, IU16 ∗ lenr, IU8 ∗ response) 6.9.4.10 IS8 CT ifdCmdResetCT (IU16 lenc, IU8 ∗ command, IU16

∗ lenr, IU8 ∗ response) 6.9.4.11 IS8 CT init (IU16 ctn, IU16 pn) 6.9.4.12 IS8 CT stopIcc (void) 6.9.5 Variable Documentation 6.9.5.1 char eepromFile[256] 6.9.5.2 int fd fromCard[2] 6.9.5.3 int fd toCard[2] 6.9.5.4 int fdEepromFile 6.9.5.5 int loadEepromFile 6.9.5.6 int saveEepromFile

6.10 fs.c File Reference

File system.

#include <config.h>
#include <sw.h>
#include <fs.h>

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

#include <hal.h>
#include <log.h>
#include <string.h>
#include <transaction.h>
#include <types.h>

Functions

• bool fs init (void)

Initialize file system variables.

• bool fs seek (iu16 fid, S FSTREAM ∗fs, S FINFO ∗fi, iu8 type)

Look for a file in a stream.

• bool fs seekEnd (S FSTREAM ∗fs)

Look for the end of files in the stream.

• bool fs getData (S FPATH ∗fp, S FSTREAM ∗fs, S FINFO ∗fi)

Get stream and info for a file specified as a path.

• bool fs getFPath (iu16 fid, S FPATH ∗fp, S FSTREAM ∗fs, S -

FINFO ∗fi)

Get path, stream and info for a file specified as a FID.

• bool fs delete (iu16 fid)

Delete file specified as fid.

• bool fs create (S FINFO ∗fi)

The function creates a file.

Variables

• iu16 fsstart

Start address of the MF file header.

• iu16 fssize

Size of the content area of the MF.

• S FPATH selected

Path specified of the currently selected file.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.10.1 Detailed Description

File system.

Id: fs.c,v 1.23 2002/12/22 15:42:55 m Exp

6.10.2 Function Documentation

6.10.2.1 bool fs create (S FINFO ∗ fi)

The function creates a file.

The functions creates a file with the data in fi. The current file must be a MF or DF. In case the current file is a DF, the file, which should be created, can’t be a DF.

Parameters: fi Pointer to S FINFO, which contains the data of the file to create.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.10.2.2 bool fs delete (iu16 fid)

Delete file specified as fid.

The function looks for the fid in the current file, which must be a MF or DF. The file, which should be deleted must be the last one in the current MF or DF.

Parameters: fid ID of the file to delete.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.10.2.3 bool fs getData (S FPATH ∗ fp, S FSTREAM ∗ fs, S - FINFO ∗ fi)

Get stream and info for a file specified as a path.

Parameters: fp Pointer to S FPATH, which is used to supply the information about the file wanted.

fs Pointer to S FSTREAM, which will be filled with data on success.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

fi Pointer to S FINFO, which will be filled with data on success.

Return values: TRUE on success. FALSE on failure. Error code given in sw.

6.10.2.4 bool fs getFPath (iu16 fid, S FPATH ∗ fp, S FSTREAM ∗ fs, S FINFO ∗ fi) Get path, stream and info for a file specified as a FID. The file is searched for in the order described in the SELECT FILE documentation on the main page.

Parameters: fid File ID to look for. fp Pointer to S FPATH, which will be filled with data on success. fs Pointer to S FSTREAM, which will be filled with data on success. This

can be NULL when no data is wanted. fi Pointer to S FINFO, which will be filled with data on success. This can

be NULL when no data is wanted.

Return values: TRUE on success. FALSE on failure. Error code given in sw.

6.10.2.5 bool fs init (void) Initialize file system variables. This looks e.g. for the start of the file system and it’s size. It must be called after each reset.

Return values: TRUE on success. FALSE on failure. Error code given in sw.

6.10.2.6 bool fs seek (iu16 fid, S FSTREAM ∗ fs, S FINFO ∗ fi, iu8 type) Look for a file in a stream.

Parameters: fid File ID to look for.

fs Pointer to S FSTREAM, where the FID is searched for. It returns on success a stream on the file found.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

fi Pointer to S FINFO, which will be filled with data on success.

type Type of file wanted.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

Todo: There is probably a potential for simplification, when the file type is not handled so rigid.

6.10.2.7 bool fs seekEnd (S FSTREAM ∗ fs) Look for the end of files in the stream.

Parameters: fs Pointer to S FSTREAM, which supplies a directory stream and which will be used to return the end position on success.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.10.3 Variable Documentation

6.10.3.1 iu16 fssize Size of the content area of the MF.

6.10.3.2 iu16 fsstart Start address of the MF file header.

6.10.3.3 S FPATH selected Path specified of the currently selected file.

Todo: Saving here a S FINFO and/or S FSTREAM of the selected file might reduce the code size.

6.11 fs.h File Reference

File system declarations.

#include <types.h>
#include <fstream.h>

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.11 fs.h File Reference  64

Data Structures

• struct s finfo

File info struct. This is directly written as a file header in the file system.

• struct s fpath

File path specifier.

Defines

• #define FS TYPE DF 0x38

File type DF.

• #define FS TYPE EF 0x00

File type EF.

• #define FS TYPE EF TRANSP 0x00

File type transparent EF.

• #define FS TYPE EF FIXED 0x01

File type fixed record EF.

• #define FS HEADER SIZE sizeof(S FINFO)

Size of the file header, which is currently the same as S FINFO.

Typedefs

• typedef s fpath S FPATH

File path specifier.

• typedef s finfo S FINFO

File info struct. This is directly written as a file header in the file system.

Functions

• bool fs init (void)

Initialize file system variables.

• bool fs seek (iu16 fid, S FSTREAM ∗fs, S FINFO ∗fi, iu8 type)

Look for a file in a stream.

• bool fs seekEnd (S FSTREAM ∗fs)

Look for the end of files in the stream.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

• bool fs getData (S FPATH ∗fp, S FSTREAM ∗fs, S FINFO ∗fi)

Get stream and info for a file specified as a path.

• bool fs getFPath (iu16 fid, S FPATH ∗fp, S FSTREAM ∗fs, S -

FINFO ∗fi)

Get path, stream and info for a file specified as a FID.

• bool fs delete (iu16 fid)

Delete file specified as fid.

• bool fs create (S FINFO ∗fi)

The function creates a file.

Variables

• S FPATH selected

Path specified of the currently selected file.

6.11.1 Detailed Description

File system declarations.

SOSSE implements a very simple file system. Each file starts with following header:

• 2 Byte: Content size

• 2 Byte: ID

• 1 Byte: Type

• 1 Byte: Access conditions

Directly after that the content area is located. If the file is a DF, this content area is directly used to add header/content sequences.

After the content area of a file, a content size of 0 must be writen as an end of data marker. This means the data capacity of a MF or DF is the total content size of it minus 2.

Currently the file system support only one level of DFs, i.e. the maximum depth is MF:DF:EF.

There are probably a lot optimization possibilities in this file system, but I think this is not bad for my first designed and implemented file system.

Todo: Here are certainly some optimizations possible to reduce code size.

Id: fs.h,v 1.14 2003/05/10 17:26:58 m Exp

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.11.2 Define Documentation

6.11.2.1 #define FS HEADER SIZE sizeof(S FINFO) Size of the file header, which is currently the same as S FINFO.

6.11.2.2 #define FS TYPE DF 0x38 File type DF.

6.11.2.3 #define FS TYPE EF 0x00 File type EF.

6.11.2.4 #define FS TYPE EF FIXED 0x01 File type fixed record EF.

6.11.2.5 #define FS TYPE EF TRANSP 0x00 File type transparent EF.

6.11.3 Typedef Documentation

6.11.3.1 typedef struct s finfo S FINFO File info struct. This is directly written as a file header in the file system.

6.11.3.2 typedef struct s fpath S FPATH File path specifier.

Todo: There is probably a potential for simplification, when the file type (DF/EF) is not handled so rigid.

6.11.4 Function Documentation

6.11.4.1 bool fs create (S FINFO ∗ fi) The function creates a file. The functions creates a file with the data in fi. The current file must be a MF or DF. In case the current file is a DF, the file, which should be created, can’t be a DF.

Parameters: fi Pointer to S FINFO, which contains the data of the file to create.

Return values: TRUE on success.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

FALSE on failure. Error code given in sw.

6.11.4.2 bool fs delete (iu16 fid)

Delete file specified as fid.

The function looks for the fid in the current file, which must be a MF or DF. The file, which should be deleted must be the last one in the current MF or DF.

Parameters: fid ID of the file to delete.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.11.4.3 bool fs getData (S FPATH ∗ fp, S FSTREAM ∗ fs, S - FINFO ∗ fi)

Get stream and info for a file specified as a path.

Parameters: fp Pointer to S FPATH, which is used to supply the information about the

file wanted. fs Pointer to S FSTREAM, which will be filled with data on success. fi Pointer to S FINFO, which will be filled with data on success.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.11.4.4 bool fs getFPath (iu16 fid, S FPATH ∗ fp, S FSTREAM ∗ fs, S FINFO ∗ fi)

Get path, stream and info for a file specified as a FID.

The file is searched for in the order described in the SELECT FILE documentation on the main page.

Parameters: fid File ID to look for.

fp Pointer to S FPATH, which will be filled with data on success.

fs Pointer to S FSTREAM, which will be filled with data on success. This

can be NULL when no data is wanted. fi Pointer to S FINFO, which will be filled with data on success. This can

be NULL when no data is wanted.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.11.4.5 bool fs init (void) Initialize file system variables. This looks e.g. for the start of the file system and it’s size. It must be called after each reset.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.11.4.6 bool fs seek (iu16 fid, S FSTREAM ∗ fs, S FINFO ∗ fi, iu8 type) Look for a file in a stream.

Parameters: fid File ID to look for.

fs Pointer to S FSTREAM, where the FID is searched for. It returns on

success a stream on the file found. fi Pointer to S FINFO, which will be filled with data on success. type Type of file wanted.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

Todo: There is probably a potential for simplification, when the file type is not handled so rigid.

6.11.4.7 bool fs seekEnd (S FSTREAM ∗ fs) Look for the end of files in the stream.

Parameters: fs Pointer to S FSTREAM, which supplies a directory stream and which will be used to return the end position on success.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.11.5 Variable Documentation

6.11.5.1 S FPATH selected Path specified of the currently selected file.

Todo: Saving here a S FINFO and/or S FSTREAM of the selected file might reduce the code size.

6.12 fstest.c File Reference

Test program for file system functions.

#include <stdio.h>
#include <auth.h>
#include <fs.h>
#include <fstream.h>
#include <hal.h>

Functions • int main (int argc, char ∗argv[ ])

Variables

• iu16 fsstart

Start address of the MF file header.

• iu16 fssize

Size of the content area of the MF.

• iu8 authstate

Variable indicating current authentication state.

6.12.1 Detailed Description

Test program for file system functions.

Id: fstest.c,v 1.11 2002/12/22 15:42:55 m Exp

6.12.2 Function Documentation

6.12.2.1 int main (int argc, char ∗ argv[ ])

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.12.3 Variable Documentation

6.12.3.1 iu8 authstate () Variable indicating current authentication state. Single bit flags indicate, which authorization process has been successful. The flag is cleared, at the reset of the card and after unsuccessful authorization processes. Valid flags are:

• AUTH FLAG PIN

• AUTH FLAG KEY

6.12.3.2 iu16 fssize Size of the content area of the MF.

6.12.3.3 iu16 fsstart Start address of the MF file header.

6.13 fstream.c File Reference

File stream functions.

#include <sw.h>
#include <fstream.h>
#include <hal.h>
#include <types.h>

Functions

• bool fstream read (S FSTREAM ∗fs, iu8 ∗dst, iu8 len)

Read data from a stream.

• bool fstream write (S FSTREAM ∗fs, iu8 ∗src, iu8 len)

Write data to a stream.

• bool fstream test (S FSTREAM ∗fs, iu16 len)

This function tests, if enough space is available to read or write len bytes.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.13.1 Detailed Description

File stream functions.

Id: fstream.c,v 1.11 2002/12/22 15:42:55 m Exp

6.13.2 Function Documentation

6.13.2.1 bool fstream read (S FSTREAM ∗ fs, iu8 ∗ dst, iu8 len) Read data from a stream. Either this functions reads all data or nothing.

Parameters: fs Pointer to S FSTREAM, on which it should be operated. dst Pointer to the data destination. len Length of the data

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.13.2.2 bool fstream test (S FSTREAM ∗ fs, iu16 len) This function tests, if enough space is available to read or write len bytes.

Parameters: fs Pointer to S FSTREAM, on which it should be operated. len Length of the data

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.13.2.3 bool fstream write (S FSTREAM ∗ fs, iu8 ∗ src, iu8 len) Write data to a stream. This functions tries to write all or nothing.

Parameters: fs Pointer to S FSTREAM, on which it should be operated. src Pointer to data source. len Length of the data

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.14 fstream.h File Reference

File stream declarations.

#include <types.h>

Data Structures

• struct s fstream

Stream struct.

Typedefs

• typedef s fstream S FSTREAM

Stream struct.

Functions

• bool fstream read (S FSTREAM ∗fs, iu8 ∗dst, iu8 len)

Read data from a stream.

• bool fstream write (S FSTREAM ∗fs, iu8 ∗src, iu8 len)

Write data to a stream.

• bool fstream test (S FSTREAM ∗fs, iu16 len)

This function tests, if enough space is available to read or write len bytes.

6.14.1 Detailed Description

File stream declarations. These streams are used to pass more easily EEPROM areas around and to reduce the chances of overwriting unwanted EEPROM areas, e.g. by overflowing the data area. This is a very slim version of the streams implemented in cryptlib from Peter Gutmann.

Id: fstream.h,v 1.8 2002/12/22 15:42:55 m Exp

6.14.2 Typedef Documentation

6.14.2.1 typedef struct s fstream S FSTREAM Stream struct.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.14.3 Function Documentation

6.14.3.1 bool fstream read (S FSTREAM ∗ fs, iu8 ∗ dst, iu8 len) Read data from a stream. Either this functions reads all data or nothing.

Parameters: fs Pointer to S FSTREAM, on which it should be operated. dst Pointer to the data destination. len Length of the data

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.14.3.2 bool fstream test (S FSTREAM ∗ fs, iu16 len) This function tests, if enough space is available to read or write len bytes.

Parameters: fs Pointer to S FSTREAM, on which it should be operated. len Length of the data

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.14.3.3 bool fstream write (S FSTREAM ∗ fs, iu8 ∗ src, iu8 len) Write data to a stream. This functions tries to write all or nothing.

Parameters: fs Pointer to S FSTREAM, on which it should be operated. src Pointer to data source. len Length of the data

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.15 hal-emu.c File Reference

HAL emulation for Linux.

#include <config.h>
#include <sio/sio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <crypt.h>
#include <sw.h>
#include <types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>

Defines • #define PORT ”/dev/ttyS0”

Functions

• void hal init (void)

Initializes the HAL.

• void hal destroy (void)

• bool hal eeprom read (iu8 ∗dst, iu16 src, iu8 len)

Read data from EEPROM.

• bool hal eeprom write (iu16 dst, iu8 ∗src, iu8 len)

Write data to EEPROM.

• void hal io sendByteT0 (iu8 b)

Send a byte with T=0 error detection and recovery.

• iu8 hal io recByteT0 (void)

Receive a byte with T=0 error detection and recovery.

• bool hal rnd getBlock (iu8 ∗dst)

Returns 8 random bytes.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Variables

• iu8 eeprom [1 ∗1024]

• int halsend

6.15.1 Detailed Description

HAL emulation for Linux.

Id: hal-emu.c,v 1.18 2003/03/30 12:42:21 m Exp

6.15.2 Define Documentation

6.15.2.1 #define PORT ”/dev/ttyS0”

6.15.3 Function Documentation

6.15.3.1 void hal destroy (void)

6.15.3.2 bool hal eeprom read (iu8 ∗ dst, iu16 src, iu8 len) Read data from EEPROM. The internal EEPROM begins at address 0, the external EEPROM is located subsequently.

Parameters: dst Pointer to destination area.

src EEPROM source address. len Length of data in bytes.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.15.3.3 bool hal eeprom write (iu16 dst, iu8 ∗ src, iu8 len) Write data to EEPROM. The internal EEPROM begins at address 0, the external EEPROM is located subsequently.

Parameters: dst EEPROM destination address src Pointer to source area. len Length of data in bytes.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.15.3.4 void hal init (void) Initializes the HAL. Must be called after each reset.

6.15.3.5 iu8 hal io recByteT0 (void) Receive a byte with T=0 error detection and recovery. Currently only 9600 bps at 3.58MHz with direct convention is supported.

Returns: This function returns a received byte. There can’t be an error, because T=0 tries endlessly to receive a characters. (And if there is really an error, what should SOSSE do with it anyway?)

6.15.3.6 void hal io sendByteT0 (iu8 b) Send a byte with T=0 error detection and recovery. Currently only 9600 bps at 3.58MHz with direct convention is supported.

Parameters: b Byte to send.

6.15.3.7 bool hal rnd getBlock (iu8 ∗ dst) Returns 8 random bytes. The current AVR implementation does not produce real random numbers, but pseudo random numbers. These are produced by a X9.17 generator modified to use a counter instead of a timer. The state of this PRNG is held at RAND - STATE ADDR. The start value (at least the key) at this address should be unique for every card.

Parameters: dst Pointer to the destination, where the 8 random bytes should be written.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

Note: There is still a simpler PRNG in the code, which uses 16 bytes RAM and 126 bytes ROM less than the X9.17 generator.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.15.4 Variable Documentation

6.15.4.1 iu8 eeprom[1∗1024]

6.15.4.2 int halsend

6.16 hal.c File Reference

HAL (Hardware Abstraction Layer).

#include <config.h>
#include <crypt.h>
#include <hal.h>
#include <avr/eeprom.h>
#include <avr/io.h>
#include <log.h>
#include <string.h>
#include <tools.h>
#include <types.h>

Functions

• void hal init (void)

Initializes the HAL.

• iu8 xeread (iu16 addr)

• void xewrt (iu16 addr, iu8 b)

• bool hal eeprom read (iu8 ∗dst, iu16 src, iu8 len)

Read data from EEPROM.

• bool hal eeprom write (iu16 dst, iu8 ∗src, iu8 len)

Write data to EEPROM.

• void sendbytet0 (iu8 b)

• iu8 recbytet0 (void)

• void hal io sendByteT0 (iu8 b)

Send a byte with T=0 error detection and recovery.

• iu8 hal io recByteT0 (void)

Receive a byte with T=0 error detection and recovery.

• bool hal rnd getBlock (iu8 ∗dst)

Returns 8 random bytes.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.16.1 Detailed Description

HAL (Hardware Abstraction Layer).

Id: hal.c,v 1.22 2003/03/30 12:42:21 m Exp

6.16.2 Function Documentation

6.16.2.1 bool hal eeprom read (iu8 ∗ dst, iu16 src, iu8 len) Read data from EEPROM. The internal EEPROM begins at address 0, the external EEPROM is located subsequently.

Parameters: dst Pointer to destination area.

src EEPROM source address. len Length of data in bytes.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.16.2.2 bool hal eeprom write (iu16 dst, iu8 ∗ src, iu8 len) Write data to EEPROM. The internal EEPROM begins at address 0, the external EEPROM is located subsequently.

Parameters: dst EEPROM destination address src Pointer to source area. len Length of data in bytes.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.16.2.3 void hal init (void) Initializes the HAL. Must be called after each reset.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.16.2.4 iu8 hal io recByteT0 (void)

Receive a byte with T=0 error detection and recovery.

Currently only 9600 bps at 3.58MHz with direct convention is supported.

Returns: This function returns a received byte. There can’t be an error, because T=0 tries endlessly to receive a characters. (And if there is really an error, what should SOSSE do with it anyway?)

6.16.2.5 void hal io sendByteT0 (iu8 b)

Send a byte with T=0 error detection and recovery.

Currently only 9600 bps at 3.58MHz with direct convention is supported.

Parameters: b Byte to send.

6.16.2.6 bool hal rnd getBlock (iu8 ∗ dst)

Returns 8 random bytes.

The current AVR implementation does not produce real random numbers, but pseudo random numbers. These are produced by a X9.17 generator modified to use a counter instead of a timer. The state of this PRNG is held at RAND - STATE ADDR. The start value (at least the key) at this address should be unique for every card.

Parameters: dst Pointer to the destination, where the 8 random bytes should be written.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

Note: There is still a simpler PRNG in the code, which uses 16 bytes RAM and 126 bytes ROM less than the X9.17 generator.

6.16.2.7 iu8 recbytet0 (void)

6.16.2.8 void sendbytet0 (iu8 b)

6.16.2.9 iu8 xeread (iu16 addr)

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.16.2.10 void xewrt (iu16 addr, iu8 b)

6.17 hal.h File Reference

HAL (Hardware Abstraction Layer) declarations.

#include <types.h>

Functions

• void hal init (void)

Initializes the HAL.

• bool hal eeprom read (iu8 ∗dst, iu16 src, iu8 len)

Read data from EEPROM.

• bool hal eeprom write (iu16 dst, iu8 ∗src, iu8 len)

Write data to EEPROM.

• void hal io sendByteT0 (iu8 b)

Send a byte with T=0 error detection and recovery.

• iu8 hal io recByteT0 (void)

Receive a byte with T=0 error detection and recovery.

• bool hal rnd addEntropy (void)

Adds entropy to the random number generator state.

• bool hal rnd getBlock (iu8 ∗dst)

Returns 8 random bytes.

• bool hal led (char set)

Sets the LEDs on Jupiter 2 cards.

6.17.1 Detailed Description

HAL (Hardware Abstraction Layer) declarations.

Id: hal.h,v 1.15 2002/12/22 15:42:55 m Exp

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.17.2 Function Documentation

6.17.2.1 bool hal eeprom read (iu8 ∗ dst, iu16 src, iu8 len) Read data from EEPROM. The internal EEPROM begins at address 0, the external EEPROM is located subsequently.

Parameters: dst Pointer to destination area.

src EEPROM source address. len Length of data in bytes.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.17.2.2 bool hal eeprom write (iu16 dst, iu8 ∗ src, iu8 len) Write data to EEPROM. The internal EEPROM begins at address 0, the external EEPROM is located subsequently.

Parameters: dst EEPROM destination address src Pointer to source area. len Length of data in bytes.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.17.2.3 void hal init (void) Initializes the HAL. Must be called after each reset.

6.17.2.4 iu8 hal io recByteT0 (void) Receive a byte with T=0 error detection and recovery. Currently only 9600 bps at 3.58MHz with direct convention is supported.

Returns: This function returns a received byte. There can’t be an error, because T=0 tries endlessly to receive a characters. (And if there is really an error, what should SOSSE do with it anyway?)

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.17.2.5 void hal io sendByteT0 (iu8 b)

Send a byte with T=0 error detection and recovery.

Currently only 9600 bps at 3.58MHz with direct convention is supported.

Parameters: b Byte to send.

6.17.2.6 bool hal led (char set)

Sets the LEDs on Jupiter 2 cards.

This can be used for example for debugging to show some state or to get a Nightrider feeling.

Parameters: set Bits 0-6 are currently used for specifying LEDs.

Return values: TRUE is currently returned

Note: This function is always included when compiling for the AT90S8535, which is AFAIK the only processor, which is available as PCB with LEDs.

6.17.2.7 bool hal rnd addEntropy (void)

Adds entropy to the random number generator state.

The idea: Adding real randomness to the RAND STATE via random events and a high speed timer.

The implementation: Timer 0 is started at the beginning and incremented every clock cycle, i.e. normally 3.58 million times per second. The timer is read at the beginning and at the end of the execution of every command. After every 8 timer values gathered in this way, RAND STATE is read and encrypted with RAND STATE and timer values as key. The result is written back to RAND STATE.

The analysis: The analysis has been done by calculating the difference of each consecutive timer value pair. From these value two distributions are build. The first is the frequency for the timer value differences within the command and the second is the frequency for the timer value differences outside the command, i.e. while communicating with the terminal. The command used for this evaluation is the Read EEPROM command (80 04 18 00 10), which should have a relatively constant execution time and does not receive bytes from the terminal.

Terminal randomness: As expected the randomness of the distribution depends on the external system, i.e. card reader and host. Different distributions have been seen e.g. for Towitoko Chipdrive and Intertext IX2. This randomness can increas the randomness in the RAND STATE buffer, when the card is

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

in the hand of the owner of the card. By this, it changes RAND STATE in a non-deterministic way for the institution writing the starting value of RAND - STATE

Command randomness: Because there is no obvious possibility for different runtimes, the expected result would be to have exactly the same delta values for all command runs, but this is not the case. The result is a 9 - 10 ticks wide curved distribution. The reason for this might be the I2C routine communicating with the external EEPROM, because Get Response and Read EE in the internal EEPROM area have the expected result with a single delta value. Independed of the source of the clock tick variations, there is probably not much non-determinism for a skilled attacker, because he can count the clocks a command has executed.

Note: This function and the initialization in hal init() (p. 76) is currently commented out.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.17.2.8 bool hal rnd getBlock (iu8 ∗ dst)

Returns 8 random bytes.

The current AVR implementation does not produce real random numbers, but pseudo random numbers. These are produced by a X9.17 generator modified to use a counter instead of a timer. The state of this PRNG is held at RAND - STATE ADDR. The start value (at least the key) at this address should be unique for every card.

Parameters: dst Pointer to the destination, where the 8 random bytes should be written.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

Note: There is still a simpler PRNG in the code, which uses 16 bytes RAM and 126 bytes ROM less than the X9.17 generator.

6.18 log.c File Reference

Logging functions.

#include <config.h>
#include <hal.h>

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

#include <log.h>
#include <types.h>

6.18.1 Detailed Description

Logging functions.

Id: log.c,v 1.6 2002/12/22 15:42:55 m Exp

6.19 log.h File Reference

Logging declarations.

#include <types.h>

Defines

• #define LOG START 0x1800

• #define LOG TAG JOKER 0xFE

• #define LOG TAG EEWRITE DST 0x01

• #define LOG TAG EEWRITE SRC 0x02

• #define LOG TAG EEWRITE LEN 0x03

• #define LOG TAG EEREAD DST 0x04

• #define LOG TAG EEREAD SRC 0x05

• #define LOG TAG EEREAD LEN 0x06

• #define LOG TAG FSCREATE 0x07

• #define LOG TAG RANDOM 0x08

• #define log init()

Initialize global logging variables.

• #define log add(tag, data, len)

Log data.

Variables

• bool log enable

Enables/disables logging.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.19.1 Detailed Description

Logging declarations.

This logging facility can be used to assist debugging. It appends TLV objects (Tag, Length, Value) to logging area starting at LOG START+2. At LOG - START the address of the end of data is maintained. This is in native byte order. (Native of architecture or compiler.)

Tags can be used to specify what data has been logged. This is meant to assist testing, so be free to change the tags as needed.

Id: log.h,v 1.5 2002/12/22 15:42:55 m Exp

6.19.2 Define Documentation

6.19.2.1 #define log add(tag, data, len)

Log data.

Tag, length and then the data itself is append to the log data. It can be called even, when CONF WITH LOGGING is not 1, because it is then neutralized with a define.

Parameters: tag Tag descriping the data.

data Pointer to the data.

len Length of the data in bytes.

6.19.2.2 #define log init()

Initialize global logging variables.

This function must be called before using log add. It can be called even, when CONF WITH LOGGING is not 1, because it is then neutralized with a define.

6.19.2.3 #define LOG START 0x1800

6.19.2.4 #define LOG TAG EEREAD DST 0x04

6.19.2.5 #define LOG TAG EEREAD LEN 0x06

6.19.2.6 #define LOG TAG EEREAD SRC 0x05

6.19.2.7 #define LOG TAG EEWRITE DST 0x01

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.19.2.8 #define LOG TAG EEWRITE LEN 0x03

6.19.2.9 #define LOG TAG EEWRITE SRC 0x02

6.19.2.10 #define LOG TAG FSCREATE 0x07

6.19.2.11 #define LOG TAG JOKER 0xFE

6.19.2.12 #define LOG TAG RANDOM 0x08

6.19.3 Variable Documentation

6.19.3.1 bool log enable Enables/disables logging. This must be set the TRUE, before any log add has an effect. It can be also changed in between to switch off and on logging to reduce unwanted data in the logging area.

6.20 main.c File Reference

main() (p. 35) function with command loop.

#include <config.h>
#include <auth.h>
#include <commands.h>
#include <sw.h>
#include <fs.h>
#include <hal.h>
#include <t0.h>
#include <transaction.h>

Functions

• int main (void)

Main function containing command interpreter loop.

6.20.1 Detailed Description

main() (p. 35) function with command loop.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.20.2 Function Documentation 6.20.2.1 int main (void) Main function containing command interpreter loop. At the end of the loop, sw is sent as the status word. This function does never return.

6.21 main.h File Reference

main() (p. 35) declarations and documentation.

6.21.1 Detailed Description main() (p. 35) declarations and documentation.

Id: main.h,v 1.24 2003/03/30 19:50:58 m Exp

6.22 newdes-sk.c File Reference

#include <config.h>
#include <types.h>

6.23 newdes-sk.h File Reference

NEWDES-SK declarations.

#include <types.h>

Defines

• #define NEWDESSK KEY LEN 15

NEWDES-SK key size.

• #define NEWDESSK BLOCK LEN 8

NEWDES-SK block length.

Functions

• void newdessk enc (iu8 ∗v, iu8 ∗k)

NEWDES-SK encryption function.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

• void newdessk dec (iu8 ∗v, iu8 ∗k)

NEWDES-SK decryption function.

6.23.1 Detailed Description

NEWDES-SK declarations.

Id: newdes-sk.h,v 1.1 2003/03/30 12:42:21 m Exp

6.23.2 Define Documentation

6.23.2.1 #define NEWDESSK BLOCK LEN 8 NEWDES-SK block length.

6.23.2.2 #define NEWDESSK KEY LEN 15 NEWDES-SK key size.

6.23.3 Function Documentation

6.23.3.1 void newdessk dec (iu8 ∗ v, iu8 ∗ k) NEWDES-SK decryption function. This function decrypts v with k and returns the decrypted data in v.

Parameters: v Array of eight iu8 values containing the data block. k Array of 15 iu8 values containing the key.

6.23.3.2 void newdessk enc (iu8 ∗ v, iu8 ∗ k) NEWDES-SK encryption function. This function encrypts v with k and returns the encrypted data in v.

Parameters: v Array of eight iu8 values containing the data block. k Array of 15 iu8 values containing the key.

6.24 skipjack.c File Reference

Skipjack declarations.

#include <config.h>

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

#include <skipjack.h>
#include <types.h>

6.24.1 Detailed Description

Skipjack declarations.

Id: skipjack.c,v 1.1 2003/03/30 12:42:21 m Exp

6.25 skipjack.h File Reference

Skipjack declarations.

#include <types.h>

Defines

• #define SKIPJACK KEY LEN 10

SKIPJACK key size.

• #define SKIPJACK BLOCK LEN 8

SKIPJACK block length.

Functions

• void skipjack enc (iu8 ∗v, iu8 ∗k)

Skipjack encryption function.

• void skipjack dec (iu8 ∗v, iu8 ∗k)

Skipjack decryption function.

6.25.1 Detailed Description

Skipjack declarations.

Documentation  for  Skipjack  is  available  at

http://csrc.nist.gov/encryption/skipjack/skipjack-kea.htm.

Id: skipjack.h,v 1.1 2003/03/30 12:42:21 m Exp

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.25.2 Define Documentation

6.25.2.1 #define SKIPJACK BLOCK LEN 8 SKIPJACK block length.

6.25.2.2 #define SKIPJACK KEY LEN 10 SKIPJACK key size.

6.25.3 Function Documentation

6.25.3.1 void skipjack dec (iu8 ∗ v, iu8 ∗ k) Skipjack decryption function. This function decrypts v with k and returns the decrypted data in v.

Parameters: v Array of eight iu8 values containing the data block. k Array of ten iu8 values containing the key.

6.25.3.2 void skipjack enc (iu8 ∗ v, iu8 ∗ k) Skipjack encryption function. This function encrypts v with k and returns the encrypted data in v.

Parameters: v Array of eight iu8 values containing the data block. k Array of ten iu8 values containing the key.

6.26 sw.c File Reference

Errno functions.

#include <config.h>
#include <sw.h>
#include <types.h>

Functions

• void sw set (iu16 value)

Function for setting sw.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Variables

• iu16 sw

Status word returned by functions.

6.26.1 Detailed Description

Errno functions.

Id: sw.c,v 1.1 2002/12/22 15:42:55 m Exp

6.26.2 Function Documentation

6.26.2.1 void sw set (iu16 value) Function for setting sw. This function reduces the code size on the AVR architecture.

6.26.3 Variable Documentation

6.26.3.1 iu16 sw Status word returned by functions. The state of sw is undefined, on return value TRUE. The content of this variable is returned at the end of the command interpreter loop. Functions falled from the command interpreter loop should set it to SW - OK if they return without error.

6.27 sw.h File Reference

Errno declarations.

#include <types.h>

Defines • #define sw get() sw

Enumerations

• enum SW { SW ACCESS DENIED = 0x6982, SW AUTH - BLOCKED = 0x6983, SW AVAILABLE = 0x6100, SW - CHANGE MEMORY ERROR = 0x6581, SW COUNTER =

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

0x63C0, SW EOD = 0x6282, SW FILE EXISTS = 0x6A89, SW - FILE FILLED = 0x6381, SW FILE NOT FOUND = 0x6A82, SW FILE TO SHORT = 0x6A84, SW INCOMPATIBLE FILE = 0x6981, SW LC INCONSISTEND WITH P1P2 = 0x6A87, SW - NOT ALLOWED = 0x6986, SW NOT SUPPORTED = 0x6A81, SW OK = 0x9000, SW OTHER = 0x6F00, SW REF DATA - INVALID = 0x6984, SW REF DATA NOT FOUND = 0x6A88, SW VERIFCATION FAILED = 0x6300, SW WRONG CLA = 0x6E00, SW WRONG CONDITION = 0x6985, SW WRONG - DATA = 0x6A80, SW WRONG INS = 0x6D00, SW WRONG LE = 0x6C00, SW WRONG LEN = 0x6700, SW WRONG P1P2 = 0x6A86, SW WRONG REFERENCE = 0x6B00 }

Status word values.

Functions

• void sw set (iu16 value)

Function for setting sw.

Variables

• iu16 sw

Status word returned by functions.

6.27.1 Detailed Description

Errno declarations.

See also for the man page of sw.

Id: sw.h,v 1.2 2003/04/24 16:47:00 m Exp

6.27.2 Define Documentation

6.27.2.1 #define sw get() sw

6.27.3 Enumeration Type Documentation

6.27.3.1 enum SW

Status word values.

Note: Implement this as defines, because doxygen apparently can’t handle this?

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Enumeration values: SW ACCESS DENIED SW AUTH BLOCKED SW AVAILABLE SW CHANGE MEMORY ERROR SW COUNTER SW EOD SW FILE EXISTS SW FILE FILLED SW FILE NOT FOUND SW FILE TO SHORT SW INCOMPATIBLE FILE SW LC INCONSISTEND WITH P1P2 SW NOT ALLOWED SW NOT SUPPORTED SW OK SW OTHER SW REF DATA INVALID SW REF DATA NOT FOUND SW VERIFCATION FAILED SW WRONG CLA SW WRONG CONDITION SW WRONG DATA SW WRONG INS SW WRONG LE SW WRONG LEN SW WRONG P1P2 SW WRONG REFERENCE

6.27.4 Function Documentation

6.27.4.1 void sw set (iu16 value) Function for setting sw. This function reduces the code size on the AVR architecture.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.27.5 Variable Documentation

6.27.5.1 iu16 sw Status word returned by functions. The state of sw is undefined, on return value TRUE. The content of this variable is returned at the end of the command interpreter loop. Functions falled from the command interpreter loop should set it to SW - OK if they return without error.

6.28 t0.c File Reference

T=0 functions.

#include <config.h>
#include <sw.h>
#include <commands.h>
#include <hal.h>
#include <t0.h>
#include <types.h>
#include <string.h>

Defines • #define SW sw

Functions

• void t0 init (void)

Initialize T=0 data.

• void t0 recBlock (iu8 ∗dst, iu16 len)

Receive multiple bytes.

• void t0 wtx (void)

Send a WTX.

• bool t0 dir (bool in)

Set IN/OUT direction if command.

• void t0 exchApdu (void)

Exchanged APDUs with IFD.

• void t0 getResponse (void)

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Get Response command.

• bool t0 testP1P2 (iu16 p1p2)

Test P1P2 for correct content.

• bool t0 testP3 (iu8 p3)

Test P3 for correct content.

Variables

• bool iosend

• bool ioin

• iu8 ioheader [5]

• iu8 iodata [sizeof(iodata)]

• iu16 iodatalen

6.28.1 Detailed Description

T=0 functions.

Id: t0.c,v 1.14 2003/05/10 17:26:58 m Exp

6.28.2 Define Documentation

6.28.2.1 #define SW sw

6.28.3 Function Documentation

6.28.3.1 bool t0 dir (bool in)

Set IN/OUT direction if command.

This should be called by each command to set the command case. With IN commands the command data is only available after this function has been called.

Only in an error case, where only a status word is to be returned this command doesn’t have to be called.

Parameters: in Boolean value signaling direction.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.28.3.2 void t0 exchApdu (void) Exchanged APDUs with IFD. This function handles also the Get Response case.

6.28.3.3 void t0 getResponse (void) Get Response command. Is called from t0 exchApdu.

6.28.3.4 void t0 init (void) Initialize T=0 data. Must be called before the first t0 exchApdu.

6.28.3.5 void t0 recBlock (iu8 ∗ dst, iu16 len) Receive multiple bytes. Receive len bytes and write them to dst.

Parameters: dst Pointer to destination area in RAM. len Data bytes to receive.

6.28.3.6 bool t0 testP1P2 (iu16 p1p2) Test P1P2 for correct content. Compares the values of P1 and P2 in header to p1p2. If they differ, sw is set to SW WRONG P1P2 and FALSE is returned.

Parameters: p1p2 Target value of P1P2.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.28.3.7 bool t0 testP3 (iu8 p3) Test P3 for correct content. Compares the value of P3 in header to p3. If they differ, sw is set to SW - WRONG P1P2 and FALSE is returned.

Parameters: p3 Target value of P3.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Return values: TRUE on success. FALSE on failure. Error code given in sw.

6.28.3.8 void t0 wtx (void) Send a WTX. 6.28.4 Variable Documentation 6.28.4.1 iu8 iodata[sizeof(iodata)] 6.28.4.2 iu16 iodatalen 6.28.4.3 iu8 ioheader[5] 6.28.4.4 bool ioin 6.28.4.5 bool iosend [static]

6.29 t0.h File Reference

T=0 declarations. Defines

• #define CLA ioheader[0]

• #define INS ioheader[1]

• #define P1 ioheader[2]

• #define P2 ioheader[3]

• #define P3 ioheader[4]

• #define T0 DIR IN TRUE

Data from IFD to ICC.

• #define T0 DIR OUT FALSE

Data from ICC to IFD.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Functions

• void t0 init (void)

Initialize T=0 data.

• void t0 recBlock (iu8 ∗dst, iu16 len)

Receive multiple bytes.

• void t0 wtx (void)

Send a WTX.

• bool t0 dir (bool in)

Set IN/OUT direction if command.

• void t0 exchApdu (void)

Exchanged APDUs with IFD.

• void t0 getResponse (void)

Get Response command.

• bool t0 testP1P2 (iu16 p1p2)

Test P1P2 for correct content.

• bool t0 testP3 (iu8 p3)

Test P3 for correct content.

Variables

• bool ioin

• iu8 ioheader [5]

• iu8 iodata [CONF IODATA SIZE]

• iu16 iodatalen

6.29.1 Detailed Description

T=0 declarations. T=0 is not implemented fully as library, but must be partly done in the commands itself. This reduces the RAM requirements. E.g. when doing an Update Binary the data must not be received in total before writing, but can be received and written in single bytes.

Id: t0.h,v 1.13 2003/05/10 17:26:58 m Exp

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.29 t0.h File Reference  99

6.29.2 Define Documentation 6.29.2.1 #define CLA ioheader[0] 6.29.2.2 #define INS ioheader[1] 6.29.2.3 #define P1 ioheader[2] 6.29.2.4 #define P2 ioheader[3] 6.29.2.5 #define P3 ioheader[4] 6.29.2.6 #define T0 DIR IN TRUE Data from IFD to ICC. 6.29.2.7 #define T0 DIR OUT FALSE Data from ICC to IFD. 6.29.3 Function Documentation 6.29.3.1 bool t0 dir (bool in) Set IN/OUT direction if command. This should be called by each command to set the command case. With IN commands the command data is only available after this function has been called. Only in an error case, where only a status word is to be returned this command doesn’t have to be called. Parameters: in Boolean value signaling direction. Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.29.3.2 void t0 exchApdu (void) Exchanged APDUs with IFD. This function handles also the Get Response case.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.29.3.3 void t0 getResponse (void) Get Response command. Is called from t0 exchApdu.

6.29.3.4 void t0 init (void) Initialize T=0 data. Must be called before the first t0 exchApdu.

6.29.3.5 void t0 recBlock (iu8 ∗ dst, iu16 len) Receive multiple bytes. Receive len bytes and write them to dst.

Parameters: dst Pointer to destination area in RAM. len Data bytes to receive.

6.29.3.6 bool t0 testP1P2 (iu16 p1p2) Test P1P2 for correct content. Compares the values of P1 and P2 in header to p1p2. If they differ, sw is set to SW WRONG P1P2 and FALSE is returned.

Parameters: p1p2 Target value of P1P2.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.29.3.7 bool t0 testP3 (iu8 p3) Test P3 for correct content. Compares the value of P3 in header to p3. If they differ, sw is set to SW - WRONG P1P2 and FALSE is returned.

Parameters: p3 Target value of P3.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.30 tea.c File Reference  101

6.29.3.8 void t0 wtx (void) Send a WTX. 6.29.4 Variable Documentation 6.29.4.1 iu8 iodata[CONF IODATA SIZE] 6.29.4.2 iu16 iodatalen 6.29.4.3 iu8 ioheader[5] 6.29.4.4 bool ioin

6.30 tea.c File Reference

TEA functions.

#include <config.h>
#include <tea.h>
#include <tools.h>

Defines • #define TEA SMALL

• #define hton ul(x, y) Functions

• iu32 tea func (iu32 ∗in, iu32 ∗sum, iu32 ∗k)

• void tea enc (iu32 ∗v, iu32 ∗k)

TEA encryption function.

• void tea dec (iu32 ∗v, iu32 ∗k)

TEA decryption function.

6.30.1 Detailed Description TEA functions. Id: tea.c,v 1.6 2003/04/02 23:57:54 m Exp

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.30.2 Define Documentation

6.30.2.1 #define hton ul(x, y)

6.30.2.2 #define TEA SMALL

6.30.3 Function Documentation

6.30.3.1 void tea dec (iu32 ∗ v, iu32 ∗ k) TEA decryption function. This function decrypts v with k and returns the decrypted data in v.

Parameters: v Array of two long values containing the data block. k Array of four long values containing the key.

6.30.3.2 void tea enc (iu32 ∗ v, iu32 ∗ k) TEA encryption function. This function encrypts v with k and returns the encrypted data in v.

Parameters: v Array of two long values containing the data block. k Array of four long values containing the key.

6.30.3.3 iu32 tea func (iu32 ∗ in, iu32 ∗ sum, iu32 ∗ k)

6.31 tea.h File Reference

TEA declarations.

#include <types.h>

Defines

• #define TEA KEY LEN 16

TEA key size.

• #define TEA BLOCK LEN 8

TEA block length.

• #define DELTA 0x9E3779B9

Magic value. (Golden number ∗ 2^{∧}31).

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

• #define ROUNDS 32

Number of rounds.

Functions

• void tea enc (iu32 ∗v, iu32 ∗k)

TEA encryption function.

• void tea dec (iu32 ∗v, iu32 ∗k)

TEA decryption function.

6.31.1 Detailed Description

TEA declarations.

Documentation for TEA is available at http://www.cl.cam.ac.uk/ftp/users/djw3/tea.ps.

Id: tea.h,v 1.5 2002/12/22 15:42:55 m Exp

6.31.2 Define Documentation

6.31.2.1 #define DELTA 0x9E3779B9 Magic value. (Golden number ∗ 2^{∧}31).

6.31.2.2 #define ROUNDS 32 Number of rounds.

6.31.2.3 #define TEA BLOCK LEN 8 TEA block length.

6.31.2.4 #define TEA KEY LEN 16 TEA key size.

6.31.3 Function Documentation

6.31.3.1 void tea dec (iu32 ∗ v, iu32 ∗ k) TEA decryption function. This function decrypts v with k and returns the decrypted data in v.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Parameters: v Array of two long values containing the data block. k Array of four long values containing the key.

6.31.3.2 void tea enc (iu32 ∗ v, iu32 ∗ k) TEA encryption function. This function encrypts v with k and returns the encrypted data in v.

Parameters: v Array of two long values containing the data block. k Array of four long values containing the key.

6.32 tools.c File Reference

Tool functions.

#include <config.h>
#include <tools.h>
#include <types.h>

6.32.1 Detailed Description

Tool functions.

Id: tools.c,v 1.7 2002/12/22 15:42:55 m Exp

6.33 tools.h File Reference

Tool declarations.

#include <config.h>
#include <types.h>

Defines

• #define swap us(us) (((us&0x00FF)<<8)|((us&0xFF00)>>8))

Byte swap single short.

• #define swap ul(ul) (((ul&0x000000FF)<<24)|((ul&0x0000FF00)<<8)|((ul&0x00FF0000)>>8)|((ul&0x-

FF000000)>>24))

Byte swap single long.

• #define hton us(us)

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.33 tools.h File Reference  105

• #define hton ul(ul)

• #define min(a, b) ((a)<(b)?(a):(b))

• #define max(a, b) ((a)>(b)?(a):(b)) Functions

• void hton us (iu16 ∗us, iu8 num)

Byte swap multiple shorts.

• void hton ul (iu32 ∗ul, iu8 num)

Byte swap multiple longs.

6.33.1 Detailed Description Tool declarations. Id: tools.h,v 1.11 2002/12/22 15:42:56 m Exp 6.33.2 Define Documentation 6.33.2.1 #define hton ul(ul) 6.33.2.2 #define hton us(us) 6.33.2.3 #define max(a, b) ((a)>(b)?(a):(b)) Return maximum value 6.33.2.4 #define min(a, b) ((a)<(b)?(a):(b)) Return minimum value 6.33.2.5 #define swap ul(ul) (((ul&0x000000FF)<<24)|((ul&0x0000FF00)<<8)|((ul&0x00FF0000)>>8)|((ul&0x-FF000000)>>24)) Byte swap single long. 6.33.2.6 #define swap us(us) (((us&0x00FF)<<8)|((us&0x-FF00)>>8)) Byte swap single short.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.33.3 Function Documentation

6.33.3.1 void hton ul (iu32 ∗ ul, iu8 num) Byte swap multiple longs.

Parameters: ul Pointer to an array of longs.

num Number of longs to process.

6.33.3.2 void hton us (iu16 ∗ us, iu8 num) Byte swap multiple shorts.

Parameters: us Pointer to an array of shorts.

num Number of shorts to process.

6.34 transaction.c File Reference

Transaction functions.

#include <config.h>
#include <sw.h>
#include <hal.h>
#include <transaction.h>
#include <types.h>

Functions

• bool ta setdata (iu8 ∗data, iu8 len, iu16 dst)

Begins a transaction and sets the data.

• bool ta commit (void)

Commits the data in the transaction buffer.

6.34.1 Detailed Description

Transaction functions.

Id: transaction.c,v 1.11 2002/12/22 15:42:56 m Exp

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.34.2 Function Documentation

6.34.2.1 bool ta commit (void) Commits the data in the transaction buffer. Data is written to the destination specified in ta setdata() (p. 107). The state is then set to clean. This function must be called after each reset to commit pending transactions.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.34.2.2 bool ta setdata (iu8 ∗ data, iu8 len, iu16 dst) Begins a transaction and sets the data. data/len bytes are written to the transaction buffer. The destination address is also stored there. Then the state is set to TRANSAC STATE DATA.

Parameters: data Pointer to the data to write into the transaction buffer. len Length of the data. (Max.: TRANSAC DATA LEN) dst Destination of the data in EEPROM.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.35 transaction.h File Reference

Transaction declarations.

#include <types.h>

Defines • #define TRANSAC STATE CLEAN 0x00

• #define TRANSAC STATE DATA 0xA5

Transaction buffer contains data.

Functions

• bool ta setdata (iu8 ∗data, iu8 len, iu16 dst)

Begins a transaction and sets the data.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

• bool ta commit (void)

Commits the data in the transaction buffer.

• bool ta rollback (void)

Do a rollback and discard the data in the transaction buffer.

6.35.1 Detailed Description

Transaction declarations.

Note: Is the current transaction implementation secure against tearing? IMO it should be nearly be. Let’s consider following scenarios:

1) Card is removed while writing the data for the transaction: This is no problem, because the state is still TRANSAC STATE CLEAN.

2) Card is removed while writing the status byte: This is most likely no problem. If the state is anything other than TRANSAC STATE DATA, it is regarded as clean, which it is. The only problem is, when it accidently is TRANSAC - STATE DATA, which is IMO very unlikely, because the erased state is totally different. But on the other side, if the card tearing occured shortly after the state update, the state really is TRANSAC STATE DATA.

3) Card is removed while doing a commit and writing the data therein: This is no problem, because after the next reset the commit is tried again.

4) Card is removed after a commit, while reseting the status byte: This is no problem, because most likely the new state is interpreted as TRANSAC - STATE CLEAN, which it is, and if the new state is really TRANSAC STATE - DATA, it is just a second time written.

5) Card is removed while writing status byte in a rollback: This might be a problem, because the rollback might file, when the unlikely event occures, that the state is TRANSAC STATE DATA. But this can also happen, if the card is removed before the rollback, because the state is there already TRANSAC - STATE DATA.

Id: transaction.h,v 1.9 2002/12/22 15:42:56 m Exp

6.35.2 Define Documentation

6.35.2.1 #define TRANSAC STATE CLEAN 0x00

Transaction buffer is clean. (Also all other values not being 0xA5 are interpreted as clean.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.35.2.2 #define TRANSAC STATE DATA 0xA5 Transaction buffer contains data.

6.35.3 Function Documentation

6.35.3.1 bool ta commit (void) Commits the data in the transaction buffer. Data is written to the destination specified in ta setdata() (p. 107). The state is then set to clean. This function must be called after each reset to commit pending transactions.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.35.3.2 bool ta rollback (void) Do a rollback and discard the data in the transaction buffer. The state is set to clean.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.35.3.3 bool ta setdata (iu8 ∗ data, iu8 len, iu16 dst) Begins a transaction and sets the data. data/len bytes are written to the transaction buffer. The destination address is also stored there. Then the state is set to TRANSAC STATE DATA.

Parameters: data Pointer to the data to write into the transaction buffer. len Length of the data. (Max.: TRANSAC DATA LEN) dst Destination of the data in EEPROM.

Return values: TRUE on success.

FALSE on failure. Error code given in sw.

6.36 types.h File Reference

Type declarations.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.36 types.h File Reference  110

Defines • #define FALSE 0

• #define TRUE !FALSE

• #define PRG RDB(x) (∗((iu8∗)(x)))

• #define CODE Typedefs

• typedef unsigned char iu8

1 byte unsiged data type.

• typedef unsigned short iu16

2 byte unsigned data type.

• typedef unsigned long iu32

4 byte unsigned data type.

• typedef unsigned char bool

Boolean data type.

6.36.1 Detailed Description Type declarations. Id: types.h,v 1.12 2003/03/30 19:36:48 m Exp 6.36.2 Define Documentation 6.36.2.1 #define CODE 6.36.2.2 #define FALSE 0 6.36.2.3 #define PRG RDB(x) (∗((iu8∗)(x))) 6.36.2.4 #define TRUE !FALSE 6.36.3 Typedef Documentation 6.36.3.1 typedef unsigned char bool Boolean data type.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

6.36.3.2 typedef unsigned short iu16

2 byte unsigned data type.

6.36.3.3 typedef unsigned long iu32

4 byte unsigned data type.

6.36.3.4 typedef unsigned char iu8

1 byte unsiged data type.

7 SOSSE Page Documentation

7.1 Todo List

Class s fpath There is probably a potential for simplification, when the file type (DF/EF) is not handled so rigid.

File auth.h Here are certainly some optimizations possible to reduce code size.

Global CONF WITH FILESYSTEM Make this define something happen.

File fs.h Here are certainly some optimizations possible to reduce code size.

Global fs seek(iu16 fid, S FSTREAM ∗fs, S FINFO ∗fi, iu8 type)

There is probably a potential for simplification, when the file type is not handled so rigid.

Global selected Saving here a S FINFO and/or S FSTREAM of the selected file might reduce the code size.

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

Index

ac

s finfo, 20 ADM KEY LEN

config.h, 46 ARCH

config.h, 46 atr

ctapi.c, 54 ATR ADDR

config.h, 46 ATR LEN ADDR

config.h, 46 ATR MAXLEN

config.h, 46 atrlen

ctapi.c, 54 auth.c, 23

auth checkAc, 24 auth createVerifyCryptogram,

24 auth getChallenge, 25 auth getCheckPinLen, 25 auth init, 26 auth setPin, 26 auth verifyPin, 26 authstate, 27 challenge, 27 challvalidity, 27

auth.h, 27 AUTH AC ADM, 29 AUTH AC ALW, 29 AUTH AC NEV, 30 AUTH AC PAA, 30 AUTH AC PIN, 30 AUTH AC POA, 30 auth checkAc, 31 auth createVerifyCryptogram,

31 AUTH FID EXTAUTH, 30 AUTH FID INTAUTH, 30 AUTH FID PINPUK, 30 AUTH FLAG KEY, 30 AUTH FLAG PIN, 30 auth getChallenge, 32 auth getCheckPinLen, 32 auth init, 33 auth setPin, 33 auth verifyPin, 33 challvalidity, 34 KEY MAX RETRIES, 30 PIN MAX RETRIES, 30 PIN TYPE EXT, 31 PIN TYPE INT, 31 PIN TYPE PIN, 31 PIN TYPE PUK, 31 PUK MAX RETRIES, 31

AUTH AC ADM auth.h, 29 AUTH AC ALW auth.h, 29 AUTH AC NEV auth.h, 30 AUTH AC PAA auth.h, 30 AUTH AC PIN auth.h, 30 AUTH AC POA auth.h, 30

auth checkAc auth.c, 24 auth.h, 31

auth createVerifyCryptogram auth.c, 24 auth.h, 31 AUTH FID EXTAUTH auth.h, 30 AUTH FID INTAUTH auth.h, 30 AUTH FID PINPUK auth.h, 30 AUTH FLAG KEY auth.h, 30 AUTH FLAG PIN auth.h, 30 auth getChallenge auth.c, 25 auth.h, 32 auth getCheckPinLen auth.c, 25 auth.h, 32

auth init auth.c, 26 auth.h, 33

\underline{INDEX 113}

auth setPin auth.c, 26 auth.h, 33

auth verifyPin auth.c, 26 auth.h, 33

authstate auth.c, 27 authtest.c, 35 fstest.c, 70

authtest.c, 34 authstate, 35 challenge, 35 challvalidity, 35 main, 34

bool types.h, 110

CARD STATE ADDR

config.h, 46 challenge

auth.c, 27 authtest.c, 35

challvalidity auth.c, 27 auth.h, 34 authtest.c, 35

CHIP

config.h, 47 CLA

t0.h, 99 CLA PROP

commands.h, 40 cmd changeUnblockPIN

commands.c, 37 commands.h, 42

cmd create commands.c, 37 commands.h, 42

cmd delete commands.c, 37 commands.h, 42

cmd extAuth commands.c, 37 commands.h, 42

cmd getChallenge commands.c, 37 commands.h, 42

cmd getResponse commands.h, 42 cmd intAuth

commands.c, 37 commands.h, 42

cmd led

commands.h, 42 cmd read

commands.c, 37 commands.h, 42

cmd readBinary commands.c, 37 commands.h, 42

cmd select commands.c, 37 commands.h, 42

cmd updateBinary commands.c, 37 commands.h, 42

cmd verifyKeyPIN commands.c, 37 commands.h, 43

cmd write commands.c, 37 commands.h, 43

CODE

types.h, 110 commands.c, 35

cmd changeUnblockPIN, 37 cmd create, 37 cmd delete, 37 cmd extAuth, 37 cmd getChallenge, 37 cmd intAuth, 37 cmd read, 37 cmd readBinary, 37 cmd select, 37 cmd updateBinary, 37 cmd verifyKeyPIN, 37 cmd write, 37 pin1len, 36 pinssize, 36

commands.h, 38 CLA PROP, 40 cmd changeUnblockPIN, 42 cmd create, 42 cmd delete, 42 cmd extAuth, 42 cmd getChallenge, 42 cmd getResponse, 42 cmd intAuth, 42 cmd led, 42

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

cmd read, 42 cmd readBinary, 42 cmd select, 42 cmd updateBinary, 42 cmd verifyKeyPIN, 43 cmd write, 43 INS CHANGE PIN, 40 INS CREATE, 40 INS DELETE, 40 INS EXTERNAL AUTH, 40 INS GET CHALLENGE, 41 INS GET RESPONSE, 41 INS INTERNAL AUTH, 41 INS LED, 41 INS READ, 41 INS READ BINARY, 41 INS SELECT, 41 INS UNBLOCK PIN, 41 INS UPDATE BINARY, 41 INS VERIFY KEY, 41 INS VERIFY PIN, 41 INS WRITE, 41 resplen, 43

CONF IODATA SIZE

config.h, 47 CONF WITH CREATECMD

config.h, 47 CONF WITH CRYPT ALGO

config.h, 47 CONF WITH DECRYPT

config.h, 47 CONF WITH DELETECMD

config.h, 47 CONF WITH FILESYSTEM

config.h, 47 CONF WITH FUNNY

config.h, 47 CONF WITH I2CEEPROM

config.h, 48 CONF WITH KEYAUTH

config.h, 48 CONF WITH KEYCMDS

config.h, 48 CONF WITH LOGGING

config.h, 48 CONF WITH PINAUTH

config.h, 48 CONF WITH PINCMDS

config.h, 48 CONF WITH RECORD FILES

config.h, 48 CONF WITH RETCODEMGR

config.h, 48 CONF WITH TESTCMDS

config.h, 49 CONF WITH TRANSACTIONS

config.h, 49 CONF WITH TRNG config.h, 49

config.h, 43 ADM KEY LEN, 46 ARCH, 46 ATR ADDR, 46 ATR LEN ADDR, 46 ATR MAXLEN, 46 CARD STATE ADDR, 46 CHIP, 47 CONF IODATA SIZE, 47 CONF WITH CREATECMD,

47 CONF WITH CRYPT - ALGO, 47

CONF WITH DECRYPT, 47 CONF WITH DELETECMD,

47 CONF WITH FILESYSTEM,

47 CONF WITH FUNNY, 47 CONF WITH I2CEEPROM,

48 CONF WITH KEYAUTH, 48 CONF WITH KEYCMDS, 48 CONF WITH LOGGING, 48 CONF WITH PINAUTH, 48 CONF WITH PINCMDS, 48 CONF WITH RECORD -

FILES, 48 CONF WITH -

RETCODEMGR, 48 CONF WITH TESTCMDS,

49 CONF WITH -

TRANSACTIONS, 49 CONF WITH TRNG, 49 DATA END 1, 49 EEPROM SIZE, 49 ENDIAN LITTLE, 49 ESIZ, 49 FS START PTR ADDR, 49 INT KEY LEN, 49

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

PIN LEN, 49 PUK LEN, 49 RAM SIZE, 50 RAND STATE ADDR, 50 RAND STATE LEN, 50 SERNUM ADDR, 50 SERNUM LEN, 50 TRANSAC DATA ADDR, 50 TRANSAC DATA LEN, 50 TRANSAC STATE ADDR, 50

crypt.h, 50

CRYPT ALGO NEWDESSK,

51 CRYPT ALGO SKIPJACK,

51 CRYPT ALGO TEA, 51 CRYPT BLOCK LEN, 51 crypt dec, 52 crypt enc, 52 CRYPT KEY LEN, 52

CRYPT ALGO NEWDESSK

crypt.h, 51 CRYPT ALGO SKIPJACK

crypt.h, 51 CRYPT ALGO TEA

crypt.h, 51 CRYPT BLOCK LEN

crypt.h, 51 crypt dec

crypt.h, 52 crypt enc

crypt.h, 52 CRYPT KEY LEN

crypt.h, 52 CT close

ctapi.c, 53 ctapi.h, 58

CT data ctapi.c, 53 ctapi.h, 58

CT forkIcc ctapi.c, 53 ctapi.h, 58

CT iccCmd ctapi.c, 53 ctapi.h, 58

CT ifdCmd ctapi.c, 53 ctapi.h, 58

CT ifdCmdEepromFile ctapi.c, 53 ctapi.h, 58

CT ifdCmdEjectICC ctapi.c, 54 ctapi.h, 58

CT ifdCmdGetStatus ctapi.c, 54 ctapi.h, 58

CT ifdCmdRequestICC ctapi.c, 54 ctapi.h, 58

CT ifdCmdResetCT ctapi.c, 54 ctapi.h, 59

CT init ctapi.c, 54 ctapi.h, 59

CT stopIcc ctapi.c, 54 ctapi.h, 59

CT t0

ctapi.c, 54 ctapi.c, 52

atr, 54 atrlen, 54 CT close, 53 CT data, 53 CT forkIcc, 53 CT iccCmd, 53 CT ifdCmd, 53 CT ifdCmdEepromFile, 53 CT ifdCmdEjectICC, 54 CT ifdCmdGetStatus, 54 CT ifdCmdRequestICC, 54 CT ifdCmdResetCT, 54 CT init, 54 CT stopIcc, 54 CT t0, 54 cthandle, 54 eepromFile, 54 fd fromCard, 54 fd toCard, 55 fdEepromFile, 55 loadEepromFile, 55 pidVirtuaCard, 55 saveEepromFile, 55

ctapi.h, 55 CT close, 58 CT data, 58 CT forkIcc, 58

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

CT iccCmd, 58 CT ifdCmd, 58 CT ifdCmdEepromFile, 58 CT ifdCmdEjectICC, 58 CT ifdCmdGetStatus, 58 CT ifdCmdRequestICC, 58 CT ifdCmdResetCT, 59 CT init, 59 CT stopIcc, 59 CTAPI AD CT, 56 CTAPI AD HOST, 56 CTAPI AD ICC1, 56 CTAPI CLA, 57 CTAPI INS EEPROM, 57 CTAPI INS EJECT ICC, 57 CTAPI INS GET STATUS,

57 CTAPI INS REQUEST ICC,

57 CTAPI INS RESET CT, 57 CTAPI PORT, 57 CTAPI RV ERR CT, 57 CTAPI RV ERR HOST, 57 CTAPI RV ERR HTSI, 57 CTAPI RV ERR INVALID,

57 CTAPI RV ERR MEMORY,

57 CTAPI RV ERR TRANS, 57 CTAPI RV OK, 57 eepromFile, 59 fd fromCard, 59 fd toCard, 59 fdEepromFile, 59 IS16, 57 IS32, 57 IS8, 57 IU16, 57 IU32, 58 IU8, 58 loadEepromFile, 59 saveEepromFile, 59

CTAPI AD CT

ctapi.h, 56 CTAPI AD HOST

ctapi.h, 56 CTAPI AD ICC1

ctapi.h, 56 CTAPI CLA

ctapi.h, 57 CTAPI INS EEPROM ctapi.h, 57 CTAPI INS EJECT ICC ctapi.h, 57

CTAPI INS GET STATUS

ctapi.h, 57 CTAPI INS REQUEST ICC

ctapi.h, 57 CTAPI INS RESET CT ctapi.h, 57 CTAPI PORT ctapi.h, 57 CTAPI RV ERR CT ctapi.h, 57 CTAPI RV ERR HOST ctapi.h, 57 CTAPI RV ERR HTSI ctapi.h, 57

CTAPI RV ERR INVALID

ctapi.h, 57 CTAPI RV ERR MEMORY

ctapi.h, 57 CTAPI RV ERR TRANS

ctapi.h, 57 CTAPI RV OK ctapi.h, 57

cthandle ctapi.c, 54

DATA END 1

config.h, 49 DELTA

tea.h, 103 df

s fpath, 21

eeprom

hal-emu.c, 77 EEPROM SIZE config.h, 49

eepromFile ctapi.c, 54 ctapi.h, 59

ef

s fpath, 21 ENDIAN LITTLE config.h, 49

ESIZ config.h, 49

FALSE

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

types.h, 110 fd fromCard

ctapi.c, 54 ctapi.h, 59

fd toCard ctapi.c, 55 ctapi.h, 59

fdEepromFile ctapi.c, 55 ctapi.h, 59

fid

s finfo, 20 fs.c, 59

fs create, 61 fs delete, 61 fs getData, 61 fs getFPath, 61 fs init, 62 fs seek, 62 fs seekEnd, 62 fssize, 63 fsstart, 63 selected, 63

fs.h, 63 fs create, 66 fs delete, 66 fs getData, 67 fs getFPath, 67 FS HEADER SIZE, 65 fs init, 67 fs seek, 68 fs seekEnd, 68 FS TYPE DF, 65 FS TYPE EF, 66 FS TYPE EF FIXED, 66 FS TYPE EF TRANSP, 66 S FINFO, 66 S FPATH, 66 selected, 68

fs create fs.c, 61 fs.h, 66

fs delete fs.c, 61 fs.h, 66

fs getData fs.c, 61 fs.h, 67

fs getFPath fs.c, 61

fs.h, 67 FS HEADER SIZE fs.h, 65

fs init fs.c, 62 fs.h, 67

fs seek fs.c, 62 fs.h, 68

fs seekEnd fs.c, 62 fs.h, 68

FS START PTR ADDR config.h, 49

FS TYPE DF fs.h, 65 FS TYPE EF fs.h, 66

FS TYPE EF FIXED

fs.h, 66 FS TYPE EF TRANSP

fs.h, 66 fssize

fs.c, 63 fstest.c, 70

fsstart fs.c, 63 fstest.c, 70

fstest.c, 69 authstate, 70 fssize, 70 fsstart, 70 main, 69 fstream.c, 70

fstream read, 71 fstream test, 71 fstream write, 71

fstream.h, 72 fstream read, 73 fstream test, 73 fstream write, 73 S FSTREAM, 72

fstream read fstream.c, 71 fstream.h, 73

fstream test fstream.c, 71 fstream.h, 73

fstream write fstream.c, 71

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

fstream.h, 73

hal-emu.c, 74 eeprom, 77 hal destroy, 75 hal eeprom read, 75 hal eeprom write, 75 hal init, 76 hal io recByteT0, 76 hal io sendByteT0, 76 hal rnd getBlock, 76 halsend, 77 PORT, 75

hal.c, 77 hal eeprom read, 78 hal eeprom write, 78 hal init, 78 hal io recByteT0, 78 hal io sendByteT0, 79 hal rnd getBlock, 79 recbytet0, 79 sendbytet0, 79 xeread, 79 xewrt, 79

hal.h, 80 hal eeprom read, 81 hal eeprom write, 81 hal init, 81 hal io recByteT0, 81 hal io sendByteT0, 81 hal led, 82 hal rnd addEntropy, 82 hal rnd getBlock, 83

hal destroy

hal-emu.c, 75 hal eeprom read

hal-emu.c, 75 hal.c, 78 hal.h, 81

hal eeprom write hal-emu.c, 75 hal.c, 78 hal.h, 81

hal init hal-emu.c, 76 hal.c, 78 hal.h, 81

hal io recByteT0 hal-emu.c, 76 hal.c, 78

hal.h, 81 hal io sendByteT0 hal-emu.c, 76 hal.c, 79 hal.h, 81

hal led

hal.h, 82 hal rnd addEntropy hal.h, 82 hal rnd getBlock

hal-emu.c, 76 hal.c, 79 hal.h, 83

halsend

hal-emu.c, 77 hton ul

tea.c, 102

tools.h, 105, 106 hton us

tools.h, 105, 106

INS

t0.h, 99 INS CHANGE PIN

commands.h, 40 INS CREATE

commands.h, 40 INS DELETE

commands.h, 40 INS EXTERNAL AUTH commands.h, 40 INS GET CHALLENGE commands.h, 41 INS GET RESPONSE commands.h, 41 INS INTERNAL AUTH commands.h, 41

INS LED

commands.h, 41 INS READ

commands.h, 41 INS READ BINARY commands.h, 41

INS SELECT

commands.h, 41 INS UNBLOCK PIN commands.h, 41 INS UPDATE BINARY commands.h, 41

INS VERIFY KEY

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

commands.h, 41 INS VERIFY PIN

commands.h, 41 INS WRITE

commands.h, 41 INT KEY LEN

config.h, 49 iodata

t0.c, 97 t0.h, 101

iodatalen t0.c, 97 t0.h, 101

ioheader t0.c, 97 t0.h, 101

ioin t0.c, 97 t0.h, 101

iosend

t0.c, 97 IS16

ctapi.h, 57 IS32

ctapi.h, 57 IS8

ctapi.h, 57 IU16

ctapi.h, 57 iu16

types.h, 110 IU32

ctapi.h, 58 iu32

types.h, 111 IU8

ctapi.h, 58 iu8

types.h, 111

KEY MAX RETRIES auth.h, 30

loadEepromFile ctapi.c, 55 ctapi.h, 59

log.c, 83 log.h, 84

log add, 85 log enable, 86 log init, 85 LOG START, 85 LOG TAG EEREAD DST, 85 LOG TAG EEREAD LEN, 85 LOG TAG EEREAD SRC, 85 LOG TAG EEWRITE DST,

85 LOG TAG EEWRITE LEN,

85 LOG TAG EEWRITE SRC,

86 LOG TAG FSCREATE, 86 LOG TAG JOKER, 86 LOG TAG RANDOM, 86

log add

log.h, 85 log enable

log.h, 86 log init

log.h, 85 LOG START

log.h, 85 LOG TAG EEREAD DST

log.h, 85 LOG TAG EEREAD LEN

log.h, 85 LOG TAG EEREAD SRC

log.h, 85 LOG TAG EEWRITE DST

log.h, 85 LOG TAG EEWRITE LEN

log.h, 85 LOG TAG EEWRITE SRC

log.h, 86 LOG TAG FSCREATE

log.h, 86 LOG TAG JOKER

log.h, 86 LOG TAG RANDOM

log.h, 86

main authtest.c, 34 fstest.c, 69 main.c, 87

main.c, 86

main, 87 main.h, 87 max

tools.h, 105

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

min tools.h, 105

newdes-sk.c, 87 newdes-sk.h, 87

NEWDESSK BLOCK LEN,

88 newdessk dec, 88 newdessk enc, 88 NEWDESSK KEY LEN, 88

NEWDESSK BLOCK LEN

newdes-sk.h, 88 newdessk dec

newdes-sk.h, 88 newdessk enc

newdes-sk.h, 88 NEWDESSK KEY LEN

newdes-sk.h, 88

P1

t0.h, 99 P2

t0.h, 99 P3

t0.h, 99 pidVirtuaCard

ctapi.c, 55 pin1len

commands.c, 36 PIN LEN

config.h, 49 PIN MAX RETRIES

auth.h, 30 PIN TYPE EXT

auth.h, 31 PIN TYPE INT

auth.h, 31 PIN TYPE PIN

auth.h, 31 PIN TYPE PUK

auth.h, 31 pinssize

commands.c, 36 PORT

hal-emu.c, 75 pos

s fstream, 22 PRG RDB

types.h, 110 PUK LEN

config.h, 49 PUK MAX RETRIES

auth.h, 31

RAM SIZE

config.h, 50 RAND STATE ADDR

config.h, 50 RAND STATE LEN

config.h, 50 recbytet0

hal.c, 79 resplen

commands.h, 43 ROUNDS

tea.h, 103

S FINFO

fs.h, 66 s finfo, 20

ac, 20 fid, 20 size, 21 type, 21

S FPATH

fs.h, 66 s fpath, 21

df, 21 ef, 21

S FSTREAM

fstream.h, 72 s fstream, 22

pos, 22 size, 22 start, 22

saveEepromFile ctapi.c, 55 ctapi.h, 59

selected fs.c, 63 fs.h, 68

sendbytet0

hal.c, 79 SERNUM ADDR

config.h, 50 SERNUM LEN

config.h, 50 size

s finfo, 21 s fstream, 22

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

skipjack.c, 88 skipjack.h, 89

SKIPJACK BLOCK LEN, 90 skipjack dec, 90 skipjack enc, 90 SKIPJACK KEY LEN, 90

SKIPJACK BLOCK LEN

skipjack.h, 90 skipjack dec

skipjack.h, 90 skipjack enc

skipjack.h, 90 SKIPJACK KEY LEN

skipjack.h, 90 start

s fstream, 22 SW

sw.h, 92 t0.c, 95

sw sw.c, 91 sw.h, 94

sw.c, 90 sw, 91 sw set, 91

sw.h, 91 SW, 92 sw, 94 SW ACCESS DENIED, 93 SW AUTH BLOCKED, 93 SW AVAILABLE, 93 SW CHANGE MEMORY -

ERROR, 93 SW COUNTER, 93 SW EOD, 93 SW FILE EXISTS, 93 SW FILE FILLED, 93 SW FILE NOT FOUND, 93 SW FILE TO SHORT, 93 sw get, 92 SW INCOMPATIBLE FILE,

93 SW LC INCONSISTEND -

WITH P1P2, 93 SW NOT ALLOWED, 93 SW NOT SUPPORTED, 93 SW OK, 93 SW OTHER, 93 SW REF DATA INVALID, 93 SW REF DATA NOT - FOUND, 93

sw set, 93

SW VERIFCATION FAILED,

93 SW WRONG CLA, 93 SW WRONG CONDITION,

93 SW WRONG DATA, 93 SW WRONG INS, 93 SW WRONG LE, 93 SW WRONG LEN, 93 SW WRONG P1P2, 93 SW WRONG REFERENCE,

93 SW ACCESS DENIED

sw.h, 93 SW AUTH BLOCKED

sw.h, 93 SW AVAILABLE sw.h, 93

SW CHANGE MEMORY ERROR

sw.h, 93 SW COUNTER sw.h, 93

SW EOD

sw.h, 93 SW FILE EXISTS sw.h, 93 SW FILE FILLED sw.h, 93

SW FILE NOT FOUND

sw.h, 93 SW FILE TO SHORT sw.h, 93

sw get

sw.h, 92 SW INCOMPATIBLE FILE

sw.h, 93 SW LC INCONSISTEND WITH -

P1P2 sw.h, 93 SW NOT ALLOWED sw.h, 93

SW NOT SUPPORTED

sw.h, 93 SW OK

sw.h, 93 SW OTHER sw.h, 93

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

SW REF DATA INVALID

sw.h, 93 SW REF DATA NOT FOUND

sw.h, 93 sw set

sw.c, 91 sw.h, 93

SW VERIFCATION FAILED

sw.h, 93 SW WRONG CLA

sw.h, 93 SW WRONG CONDITION

sw.h, 93 SW WRONG DATA

sw.h, 93 SW WRONG INS

sw.h, 93 SW WRONG LE

sw.h, 93 SW WRONG LEN

sw.h, 93 SW WRONG P1P2

sw.h, 93 SW WRONG REFERENCE

sw.h, 93 swap ul

tools.h, 105 swap us

tools.h, 105

t0.c, 94 iodata, 97 iodatalen, 97 ioheader, 97 ioin, 97 iosend, 97 SW, 95 t0 dir, 95 t0 exchApdu, 95 t0 getResponse, 96 t0 init, 96 t0 recBlock, 96 t0 testP1P2, 96 t0 testP3, 96 t0 wtx, 97

t0.h, 97 CLA, 99 INS, 99 iodata, 101 iodatalen, 101 ioheader, 101 ioin, 101 P1, 99 P2, 99 P3, 99 t0 dir, 99 T0 DIR IN, 99 T0 DIR OUT, 99 t0 exchApdu, 99 t0 getResponse, 99 t0 init, 100 t0 recBlock, 100 t0 testP1P2, 100 t0 testP3, 100 t0 wtx, 100

t0 dir t0.c, 95 t0.h, 99

T0 DIR IN

t0.h, 99 T0 DIR OUT

t0.h, 99 t0 exchApdu

t0.c, 95 t0.h, 99

t0 getResponse t0.c, 96 t0.h, 99

t0 init t0.c, 96 t0.h, 100

t0 recBlock t0.c, 96 t0.h, 100

t0 testP1P2 t0.c, 96 t0.h, 100

t0 testP3 t0.c, 96 t0.h, 100

t0 wtx t0.c, 97 t0.h, 100

ta commit transaction.c, 107 transaction.h, 109

ta rollback

transaction.h, 109 ta setdata

transaction.c, 107

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002

transaction.h, 109 tea.c, 101

hton ul, 102 tea dec, 102 tea enc, 102 tea func, 102 TEA SMALL, 102

tea.h, 102 DELTA, 103 ROUNDS, 103 TEA BLOCK LEN, 103 tea dec, 103 tea enc, 104 TEA KEY LEN, 103

TEA BLOCK LEN

tea.h, 103 tea dec

tea.c, 102 tea.h, 103

tea enc tea.c, 102 tea.h, 104

tea func

tea.c, 102 TEA KEY LEN

tea.h, 103 TEA SMALL

tea.c, 102 tools.c, 104 tools.h, 104

hton ul, 105, 106 hton us, 105, 106 max, 105 min, 105 swap ul, 105 swap us, 105

TRANSAC DATA ADDR

config.h, 50 TRANSAC DATA LEN

config.h, 50 TRANSAC STATE ADDR

config.h, 50 TRANSAC STATE CLEAN

transaction.h, 108 TRANSAC STATE DATA

transaction.h, 108 transaction.c, 106

ta commit, 107 ta setdata, 107

transaction.h, 107 ta commit, 109 ta rollback, 109 ta setdata, 109 TRANSAC STATE CLEAN,

108 TRANSAC STATE DATA,

108 TRUE

types.h, 110 type

s finfo, 21 types.h, 109

bool, 110 CODE, 110 FALSE, 110 iu16, 110 iu32, 111 iu8, 111 PRG RDB, 110 TRUE, 110

xeread

hal.c, 79 xewrt

hal.c, 79

Generated on Wed Jul 9 16:22:08 2003 for SOSSE by Doxygen written by Dimitri van Heesch

\begin{matrix}c \\ ◯ \end{matrix} 1997-2002