ATmega644 Smart-Card
Loading...
Searching...
No Matches
protocol.h
1
11#ifndef PROTOCOL_H
12#define PROTOCOL_H
13
14#include "defs.h"
15
25{
26private:
27 static constexpr byte_t TS = 0x3b;
28 static constexpr byte_t T0 = 0x90;
29 static constexpr byte_t TA1 = 0x11;
30 static constexpr byte_t TD1 = 0x00;
31 static constexpr byte_t CLA = 0x88;
32 static constexpr byte_t INS_DATA_IN = 0x10;
33 static constexpr byte_t INS_DATA_OUT = 0xc0;
34 static constexpr byte_t P1 = 0x00;
35 static constexpr byte_t P2 = 0x00;
36 static constexpr byte_t P3 = 0x10;
37public:
38 // Protocol definitions *********************************************************
39 // ATR
40 static constexpr byte_t ATR_SEQ[] = {TS, T0, TA1, TD1};
41 static constexpr uint8_t ATR_LENGTH = 4;
42 // Data in/out
43 static constexpr byte_t DATA_IN_HEADER[] = {CLA, INS_DATA_IN, P1, P2, P3};
44 static constexpr byte_t DATA_OUT_HEADER[] = {CLA, INS_DATA_OUT, P1, P2, P3};
45 static constexpr uint8_t HEADER_LENGTH = 5;
46 static constexpr byte_t ACK_DATA_IN = INS_DATA_IN ^ 0xff;
47 static constexpr byte_t ACK_DATA_OUT = INS_DATA_OUT;
48 static constexpr byte_t RESPONSE_DECRYPTED[]= {0x61, 0x10};
49 static constexpr byte_t RESPONSE_DATA_OUT[] = {0x9d, 0x00};
50 static constexpr uint8_t RESPONSE_LENGTH = 2;
51};
52
53#endif // PROTOCOL_H
Some definitions of the protocol used for communication between the SmartCard & Terminal.
Definition protocol.h:25
static constexpr uint8_t ATR_LENGTH
Length of the Answer-to-reset sequence.
Definition protocol.h:41
static constexpr byte_t DATA_IN_HEADER[]
T=0 protocol header for incoming data to be decrypted.
Definition protocol.h:43
static constexpr byte_t ATR_SEQ[]
Answer-to-reset sequence, send at the start.
Definition protocol.h:40
static constexpr byte_t RESPONSE_DECRYPTED[]
Response that is sent after the data to decrypt has been received.
Definition protocol.h:48
static constexpr uint8_t RESPONSE_LENGTH
Response length.
Definition protocol.h:50
static constexpr byte_t RESPONSE_DATA_OUT[]
Response after sending the decrypted data.
Definition protocol.h:49
static constexpr uint8_t HEADER_LENGTH
Length of the T=0 protocol headers.
Definition protocol.h:45
static constexpr byte_t ACK_DATA_IN
Acknowledge byte for instruction 0x10.
Definition protocol.h:46
static constexpr byte_t DATA_OUT_HEADER[]
T=0 protocol header for decrypted outgoing data.
Definition protocol.h:44
static constexpr byte_t ACK_DATA_OUT
Acknowledge byte for instruction 0xc0.
Definition protocol.h:47