FedmIscTagHandler_ISO14443_4_MIFARE_Plus.cpp
Go to the documentation of this file.
00001 /*-------------------------------------------------------
00002 |                                                       |
00003 |      FedmIscTagHandler_ISO14443_4_MIFARE_Plus.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-4 MIFARE Plus
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_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 // class FedmIscTagHandler_ISO14443_4_MIFARE_Plus
00051 // >> supports only ISO Host Commands <<
00052 //####################################################################
00053 
00054         // public constructor not necessary, as this class represents not a real tag type
00055 /*FedmIscTagHandler_ISO14443_4_MIFARE_Plus::FedmIscTagHandler_ISO14443_4_MIFARE_Plus(
00056         FEDM_ISCReader* pReader, 
00057         FEDM_ISOTabItem* pTabItem )
00058         : FedmIscTagHandler_ISO14443_4(pReader, FedmIscTagHandler::TYPE_ISO14443_4, pTabItem)
00059 {
00060         m_sTagName = "ISO 14443-4 Type A : MIFARE Plus";
00061 
00062         Init();
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 // set all data members to 0
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   Begin                 :       24.08.2009 / M. Hultsch
00102 
00103   Version               :       03.01.00 / 25.08.2009 / M. Hultsch
00104 
00105   Function                      :       [0xC2][0x70] First Authentication with key from reader
00106 
00107                                                 NOTE: only for selected tags
00108 
00109   Parameters            :       unsigned int uiAesKeyBlockNumber        - [in] AES Key-Block-Number
00110                                                 unsigned char ucPcdCapLength            - [in] Length of PCD capabilities
00111                                                 unsigned char* pucPcdCap2                       - [in] PCD capabilities
00112                                                 unsigned char ucKeyIndex                        - [in] reader key index
00113 
00114   Return value          :       0                               - if tramsmission was successful
00115                                                 status byte (>1)- if the reader signals a problem
00116                                                 error code (<0) - if something goes wrong
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         // ... and execute
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   Begin                 :       24.08.2009 / M. Hultsch
00155 
00156   Version               :       03.01.00 / 25.08.2009 / M. Hultsch
00157 
00158   Function                      :       [0xC2][0x76] Following Authentication with key from reader
00159 
00160                                                 NOTE: only for selected tags
00161 
00162   Parameters            :       unsigned int uiAesKeyBlockNumber        - [in] AES Key-Block-Number
00163                                                 unsigned char ucKeyIndex                        - [in] reader key index
00164 
00165   Return value          :       0                               - if tramsmission was successful
00166                                                 status byte (>1)- if the reader signals a problem
00167                                                 error code (<0) - if something goes wrong
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         // ... and execute
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)


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