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_3_MIFARE_Plus_SL2.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 FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2::FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2(
00055 FEDM_ISCReader* pReader,
00056 FEDM_ISOTabItem* pTabItem )
00057 : FedmIscTagHandler_ISO14443_3_MIFARE_Plus(pReader, FedmIscTagHandler::TYPE_ISO14443_3_MIFARE_PLUS_SL2, pTabItem)
00058 {
00059 m_sTagName = "ISO 14443-3 Type A : MIFARE Plus in Security Level 2";
00060 }
00061
00062 FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2::FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2(
00063 FEDM_ISCReader* pReader,
00064 unsigned int uiTagHandlerType,
00065 FEDM_ISOTabItem* pTabItem )
00066 : FedmIscTagHandler_ISO14443_3_MIFARE_Plus(pReader, uiTagHandlerType, pTabItem)
00067 {
00068 m_sTagName = "ISO 14443-3 Type A : MIFARE Plus in Security Level 2";
00069 }
00070
00071 FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2::~FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2()
00072 {
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 int FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2::AESandCrypto1Authent(
00100 unsigned int uiDBAddr,
00101 unsigned char ucKeyType,
00102 unsigned char ucKeyNo,
00103 unsigned char ucReaderKeyIndex )
00104 {
00105 int iErr = 0;
00106
00107 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0x75));
00108 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00109 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_KEY_INDEX, ucReaderKeyIndex));
00110 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_KEY_TYPE, ucKeyType));
00111 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_KEY_NO, ucKeyNo));
00112 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_DB_ADR, uiDBAddr));
00113
00114
00115 int iBack = m_pReader->SendProtocol(0xC2);
00116 if( iBack==0x00 )
00117 {
00118 m_ucErrorSource = 0;
00119 m_uiErrorCode = 0;
00120 }
00121 else if( iBack==0x97 )
00122 {
00123 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00124 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00125 }
00126
00127 return iBack;
00128 }
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 int FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2::MultiBlockRead(
00149 unsigned int uiBlockNo,
00150 unsigned char ucLength,
00151 unsigned char* pucResponseData )
00152 {
00153 int iErr = 0;
00154
00155 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0x38));
00156 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00157 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_SRC_BLOCK_NO, uiBlockNo));
00158 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_EXT, ucLength));
00159
00160
00161 int iBack = m_pReader->SendProtocol(0xC2);
00162 if( iBack==0x00 )
00163 {
00164 memcpy(pucResponseData, &m_pTabItem->m_ucRxDB[uiBlockNo * 16], ucLength * 16);
00165 m_ucErrorSource = 0;
00166 m_uiErrorCode = 0;
00167 }
00168 else if( iBack==0x97 )
00169 {
00170 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00171 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00172 }
00173
00174 return iBack;
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 int FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2::MultiBlockWrite(
00196 unsigned int uiBlockNo,
00197 unsigned char ucLength,
00198 unsigned char* pucRequestData )
00199 {
00200 int iErr = 0;
00201
00202 if(ucLength * 16 > FEDM_ISC_ISO_TABLE_TxDB_SIZE)
00203 return FEDM_ERROR_ARRAY_BOUNDARY;
00204
00205 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_CMD, (unsigned char)0xA8));
00206 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_MODE, (unsigned char)0x00));
00207 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_BLOCK_NO, uiBlockNo));
00208 FEDM_CHK1(iErr, m_pReader->SetData(FEDM_ISC_TMP_0xC2_EXT, ucLength));
00209
00210 memcpy(&m_pTabItem->m_ucTxDB[uiBlockNo * 16], pucRequestData, ucLength * 16);
00211
00212
00213 int iBack = m_pReader->SendProtocol(0xC2);
00214 if( iBack==0x00 )
00215 {
00216 m_ucErrorSource = 0;
00217 m_uiErrorCode = 0;
00218 }
00219 else if( iBack==0x97 )
00220 {
00221 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_SOURCE, &m_ucErrorSource));
00222 FEDM_CHK1(iErr, m_pReader->GetData(FEDM_ISC_TMP_0xC2_ERROR_CODE, &m_uiErrorCode));
00223 }
00224
00225 return iBack;
00226 }
00227
00228 #endif // #if !defined(_FEDM_NO_TAG_HANDLER_ISO14443)