NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
be_device_smartcard_apdu.h
Go to the documentation of this file.
1/*
2 * This software was developed at the National Institute of Standards and
3 * Technology (NIST) by employees of the Federal Government in the course
4 * of their official duties. Pursuant to title 17 Section 105 of the
5 * United States Code, this software is not subject to copyright protection
6 * and is in the public domain. NIST assumes no responsibility whatsoever for
7 * its use by other parties, and makes no guarantees, expressed or implied,
8 * about its quality, reliability, or any other characteristic.
9 */
10
11#ifndef __BE_DEVICE_SMARTCARD_APDU_H__
12#define __BE_DEVICE_SMARTCARD_APDU_H__
13
14#include <cstdint>
15#include <string>
16#include <be_device_smartcard.h>
17
18namespace BiometricEvaluation
19{
20 namespace Device
21 {
26 public:
27 /* Bit masks to indicate optional fields to include */
28
30 static const int FIELD_LC{0x00000001};
32 static const int FIELD_LE{0x00000002};
33
34 /* Define the length of the APDU fields */
35 static const int FLEN_CLA{1};
36 static const int FLEN_INS{1};
37 static const int FLEN_P1{1};
38 static const int FLEN_P2{1};
39 static const int FLEN_LC_SHORT{1};
40 static const int FLEN_LC_EXTENDED{3};
41 static const int FLEN_LE_SHORT{1};
42 static const int FLEN_LE_EXTENDED{3};
43 static const int FLEN_TRAILER{2};
44
45 static const int FLAG_CLA_NOCHAIN{0x00};
46 static const int FLAG_CLA_CHAIN{0x10};
47
48 /*
49 * The max size of any command data is determined by
50 * the max size of the Le field, and that is 0 (absent),
51 * 1, or 3 bytes. In the 3-byte case, the first byte is
52 * 0x00, and the next two are 0x0001-0xFFFF.
53 * The same approach is used for the expected response
54 * Le field.
55 */
56 static const int MAX_NC_SIZE{0xFFFF};
57 static const int MAX_LE_SIZE{0xFFFF};
58
59 static const int MAX_SHORT_LC{255};
60 static const int MAX_SHORT_LE{255};
61 static const int HEADER_LEN
63
64 /*
65 * Define some response codes for SW1.
66 */
67 static const int NORMAL_COMPLETE{0x90};
68 static const int NORMAL_CHAINING{0x61};
69 static const int WARN_NVM_UNCHANGED{0x62};
70 static const int WARN_NVM_CHANGED{0x63};
71 static const int EXEC_ERR_NVM_UNCHANGED{0x64};
72 static const int EXEC_ERR_NVM_CHANGED{0x65};
73 static const int EXEC_ERR_SECURITY{0x66};
74 static const int CHECK_ERR_WRONG_LENGTH{0x67};
75 static const int CHECK_ERR_CLA_FUNCTION{0x68};
76 static const int CHECK_ERR_CMD_NOT_ALLOWED{0x69};
77 static const int CHECK_ERR_WRONG_PARAM_QUAL{0x6A};
78 static const int CHECK_ERR_WRONG_PARAM{0x6B};
79 static const int CHECK_ERR_WRONG_LE{0x6C};
80 static const int CHECK_ERR_INVALID_INS{0x6D};
81 static const int CHECK_ERR_CLA_UNSUPPORTED{0x6E};
82 static const int CHECK_ERR_NO_DIAGNOSIS{0x6F};
83
84 /*
85 * Define some response codes for SW2.
86 */
87 static const int NO_INFORMATION{0x00};
88 static const int INCORRECT_PARAMETERS{0x80};
89 static const int FUNCTION_NOT_SUPPORTED{0x81};
90 static const int FILE_OR_APP_NOT_FOUND{0x82};
91
92 /*
93 * Mask for SW2 retry counter.
94 */
95 static const int RETRY_COUNTER_MASK{0x0F};
96 static const int RETRY_COUNTER_INDICATOR{0xC0};
97 static const int RETRY_COUNTER_INDICATOR_MASK{0xF0};
98 static const int RETRY_COUNTER_MAX{15};
99
100 /*
101 * Data that makes up the actual APDU fields.
102 */
103
105 uint8_t cla;
107 uint8_t ins;
109 uint8_t p1;
111 uint8_t p2;
113 uint16_t lc;
115 uint8_t nc[MAX_NC_SIZE];
117 uint16_t le;
119 uint8_t field_mask;
120 };
121 }
122}
123#endif /* __BE_DEVICE_SMARTCARD_APDU_H__ */
124
static const int FIELD_LE
Le field is present, response data expected.
uint16_t le
Le, expected response length.
uint8_t nc[MAX_NC_SIZE]
Nc, command data.
uint8_t field_mask
Mask of optional fields; use field bit masks.
static const int FIELD_LC
Lc field is present; Implies Nc present as well.
This software was developed at the National Institute of Standards and Technology (NIST) by employees...