AusweisApp2
ResponseApdu.h
gehe zur Dokumentation dieser Datei
1
5#pragma once
6
7#include "CardReturnCode.h"
8#include "EnumHelper.h"
9
10
11namespace governikus
12{
13defineTypedEnumType(StatusCode, quint16,
14 UNKNOWN = 0x0000,
15 SUCCESS = 0x9000,
16 NO_PKCS15_APP = 0x6200,
17 END_OF_FILE = 0x6282,
18 PIN_DEACTIVATED = 0x6283,
19 FCI_NO_ISO7816_4 = 0x6284,
20 VERIFICATION_FAILED = 0x6300,
21 INPUT_TIMEOUT = 0x6400,
22 INPUT_CANCELLED = 0x6401,
23 PASSWORDS_DIFFER = 0x6402,
24 PASSWORD_OUTOF_RANGE = 0x6403,
25 CARD_EJECTED_AND_REINSERTED = 0x64A2,
26 EEPROM_CELL_DEFECT = 0x6581,
27 SECURITY_ENVIRONMENT = 0x6600,
28 WRONG_LENGTH = 0x6700,
29 NO_BINARY_FILE = 0x6981,
30 LAST_CHAIN_CMD_EXPECTED = 0x6883,
31 ACCESS_DENIED = 0x6982,
32 PASSWORD_COUNTER_EXPIRED = 0x6983,
33 DIRECTORY_OR_PASSWORD_LOCKED_OR_NOT_ALLOWED = 0x6984,
34 NO_PARENT_FILE = 0x6985,
35 NOT_YET_INITIALIZED = 0x6985,
36 NO_CURRENT_DIRECTORY_SELECTED = 0x6986,
37 DATAFIELD_EXPECTED = 0x6987,
38 INVALID_SM_OBJECTS = 0x6988,
39 COMMAND_NOT_ALLOWED = 0x69F0,
40 INVALID_DATAFIELD = 0x6A80,
41 ALGORITHM_ID = 0x6A81,
42 FILE_NOT_FOUND = 0x6A82,
43 RECORD_NOT_FOUND = 0x6A83,
44 INVALID_PARAMETER = 0x6A86,
45 LC_INCONSISTANT = 0x6A87,
46 PASSWORD_NOT_FOUND = 0x6A88,
47 ILLEGAL_OFFSET = 0x6B00,
48 UNSUPPORTED_CLA = 0x6E00,
49 CANT_DISPLAY = 0x6410,
50 INVALID_P1P2 = 0x6A00,
51 UNSUPPORTED_INS = 0x6D00,
52 PIN_BLOCKED = 0x63C0, // retries left: 0
53 PIN_SUSPENDED = 0x63C1, // retries left: 1
54 PIN_RETRY_COUNT_2 = 0x63C2, // retries left: 2
55 INITIAL_PIN_BLOCKED = 0x63D0,
56 INITIAL_PIN_RETRY_COUNT_1 = 0x63D1,
57 INITIAL_PIN_RETRY_COUNT_2 = 0x63D2,
58 INITIAL_PIN_RETRY_COUNT_3 = 0x63D3
59 )
60
61// According to ISO-7816-4, 5.6 Status bytes, Table 6
63 UNKNOWN = 0x00,
79 SUCCESS = 0x90
80 )
81
82class ResponseApdu final
83{
84 private:
85 quint16 mStatusCode;
86 QByteArray mData;
87
88 public:
89 explicit ResponseApdu(StatusCode pStatusCode, const QByteArray& pData = QByteArray());
90 explicit ResponseApdu(const QByteArray& pBuffer = QByteArray());
91
92 [[nodiscard]] bool isEmpty() const;
93 [[nodiscard]] const QByteArray& getData() const;
94 [[nodiscard]] StatusCode getStatusCode() const;
95 [[nodiscard]] QByteArray getStatusBytes() const;
96 [[nodiscard]] SW1 getSW1() const;
97 [[nodiscard]] char getSW2() const;
98
99 operator QByteArray() const;
100};
101
102
103inline QDebug operator<<(QDebug pDbg, const ResponseApdu& pResponseApdu)
104{
105 QDebugStateSaver saver(pDbg);
106 pDbg << QByteArray(pResponseApdu).toHex();
107 return pDbg;
108}
109
110
111char* toString(const ResponseApdu& pResponseApdu);
112
113
115{
116 CardReturnCode mReturnCode = CardReturnCode::UNDEFINED;
117 ResponseApdu mResponseApdu = ResponseApdu();
118};
119
120#ifndef QT_NO_DEBUG
121inline bool operator==(const ResponseApdu& pLeft, const ResponseApdu& pRight)
122{
123 return QByteArray(pLeft) == QByteArray(pRight);
124}
125
126
127inline bool operator==(const ResponseApduResult& pLeft, const ResponseApduResult& pRight)
128{
129 return pLeft.mReturnCode == pRight.mReturnCode && pLeft.mResponseApdu == pRight.mResponseApdu;
130}
131
132
133#endif
134
135} // namespace governikus
struct Data mData
A simple template renderer.
Definition: ActivationContext.h:15
quint8
Definition: ResponseApdu.h:62
UNKNOWN
Definition: ResponseApdu.h:63
WRONG_PARAMETERS_P1_P2_NO_INFO
Definition: ResponseApdu.h:74
char * toString(const CommandApdu &pCommandApdu)
WRONG_LENGTH
Definition: ResponseApdu.h:70
MORE_DATA_AVAILABLE
Definition: ResponseApdu.h:64
WRONG_PARAMETERS_P1_P2
Definition: ResponseApdu.h:73
FUNCTIONS_IN_CLASS_NOT_SUPPORTED
Definition: ResponseApdu.h:71
NONVOLATILE_MEMORY_CHANGED_2
Definition: ResponseApdu.h:68
SECURITY_ISSUE
Definition: ResponseApdu.h:69
WRONG_LE_FIELD
Definition: ResponseApdu.h:75
NONVOLATILE_MEMORY_UNCHANGED_1
Definition: ResponseApdu.h:65
ERROR_COMMAND_NOT_ALLOWED
Definition: ResponseApdu.h:72
defineTypedEnumType(Ins, uchar, UNKNOWN=0x00, MSE_SET=0x22, EXTERNAL_AUTHENTICATE=0x82, GET_CHALLENGE=0x84, GENERAL_AUTHENTICATE=0x86, PSO_VERIFY=0x2A, PSO_COMPUTE=0x2B, RESET_RETRY_COUNTER=0x2C, SELECT=0xA4, READ_BINARY=0xB0, GET_RESPONSE=0xC0, UPDATE_BINARY=0xD6) class CommandApdu
Definition: CommandApdu.h:17
INSTRUCTION_CODE_INVALID
Definition: ResponseApdu.h:76
QDebug operator<<(QDebug pDbg, const CommandApdu &pCommandApdu)
Definition: CommandApdu.h:89
NO_PRECISE_DIAGNOSIS
Definition: ResponseApdu.h:78
NONVOLATILE_MEMORY_UNCHANGED_2
Definition: ResponseApdu.h:67
NONVOLATILE_MEMORY_CHANGED_1
Definition: ResponseApdu.h:66
CLASS_NOT_SUPPORTED
Definition: ResponseApdu.h:77
bool operator==(const CommandApdu &pLeft, const CommandApdu &pRight)
Definition: CommandApdu.h:100
SUCCESS
Definition: ResponseApdu.h:79
Definition: ResponseApdu.h:115
CardReturnCode mReturnCode
Definition: ResponseApdu.h:116
ResponseApdu mResponseApdu
Definition: ResponseApdu.h:117