ID Chip Reader
bac_application.h
Go to the documentation of this file.
1 
11 #pragma once
12 #ifndef ACCESS_BAC_APPLICATION_H_
13 #define ACCESS_BAC_APPLICATION_H_
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #include "config.h"
20 
29 void KeySeedCalculate(unsigned char mrzInformation[], unsigned char mrzKeySeed[16]);
30 
40 void SessionKeyGenerate(unsigned char keySeed[16],
41  unsigned char encryptKeyBuf[16],
42  unsigned char macKeyBuf[16]);
43 
53 long InitReader(void);
54 
55 #if USE_NFC
65 long DetectCard(void);
66 #endif
67 
77 long SelectApplication(void);
78 
90 long GetChallenge(unsigned char getChallengeResponse[10], int getChallengeResponseSize);
91 
114 long ExternalAuthenticate(unsigned char getChallengeResponse[10],
115  unsigned char encryptKey[16],
116  unsigned char macKey[16],
117  unsigned char sessionKeyEncrypt[16],
118  unsigned char sessionKeyMac[16],
119  unsigned char sendSequenceCounter[8]);
120 
121 /*
122 * @brief Read EF.COM to get basic chip's information.
123  *
124  * Reads the EF.COM file from the smart card, which contains the LDS Version, Tag list, and DG list.
125  *
126  * @param[in] sessionKeyEncrypt The session encryption key as an array of 16 unsigned chars for
127  secure messaging.
128  * @param[in] sessionKeyMac The session MAC key as an array of 16 unsigned chars for secure
129  messaging.
130  * @param[in,out] sendSequenceCounter The send sequence counter as an array of 8 unsigned chars for
131  secure messaging, updated after each command/response exchange with the smart card.
132  *
133  * @return A long value representing the status code. APP_SUCCESS indicates successful reading,
134  otherwise an error code is returned.
135 */
136 long ReadEFCOM(unsigned char sessionKeyEncrypt[16],
137  unsigned char sessionKeyMac[16],
138  unsigned char sendSequenceCounter[8]);
139 
155 long ReadDG1(unsigned char sessionKeyEncrypt[16],
156  unsigned char sessionKeyMac[16],
157  unsigned char sendSequenceCounter[8]);
158 
176 long ReadDG2(unsigned char sessionKeyEncrypt[16],
177  unsigned char sessionKeyMac[16],
178  unsigned char sendSequenceCounter[8],
179  unsigned char imageFilePath[]);
180 
181 /*
182 * @brief Read DG13.COM to get holder's extra information.
183 *
184 * Reads the DG13 data group from the smart card, which contains extra information about the holder.
185 *
186 * @param[in] sessionKeyEncrypt The session encryption key as an array of 16 unsigned chars for
187 secure messaging.
188 * @param[in] sessionKeyMac The session MAC key as an array of 16 unsigned chars for secure
189 messaging.
190 * @param[in,out] sendSequenceCounter The send sequence counter as an array of 8 unsigned chars for
191 *
192 * @return A long value representing the status code. APP_SUCCESS indicates successful reading,
193 otherwise an error code is returned.
194 */
195 long ReadDG13(unsigned char sessionKeyEncrypt[16],
196  unsigned char sessionKeyMac[16],
197  unsigned char sendSequenceCounter[8]);
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 
203 #endif // #ifndef ACCESS_BAC_APPLICATION_H_