FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2.cpp
Go to the documentation of this file.
00001 /*-------------------------------------------------------
00002 |                                                       |
00003 |      FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2.cpp |
00004 |                                                       |
00005 ---------------------------------------------------------
00006 
00007 Copyright © 2009-2010   FEIG ELECTRONIC GmbH, All Rights Reserved.
00008                                                 Lange Strasse 4
00009                                                 D-35781 Weilburg
00010                                                 Federal Republic of Germany
00011                                                 phone    : +49 6471 31090
00012                                                 fax      : +49 6471 310999
00013                                                 e-mail   : obid-support@feig.de
00014                                                 Internet : http://www.feig.de
00015                                         
00016 Author                  :       Markus Hultsch
00017 Begin                   :       24.08.2009
00018 
00019 Version                 :       03.01.00 / 10.02.2010 / M. Hultsch
00020 
00021 Operation Systems       :       independent
00022 
00023 Function                        :       class for OBID® classic-pro transponder ISO14443-3 MIFARE Plus in Security Level 2
00024 
00025 NOTE                            :       this class supports only selected or addressed mode in Host-Mode
00026 
00027 
00028 Trademarks:
00029 -----------
00030 OBID®, OBID i-scan® and OBID myAXXESS® are registered Trademarks of FEIG ELECTRONIC GmbH
00031 Other Trademarks: see FEDM.h
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 // class FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2
00051 // >> supports only ISO Host Commands <<
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 // set all data members to 0
00076 /*void FedmIscTagHandler_ISO14443_3_MIFARE_Plus_SL2::Init()
00077 {
00078 }*/
00079 
00080 
00081 /***************************************************************************
00082   Begin                 :       01.09.2009 / M. Hultsch
00083 
00084   Version               :       03.01.00 / 01.09.2009 / M. Hultsch
00085 
00086   Function                      :       [0xC2][0x75] SL2 AES and Crypto1 Authent
00087 
00088                                                 NOTE: only for selected tags
00089 
00090   Parameters            :       unsigned int uiDBAddr           - [in] address of data block to be authenticated
00091                                                 unsigned char ucKeyType         - [in] key type of crypto1 key
00092                                                 unsigned char ucKeyNo           - [in] EEPROM address where the crypto1 key is stored in the reader
00093                                                 unsigned char ucKeyIndex        - [in] reader key index
00094 
00095   Return value          :       0                               - if tramsmission was successful
00096                                                 status byte (>1)- if the reader signals a problem
00097                                                 error code (<0) - if something goes wrong
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         // ... and execute
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   Begin                 :       04.09.2009 / M. Hultsch
00133 
00134   Version               :       03.01.00 / 04.09.2009 / M. Hultsch
00135 
00136   Function                      :       [0xC2][0x38] SL2 MultiBlock Read
00137 
00138                                                 NOTE: only for selected tags
00139 
00140   Parameters            :       unsigned int uiBlockNo                  - [in] first data block address
00141                                                 unsigned char ucLength                  - [in] number of blocks to be read
00142                                                 unsigned char* pucResponseData  - [in] pointer to response data buffer
00143 
00144   Return value          :       0                               - if tramsmission was successful
00145                                                 status byte (>1)- if the reader signals a problem
00146                                                 error code (<0) - if something goes wrong
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         // ... and execute
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   Begin                 :       04.09.2009 / M. Hultsch
00180 
00181   Version               :       03.01.00 / 04.09.2009 / M. Hultsch
00182 
00183   Function                      :       [0xC2][0xA8] SL2 MultiBlock Write
00184 
00185                                                 NOTE: only for selected tags
00186 
00187   Parameters            :       unsigned int uiBlockNo                  - [in] first data block address
00188                                                 unsigned char ucLength                  - [in] number of blocks to be read
00189                                                 unsigned char* pucRequestData   - [in] pointer to request data buffer
00190 
00191   Return value          :       0                               - if tramsmission was successful
00192                                                 status byte (>1)- if the reader signals a problem
00193                                                 error code (<0) - if something goes wrong
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         // ... and execute
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)


maggie_rfid_drivers
Author(s): Raul Perula-Martinez
autogenerated on Mon Sep 14 2015 03:05:30