apps.h File Reference

apps.h header file More...

#include <avr/io.h>
#include "emv.h"
#include "scd_logger.h"

Go to the source code of this file.

Defines

#define MAX_EXCHANGES   50
 Maximum number of command-response pairs recorded when logging.
#define MAGIC_BOOT_KEY   0x77
 Use for bootloader jump.
#define EEPROM_PIN   0x8
 EEPROM address for stored PIN.
#define APP_VIRTUAL_SERIAL_PORT   0x01
 USB Virtual Serial Port.
#define APP_FORWARD   0x02
 Forward data and make log.
#define APP_FILTER_GENERATEAC   0x03
 Filter Transaction Amount.
#define APP_TERMINAL   0x04
 Terminal application.
#define APP_LOG_GENERATE_AC   0x05
 Forward data and log from Generate AC only.
#define APP_ERASE_EEPROM   0x06
 Erase EEPROM.
#define APP_SERIAL_PORT   0x07
 Serial Port.
#define APPLICATION_COUNT   7
 Number of existing applications.

Functions

uint8_t VirtualSerial ()
 Virtual Serial Port (send/receive command strings).
uint8_t SerialInterface ()
 Serial Port interface (send/receive command strings).
void EraseEEPROM ()
 Clears the contents of the EEPROM.
void ResetEEPROM ()
 Resets the data in EEPROM to default values.
void RunBootloader ()
 Jump to bootloader.
uint8_t ForwardData (log_struct_t *logger)
 Forward commands between terminal and ICC through the ICC.
uint8_t ForwardDataLogAC (log_struct_t *logger)
 Forward commands and responses but log only from Generate AC onwards.
uint8_t FilterGenerateAC (log_struct_t *logger)
 Filter Generate AC command until user accepts or denies the transaction.
uint8_t StorePIN (log_struct_t *logger)
 Stores the PIN data from VERIFY command to EEPROM.
uint8_t ForwardAndChangePIN (log_struct_t *logger)
 Forward commands and modify VERIFY command with EEPROM PIN data.
uint8_t Terminal (log_struct_t *logger)
 Run the terminal application.
void WriteLogEEPROM (log_struct_t *logger)
 Write the log of the last transaction to EEPROM.

Variables

uint8_t warmResetByte
CRPtransactionData [MAX_EXCHANGES]
uint8_t nTransactions
uint8_t lcdAvailable
uint8_t nCounter
uint8_t selected
uint8_t bootkey
volatile uint32_t usCounter

Detailed Description

apps.h header file

This file defines the applications available on the SCD

These functions are not microcontroller dependent but they are intended for the AVR 8-bit architecture

Copyright (C) 2012 Omar Choudary (omar.choudary@cl.cam.ac.uk)

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file apps.h.


Define Documentation

#define APP_ERASE_EEPROM   0x06

Erase EEPROM.

Definition at line 64 of file apps.h.

#define APP_FILTER_GENERATEAC   0x03

Filter Transaction Amount.

Definition at line 58 of file apps.h.

#define APP_FORWARD   0x02

Forward data and make log.

Definition at line 56 of file apps.h.

#define APP_LOG_GENERATE_AC   0x05

Forward data and log from Generate AC only.

Definition at line 62 of file apps.h.

#define APP_SERIAL_PORT   0x07

Serial Port.

Definition at line 66 of file apps.h.

#define APP_TERMINAL   0x04

Terminal application.

Definition at line 60 of file apps.h.

#define APP_VIRTUAL_SERIAL_PORT   0x01

USB Virtual Serial Port.

Application IDs used in the application selection menu

Definition at line 54 of file apps.h.

#define APPLICATION_COUNT   7

Number of existing applications.

Definition at line 69 of file apps.h.

#define EEPROM_PIN   0x8

EEPROM address for stored PIN.

Definition at line 50 of file apps.h.

#define MAGIC_BOOT_KEY   0x77

Use for bootloader jump.

Definition at line 47 of file apps.h.

#define MAX_EXCHANGES   50

Maximum number of command-response pairs recorded when logging.

Definition at line 44 of file apps.h.


Function Documentation

void EraseEEPROM (  ) 

Clears the contents of the EEPROM.

This function erases the entire contents of the EEPROM. Interrupts are disabled during operation.

Definition at line 183 of file apps.c.

uint8_t FilterGenerateAC ( log_struct_t logger  ) 

Filter Generate AC command until user accepts or denies the transaction.

This function initiates the communication between ICC and terminal and then forwards the commands and responses from terminal to ICC but blocks the Generate AC request until the user accepts or denies the transaction.

Transaction amount is displayed on LCD and thus the LCD is required for this application.

If the terminal enables the reset line (either by warm reset or by interrupting the transaction the INT0 interrupt routing will be called

Parameters:
logger the log structure or NULL if log is not desired
Returns:
0 if successful, non-zero otherwise

Definition at line 601 of file apps.c.

uint8_t ForwardAndChangePIN ( log_struct_t logger  ) 

Forward commands and modify VERIFY command with EEPROM PIN data.

This function is similar to ForwardData but it modifies the VERIFY command. The command data of the VERIFY command is replaced with stored data in EEPROM when the command is sent to the ICC.

Parameters:
logger the log structure or NULL if log is not desired
Returns:
0 if successful, non-zero otherwise
See also:
ForwardData

Definition at line 1013 of file apps.c.

uint8_t ForwardData ( log_struct_t logger  ) 

Forward commands between terminal and ICC through the ICC.

This function initiates the communication between ICC and terminal and then forwards the commands and responses from terminal to ICC and back until the terminal sends a reset signal.

When a reset signal is received the SCD restarts. The reset signal can be used to copy the log data into EEPROM as in the current implementation. The EEPROM data can then be retrieved using any programmer.

Parameters:
logger the log structure or NULL if log is not desired
Returns:
0 if successful, non-zero otherwise. See scd_values.h for details.

Definition at line 1176 of file apps.c.

uint8_t ForwardDataLogAC ( log_struct_t logger  ) 

Forward commands and responses but log only from Generate AC onwards.

This function passively monitors a transaction, similarly to ForwardData, but it only logs the messages starting from the first Generate AC command in order to save space in EEPROM.

Parameters:
logger the log structure or NULL if log is not desired
Returns:
0 if successful, non-zero otherwise
See also:
ForwardData

Definition at line 1258 of file apps.c.

void ResetEEPROM (  ) 

Resets the data in EEPROM to default values.

Reset the data in EEPROM to default values. This method will first erase the EEPROM contents and then set the default values. Interrupts are disabled during operation.

See also:
EraseEEPROM

Definition at line 213 of file apps.c.

void RunBootloader (  ) 

Jump to bootloader.

Jump into the Bootloader application, typically the DFU bootloader for USB programming.

Code taken from: http://www.fourwalledcubicle.com/files/LUFA/Doc/100807/html/_page__software_bootloader_start.html

Definition at line 236 of file apps.c.

uint8_t SerialInterface (  ) 

Serial Port interface (send/receive command strings).

uint8_t StorePIN ( log_struct_t logger  ) 

Stores the PIN data from VERIFY command to EEPROM.

This function forwards commands between the terminal and ICC much like the ForwardData method, but when it receives the Verify command it stores the PIN entered by the user in the EEPROM. This is useful in order to store the PIN once and then use it in further transactions so that the original PIN is never revealed.

This method returns immediately after receiving the verify command. Thus PIN entry should be done for example using a CAP reader, where the completion of this transaction is not essential.

The PIN is stored in the EEPROM at the address mentioned by the parameter EEPROM_PIN

Parameters:
logger the log structure or NULL if log is not desired
Returns:
This method returns zero (success) if the verify command is sent with plaintext PIN. The method returns non-zero otherwise.

Definition at line 904 of file apps.c.

uint8_t Terminal ( log_struct_t logger  ) 

Run the terminal application.

This method implements a terminal application with the basic steps of an EMV transaction. This includes selection by AID, DDA signature, PIN verification and transaction data authorization (Generate AC).

Parameters:
logger the log structure or NULL if log is not desired
Returns:
0 if successful, non-zero otherwise

Definition at line 331 of file apps.c.

uint8_t VirtualSerial (  ) 

Virtual Serial Port (send/receive command strings).

void WriteLogEEPROM ( log_struct_t logger  ) 

Write the log of the last transaction to EEPROM.

This method writes to EEPROM the log of the last transaction. The log is done either while monitoring a card-terminal transaction or by enabling logging while running other application (e.g. the Terminal() application).

Parameters:
logger the log structure. If this is NULL the function will exit promptly.

Definition at line 1388 of file apps.c.


Variable Documentation

uint8_t bootkey

Definition at line 99 of file scd.c.

uint8_t lcdAvailable

Definition at line 96 of file scd.c.

uint8_t nCounter

Definition at line 97 of file scd.c.

uint8_t nTransactions
uint8_t selected

Definition at line 98 of file scd.c.

CRP* transactionData[MAX_EXCHANGES]
volatile uint32_t usCounter
uint8_t warmResetByte

Definition at line 95 of file scd.c.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated on Tue Apr 24 12:00:29 2012 for The Smart Card Detective (SCD) by  doxygen 1.6.3