#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 |
CRP * | transactionData [MAX_EXCHANGES] |
uint8_t | nTransactions |
uint8_t | lcdAvailable |
uint8_t | nCounter |
uint8_t | selected |
uint8_t | bootkey |
volatile uint32_t | usCounter |
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 APP_LOG_GENERATE_AC 0x05 |
#define APP_VIRTUAL_SERIAL_PORT 0x01 |
#define MAX_EXCHANGES 50 |
void EraseEEPROM | ( | ) |
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
logger | the log structure or NULL if log is not desired |
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.
logger | the log structure or NULL if log is not desired |
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.
logger | the log structure or NULL if log is not desired |
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.
logger | the log structure or NULL if log is not desired |
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.
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
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
logger | the log structure or NULL if log is not desired |
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).
logger | the log structure or NULL if log is not desired |
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).
logger | the log structure. If this is NULL the function will exit promptly. |
uint8_t lcdAvailable |
uint8_t nTransactions |
CRP* transactionData[MAX_EXCHANGES] |
volatile uint32_t usCounter |
uint8_t warmResetByte |