AusweisApp2
 Alle Klassen Namensbereiche Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Propertys Freundbeziehungen Makrodefinitionen
Apdu.h
gehe zur Dokumentation dieser Datei
1 
5 #pragma once
6 
7 #include "CardReturnCode.h"
8 #include "EnumHelper.h"
9 
10 #include <QByteArray>
11 
12 namespace governikus
13 {
14 
15 defineTypedEnumType(StatusCode, quint16,
16  EMPTY = 0x0000,
17  INVALID = 0x0001,
18  SUCCESS = 0x9000,
19  NO_PKCS15_APP = 0x6200,
20  END_OF_FILE = 0x6282,
21  PIN_DEACTIVATED = 0x6283,
22  FCI_NO_ISO7816_4 = 0x6284,
23  VERIFICATION_FAILED = 0x6300,
24  INPUT_TIMEOUT = 0x6400,
25  INPUT_CANCELLED = 0x6401,
26  PASSWORDS_DIFFER = 0x6402,
27  PASSWORD_OUTOF_RANGE = 0x6403,
28  CARD_EJECTED_AND_REINSERTED = 0x64a2,
29  EEPROM_CELL_DEFECT = 0x6581,
30  SECURITY_ENVIRONMENT = 0x6600,
31  WRONG_LENGTH = 0x6700,
32  NO_BINARY_FILE = 0x6981,
33  ACCESS_DENIED = 0x6982,
34  PASSWORD_COUNTER_EXPIRED = 0x6983,
35  DIRECTORY_OR_PASSWORD_LOCKED_OR_NOT_ALLOWED = 0x6984,
36  NO_PARENT_FILE = 0x6985,
37  NOT_YET_INITIALIZED = 0x6985,
38  NO_CURRENT_DIRECTORY_SELECTED = 0x6986,
39  DATAFIELD_EXPECTED = 0x6987,
40  INVALID_SM_OBJECTS = 0x6988,
41  COMMAND_NOT_ALLOWED = 0x69f0,
42  INVALID_DATAFIELD = 0x6a80,
43  ALGORITHM_ID = 0x6a81,
44  FILE_NOT_FOUND = 0x6a82,
45  RECORD_NOT_FOUND = 0x6a83,
46  INVALID_PARAMETER = 0x6a86,
47  LC_INCONSISTANT = 0x6a87,
48  PASSWORD_NOT_FOUND = 0x6a88,
49  ILLEGAL_OFFSET = 0x6b00,
50  UNSUPPORTED_CLA = 0x6e00,
51  CANT_DISPLAY = 0x6410,
52  INVALID_P1P2 = 0x6a00,
53  UNSUPPORTED_INS = 0x6d00,
54  PIN_BLOCKED = 0x63c0, //retrys left 0
55  PIN_SUSPENDED = 0x63c1, //retrys left 1
56  PIN_RETRY_COUNT_2 = 0x63c2, //retrys left 2
57  )
58 
59 
60 /*
61  * As defined in ISO-7816-4 Table-5
62  */
63 defineEnumType(SW1,
64  INVALID = 0x00,
68  )
69 
70 class Apdu
71 {
72  protected:
73  QByteArray mBuffer;
74 
75  Apdu(const QByteArray& pBuffer);
76  virtual ~Apdu();
77 
78  public:
79  static const int NO_LE = 0;
80  static const int SHORT_MAX_LC = 0xff;
81  static const int SHORT_MAX_LE = 0x0100;
82  static const int EXTENDED_MAX_LC = 0x00ffff;
83  static const int EXTENDED_MAX_LE = 0x010000;
84  static const char CLA = 0x00;
85  static const char CLA_COMMAND_CHAINING = 0x10;
86  static const char CLA_SECURE_MESSAGING = 0x0c;
87  const QByteArray& getBuffer() const;
88  int length() const;
89 };
90 
92  : public Apdu
93 {
94  private:
95  bool mUpdateRetryCounter;
96 
97  inline bool isExtendedLength() const;
98 
99  public:
100  CommandApdu(const QByteArray& pBuffer, bool pUpdateRetryCounter = false);
101  CommandApdu(const QByteArray& pHeader, const QByteArray& pData, int pLe);
102  CommandApdu(char pCla, char pIns, char pP1, char pP2, const QByteArray& pData = QByteArray(), int pLe = NO_LE);
103  virtual ~CommandApdu();
104 
105  char getCLA() const;
106  char getINS() const;
107  char getP1() const;
108  char getP2() const;
109  int getLc() const;
110  int getLe() const;
111  QByteArray getData() const;
112  bool isUpdateRetryCounter() const;
113 
114  static bool isExtendedLength(const QByteArray& pData, int pLe);
115  static bool isSecureMessaging(const QByteArray& pCommandBuffer);
116 };
117 
119  : public Apdu
120 {
121 
122  private:
123  static const int RETURN_CODE_LENGTH = 2;
124 
125  public:
126  ResponseApdu(StatusCode pStatusCode);
127  ResponseApdu(const QByteArray& pBuffer = QByteArray());
128  virtual ~ResponseApdu();
129 
130  virtual void setBuffer(const QByteArray& pBuffer);
131  QByteArray getData() const;
132  int getDataLength() const;
133  StatusCode getReturnCode() const;
134  QByteArray getReturnCodeAsHex() const;
135  int getRetryCounter() const;
136  SW1 getSW1() const;
137  char getSW2() const;
138  CardReturnCode getCardReturnCode() const;
139 };
140 
141 } /* namespace governikus */
SW1 getSW1() const
Definition: Apdu.cpp:321
char getP2() const
Definition: Apdu.cpp:154
CommandApdu(const QByteArray &pBuffer, bool pUpdateRetryCounter=false)
Definition: Apdu.cpp:42
virtual ~ResponseApdu()
Definition: Apdu.cpp:252
ResponseApdu(StatusCode pStatusCode)
Definition: Apdu.cpp:237
virtual void setBuffer(const QByteArray &pBuffer)
Definition: Apdu.cpp:257
int getRetryCounter() const
Definition: Apdu.cpp:298
char getSW2() const
Definition: Apdu.cpp:332
Definition: Apdu.h:70
MORE_DATA_AVAILABLE
Definition: Apdu.h:65
WRONG_LE_FIELD
Definition: Apdu.h:67
CardReturnCode getCardReturnCode() const
Definition: Apdu.cpp:343
char getINS() const
Definition: Apdu.cpp:142
virtual ~CommandApdu()
Definition: Apdu.cpp:131
QByteArray getReturnCodeAsHex() const
Definition: Apdu.cpp:292
int getDataLength() const
Definition: Apdu.cpp:274
ERROR_COMMAND_NOT_ALLOWED
Definition: Apdu.h:66
StatusCode getReturnCode() const
Definition: Apdu.cpp:280
Definition: Apdu.h:91
QByteArray mBuffer
Definition: Apdu.h:73
static bool isSecureMessaging(const QByteArray &pCommandBuffer)
Definition: Apdu.cpp:65
static const int NO_LE
Definition: Apdu.h:79
int getLc() const
Definition: Apdu.cpp:166
QByteArray getData() const
Definition: Apdu.cpp:263
char getCLA() const
Definition: Apdu.cpp:136
int getLe() const
Definition: Apdu.cpp:187
QByteArray getData() const
Definition: Apdu.cpp:214
defineEnumType(UiModule, CURRENT, DEFAULT, IDENTIFY, SETTINGS, PINMANAGEMENT) defineEnumType(StatusFormat
UI modules that can be requested to show.
INVALID
Definition: Apdu.h:64
Definition: Apdu.h:118
char getP1() const
Definition: Apdu.cpp:148
defineTypedEnumType(StatusCode, quint16, EMPTY=0x0000, INVALID=0x0001, SUCCESS=0x9000, NO_PKCS15_APP=0x6200, END_OF_FILE=0x6282, PIN_DEACTIVATED=0x6283, FCI_NO_ISO7816_4=0x6284, VERIFICATION_FAILED=0x6300, INPUT_TIMEOUT=0x6400, INPUT_CANCELLED=0x6401, PASSWORDS_DIFFER=0x6402, PASSWORD_OUTOF_RANGE=0x6403, CARD_EJECTED_AND_REINSERTED=0x64a2, EEPROM_CELL_DEFECT=0x6581, SECURITY_ENVIRONMENT=0x6600, WRONG_LENGTH=0x6700, NO_BINARY_FILE=0x6981, ACCESS_DENIED=0x6982, PASSWORD_COUNTER_EXPIRED=0x6983, DIRECTORY_OR_PASSWORD_LOCKED_OR_NOT_ALLOWED=0x6984, NO_PARENT_FILE=0x6985, NOT_YET_INITIALIZED=0x6985, NO_CURRENT_DIRECTORY_SELECTED=0x6986, DATAFIELD_EXPECTED=0x6987, INVALID_SM_OBJECTS=0x6988, COMMAND_NOT_ALLOWED=0x69f0, INVALID_DATAFIELD=0x6a80, ALGORITHM_ID=0x6a81, FILE_NOT_FOUND=0x6a82, RECORD_NOT_FOUND=0x6a83, INVALID_PARAMETER=0x6a86, LC_INCONSISTANT=0x6a87, PASSWORD_NOT_FOUND=0x6a88, ILLEGAL_OFFSET=0x6b00, UNSUPPORTED_CLA=0x6e00, CANT_DISPLAY=0x6410, INVALID_P1P2=0x6a00, UNSUPPORTED_INS=0x6d00, PIN_BLOCKED=0x63c0, PIN_SUSPENDED=0x63c1, PIN_RETRY_COUNT_2=0x63c2,) defineEnumType(SW1
bool isUpdateRetryCounter() const
Definition: Apdu.cpp:231