scd_hal.h - SCD hardware abstraction layer header file for AT90USB1287 More...
Go to the source code of this file.
Functions | |
uint16_t | GetTerminalFreq () |
Returns the frequency of the terminal clock in khz, zero if there is no clock. | |
uint16_t | ReadCounterTerminal () |
Reads the value of the terminal counter. | |
void | StartCounterTerminal () |
Starts the counter for the external clock given by the terminal. | |
void | StopCounterTerminal () |
Stops the terminal clock counter. | |
void | PauseCounterTerminal () |
Pauses the terminal clock counter. | |
uint8_t | GetResetStateTerminal () |
Retrieves the state of the reset line from the terminal. | |
uint8_t | SendByteTerminalParity (uint8_t byte, uint8_t inverse_convention) |
Sends a byte to the terminal with parity check. | |
void | SendByteTerminalNoParity (uint8_t byte, uint8_t inverse_convention) |
Sends a byte to the terminal without parity check. | |
uint8_t | GetByteTerminalParity (uint8_t inverse_convention, uint8_t *r_byte) |
Receives a byte from the terminal with parity check. | |
uint8_t | GetByteTerminalNoParity (uint8_t inverse_convention, uint8_t *r_byte) |
Receives a byte from the terminal without parity check. | |
void | LoopTerminalETU (uint8_t nEtus) |
Waits (loops) for a number of nEtus based on the Terminal clock. | |
void | SendT0ATRTerminal (uint8_t inverse_convention, uint8_t TC1) |
Sends default ATR for T=0 to terminal. | |
uint8_t | IsICCInserted () |
Returns non-zero if ICC is inserted, zero otherwise. | |
uint8_t | IsICCPowered () |
Returns non-zero if ICC is powered up. | |
uint8_t | PowerUpIcc () |
Powers up the card, if possible. | |
void | PowerDownICC () |
Powers down the ICC. | |
void | LoopICCETU (uint8_t nEtus) |
Waits (loops) for a number of nEtus based on the ICC clock. | |
uint8_t | WaitForICCData (uint16_t max_cycles) |
Loops for max_cycles or until the I/O line from ICC becomes low. | |
uint8_t | GetByteICCNoParity (uint8_t inverse_convention, uint8_t *r_byte) |
Receives a byte from the ICC without parity checking. | |
uint8_t | GetByteICCParity (uint8_t inverse_convention, uint8_t *r_byte) |
Receives a byte from the ICC with parity checking. | |
void | SendByteICCNoParity (uint8_t byte, uint8_t inverse_convention) |
Sends a byte to the ICC without parity check. | |
uint8_t | SendByteICCParity (uint8_t byte, uint8_t inverse_convention) |
Sends a byte to the ICC with parity check. | |
uint8_t | GetATRICC (uint8_t *inverse_convention, uint8_t *proto, uint8_t *TC1, uint8_t *TA3, uint8_t *TB3) |
Receives the ATR from ICC after a successful activation. | |
uint8_t | ResetICC (uint8_t warm, uint8_t *inverse_convention, uint8_t *proto, uint8_t *TC1, uint8_t *TA3, uint8_t *TB3) |
Starts a cold or warm reset for ICC. | |
uint8_t | ActivateICC (uint8_t warm) |
Starts the activation sequence for the ICC. | |
void | DeactivateICC () |
Starts the deactivation sequence for the ICC. |
scd_hal.h - SCD hardware abstraction layer header file for AT90USB1287
This file provides an abstract definition for all micro-controller dependent functions that are used in the Smartcard Defender
For each microcontroller a different halSCD.c source file should be used.
Copyright (C) 2010 Omar Choudary (osc22@cam.ac.uk)
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 3 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 MERCHANTABILITY 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, see <http://www.gnu.org/licenses/>.
Definition in file scd_hal.h.
uint8_t ActivateICC | ( | uint8_t | warm | ) |
void DeactivateICC | ( | ) |
uint8_t GetATRICC | ( | uint8_t * | inverse_convention, | |
uint8_t * | proto, | |||
uint8_t * | TC1, | |||
uint8_t * | TA3, | |||
uint8_t * | TB3 | |||
) |
Receives the ATR from ICC after a successful activation.
Receives the ATR from ICC after a successful activation
inverse_convention | non-zero if inverse convention is to be used | |
proto | 0 for T=0 and non-zero for T=1 | |
TC1 | see ISO 7816-3 or EMV Book 1 section ATR | |
TA3 | see ISO 7816-3 or EMV Book 1 section ATR | |
TB3 | see ISO 7816-3 or EMV Book 1 section ATR |
This implementation is compliant with EMV 4.2 Book 1
uint8_t GetByteICCNoParity | ( | uint8_t | inverse_convention, | |
uint8_t * | r_byte | |||
) |
Receives a byte from the ICC without parity checking.
Receives a byte from the ICC without parity checking
inverse_convention | different than 0 if inverse convention is to be used * | |
r_byte | contains the byte read on return |
ICC clock counter must be already enabled
uint8_t GetByteICCParity | ( | uint8_t | inverse_convention, | |
uint8_t * | r_byte | |||
) |
Receives a byte from the ICC with parity checking.
Receives a byte from the ICC with parity checking
inverse_convention | different than 0 if inverse convention is to be used * | |
r_byte | contains the byte read on return |
ICC clock counter must be already enabled
uint8_t GetByteTerminalNoParity | ( | uint8_t | inverse_convention, | |
uint8_t * | r_byte | |||
) |
Receives a byte from the terminal without parity check.
Receives a byte from the terminal without parity checking
inverse_convention | different than 0 if inverse convention is to be used | |
r_byte | contains the byte read on return |
Terminal clock counter must be already enabled
uint8_t GetByteTerminalParity | ( | uint8_t | inverse_convention, | |
uint8_t * | r_byte | |||
) |
Receives a byte from the terminal with parity check.
Receives a byte from the terminal with parity checking
inverse_convention | different than 0 if inverse convention is to be used | |
r_byte | contains the byte read on return |
Terminal clock counter must be enabled before calling this function
uint8_t GetResetStateTerminal | ( | ) |
uint16_t GetTerminalFreq | ( | ) |
uint8_t IsICCInserted | ( | ) |
uint8_t IsICCPowered | ( | ) |
void LoopICCETU | ( | uint8_t | nEtus | ) |
void LoopTerminalETU | ( | uint8_t | nEtus | ) |
void PauseCounterTerminal | ( | ) |
void PowerDownICC | ( | ) |
uint8_t PowerUpIcc | ( | ) |
Powers up the card, if possible.
uint16_t ReadCounterTerminal | ( | ) |
uint8_t ResetICC | ( | uint8_t | warm, | |
uint8_t * | inverse_convention, | |||
uint8_t * | proto, | |||
uint8_t * | TC1, | |||
uint8_t * | TA3, | |||
uint8_t * | TB3 | |||
) |
Starts a cold or warm reset for ICC.
Starts activation sequence for ICC
warm | 0 if a cold reset is to be issued, 1 otherwise | |
inverse_convention | non-zero if inverse convention is to be used | |
proto | 0 for T=0 and non-zero for T=1 | |
TC1 | see ISO 7816-3 or EMV Book 1 section ATR | |
TA3 | see ISO 7816-3 or EMV Book 1 section ATR | |
TB3 | see ISO 7816-3 or EMV Book 1 section ATR |
void SendByteICCNoParity | ( | uint8_t | byte, | |
uint8_t | inverse_convention | |||
) |
Sends a byte to the ICC without parity check.
Sends a byte to the ICC without parity error retransmission
byte | byte to be sent | |
inverse_convention | different than 0 if inverse convention is to be used |
The ICC clock counter must be started before calling this function
uint8_t SendByteICCParity | ( | uint8_t | byte, | |
uint8_t | inverse_convention | |||
) |
Sends a byte to the ICC with parity check.
Sends a byte to the ICC with parity error retransmission
byte | byte to be sent | |
inverse_convention | different than 0 if inverse convention is to be used |
As in the No Parity version, this function relies on counter started
void SendByteTerminalNoParity | ( | uint8_t | byte, | |
uint8_t | inverse_convention | |||
) |
Sends a byte to the terminal without parity check.
Sends a byte to the terminal without parity error retransmission
byte | byte to be sent | |
inverse_convention | different than 0 if inverse convention is to be used |
The terminal clock counter must be started before calling this function
uint8_t SendByteTerminalParity | ( | uint8_t | byte, | |
uint8_t | inverse_convention | |||
) |
Sends a byte to the terminal with parity check.
Sends a byte to the terminal with parity error retransmission
byte | byte to be sent | |
inverse_convention | different than 0 if inverse convention is to be used |
As in the NoParity version, this function relies on counter started
void SendT0ATRTerminal | ( | uint8_t | inverse_convention, | |
uint8_t | TC1 | |||
) |
Sends default ATR for T=0 to terminal.
Sends default ATR for T=0 to terminal
inverse_convention | specifies if direct (0) or inverse convention (non-zero) is to be used. Only direct convention should be used for future applications. | |
TC1 | specifies the TC1 byte of the ATR. This should be as small as possible in order to limit the latency of communication, or large if a large timeout between bytes is desired. |
void StartCounterTerminal | ( | ) |
Starts the counter for the external clock given by the terminal.
Starts the counter for the external clock given by the terminal
From hardware tests it seems that it is better to just leave the counter running all the time and just modify the register values as needed
void StopCounterTerminal | ( | ) |
uint8_t WaitForICCData | ( | uint16_t | max_cycles | ) |
Loops for max_cycles or until the I/O line from ICC becomes low.
Loops until the I/O line from ICC becomes low
max_cycles | the maximum number of clocks to wait for the I/O line to become low. Loops forever if this is 0 |