Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)
00035
00036 #include "FedmIscTagHandler_ISO14443_4_MIFARE_Plus.h"
00037 #include "../FEDM_ISCReader.h"
00038 #include "../FEDM_ISOTabItem.h"
00039 #include "../FEDM_ISCReaderID.h"
00040 #include "../FEDM_ISC.h"
00041
00042
00043 #if _MSC_VER >= 1400
00044 #pragma warning(disable : 4996)
00045 #endif
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 FedmIscTagHandler_ISO14443_4_MIFARE_Plus::FedmIscTagHandler_ISO14443_4_MIFARE_Plus(
00066 FEDM_ISCReader* pReader,
00067 unsigned int uiTagHandlerType,
00068 FEDM_ISOTabItem* pTabItem )
00069 : FedmIscTagHandler_ISO14443_4(pReader, uiTagHandlerType, pTabItem)
00070 {
00071 m_sTagName = "ISO 14443-4 Type A : MIFARE Plus";
00072
00073 Init();
00074 }
00075
00076 FedmIscTagHandler_ISO14443_4_MIFARE_Plus::~FedmIscTagHandler_ISO14443_4_MIFARE_Plus()
00077 {
00078 }
00079
00080
00081 void FedmIscTagHandler_ISO14443_4_MIFARE_Plus::Init()
00082 {
00083 FedmIscTagHandler::Init();
00084
00085 m_ucErrorSource = 0;
00086 m_uiErrorCode = 0;
00087 }
00088
00089 unsigned char FedmIscTagHandler_ISO14443_4_MIFARE_Plus::GetErrorSource()
00090 {
00091 return m_ucErrorSource;
00092 }
00093
00094 unsigned int FedmIscTagHandler_ISO14443_4_MIFARE_Plus::GetErrorCode()
00095 {
00096 return m_uiErrorCode;
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus::FirstAuthent(
00119 unsigned int uiAesKeyBlockNumber,
00120 unsigned char ucPcdCapLength,
00121 unsigned char* pucPcdCap2,
00122 unsigned char ucReaderKeyIndex )
00123 {
00124 int iErr = 0;
00125
00126 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0x70));
00127 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00128 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_AES_KEY_BLOCK_NO, uiAesKeyBlockNumber));
00129 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_PCD_CAP_LEN, ucPcdCapLength));
00130 if(ucPcdCapLength > 0)
00131 {
00132 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_PCD_CAP, pucPcdCap2, ucPcdCapLength));
00133 }
00134 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_KEY_INDEX, ucReaderKeyIndex));
00135
00136
00137 int iBack = m_pReader->SendProtocol(0xC2);
00138 if( iBack==0x00 )
00139 {
00140 m_ucErrorSource = 0;
00141 m_uiErrorCode = 0;
00142 }
00143 else if( iBack==0x97 )
00144 {
00145 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00146 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00147 }
00148
00149 return iBack;
00150 }
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169 int FedmIscTagHandler_ISO14443_4_MIFARE_Plus::FollowingAuthent(
00170 unsigned int uiAesKeyBlockNumber,
00171 unsigned char ucReaderKeyIndex )
00172 {
00173 int iErr = 0;
00174
00175 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0x76));
00176 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00177 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_AES_KEY_BLOCK_NO, uiAesKeyBlockNumber));
00178 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_KEY_INDEX, ucReaderKeyIndex));
00179
00180
00181 int iBack = m_pReader->SendProtocol(0xC2);
00182 if( iBack==0x00 )
00183 {
00184 m_ucErrorSource = 0;
00185 m_uiErrorCode = 0;
00186 }
00187 else if( iBack==0x97 )
00188 {
00189 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00190 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00191 }
00192
00193 return iBack;
00194 }
00195
00196 #endif // #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)